From 4e3ea7442eab3bc2a93d0c2a9196f995020336f5 Mon Sep 17 00:00:00 2001 From: Nate Maninger Date: Fri, 29 Sep 2023 08:25:24 -0600 Subject: [PATCH] rhp3: sign transactions with WholeCoveredFields --- rhp/v3/rpc.go | 2 +- wallet/wallet.go | 36 ------------------------------------ 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/rhp/v3/rpc.go b/rhp/v3/rpc.go index c714cb96..b6161582 100644 --- a/rhp/v3/rpc.go +++ b/rhp/v3/rpc.go @@ -399,7 +399,7 @@ func (sh *SessionHandler) handleRPCRenew(s *rhp3.Stream, log *zap.Logger) (contr renterSigs := len(renewalTxn.Signatures) // sign and broadcast the transaction - if err := sh.wallet.SignTransaction(sh.chain.TipState(), &renewalTxn, toSign, wallet.ExplicitCoveredFields(renewalTxn)); err != nil { + if err := sh.wallet.SignTransaction(sh.chain.TipState(), &renewalTxn, toSign, types.CoveredFields{WholeTransaction: true}); err != nil { s.WriteResponseErr(fmt.Errorf("failed to sign renewal transaction: %w", ErrHostInternalError)) return contracts.Usage{}, fmt.Errorf("failed to sign renewal transaction: %w", err) } diff --git a/wallet/wallet.go b/wallet/wallet.go index adf57339..e97f960f 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -731,42 +731,6 @@ func convertToCore(siad encoding.SiaMarshaler, core types.DecoderFrom) { } } -// 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 -} - // NewSingleAddressWallet returns a new SingleAddressWallet using the provided private key and store. func NewSingleAddressWallet(priv types.PrivateKey, cm ChainManager, tp TransactionPool, store SingleAddressStore, log *zap.Logger) (*SingleAddressWallet, error) { changeID, scanHeight, err := store.LastWalletChange()