From 09f82abd5d2572694fa59d9cab3295e4cccd89be Mon Sep 17 00:00:00 2001 From: PJ Date: Tue, 12 Mar 2024 14:37:12 +0100 Subject: [PATCH] wallet: add ExplicitCoveredFields --- wallet/wallet.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/wallet/wallet.go b/wallet/wallet.go index e9f81a7..148074b 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -645,6 +645,42 @@ func IsRelevantTransaction(txn types.Transaction, addr types.Address) bool { return false } +// ExplicitCoveredFields returns a CoveredFields that covers all elements +// present in txn. +func ExplicitCoveredFields(txn types.Transaction) (cf types.CoveredFields) { + for i := range txn.SiacoinInputs { + cf.SiacoinInputs = append(cf.SiacoinInputs, uint64(i)) + } + for i := range txn.SiacoinOutputs { + cf.SiacoinOutputs = append(cf.SiacoinOutputs, uint64(i)) + } + for i := range txn.FileContracts { + cf.FileContracts = append(cf.FileContracts, uint64(i)) + } + for i := range txn.FileContractRevisions { + cf.FileContractRevisions = append(cf.FileContractRevisions, uint64(i)) + } + for i := range txn.StorageProofs { + cf.StorageProofs = append(cf.StorageProofs, uint64(i)) + } + for i := range txn.SiafundInputs { + cf.SiafundInputs = append(cf.SiafundInputs, uint64(i)) + } + for i := range txn.SiafundOutputs { + cf.SiafundOutputs = append(cf.SiafundOutputs, uint64(i)) + } + for i := range txn.MinerFees { + cf.MinerFees = append(cf.MinerFees, uint64(i)) + } + for i := range txn.ArbitraryData { + cf.ArbitraryData = append(cf.ArbitraryData, uint64(i)) + } + for i := range txn.Signatures { + cf.Signatures = append(cf.Signatures, uint64(i)) + } + return +} + // SumOutputs returns the total value of the supplied outputs. func SumOutputs(outputs []types.SiacoinElement) (sum types.Currency) { for _, o := range outputs {