Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose ExplicitCoveredFields from the wallet package #37

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading