From e566955acb8e57c80b6942f5ff70d260ab2ea4a3 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Mon, 17 Apr 2023 21:04:39 -0600 Subject: [PATCH] Calculate convential fee in `CreateTransaction` before stripping sigs. --- src/wallet/wallet.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f535d7fac..89d5f3f74 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -5703,15 +5703,6 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt unsigned int nBytes = ::GetSerializeSize(txNew, SER_NETWORK, PROTOCOL_VERSION); - // Remove scriptSigs if we used dummy signatures for fee calculation - if (!sign) { - for (CTxIn& vin : txNew.vin) - vin.scriptSig = CScript(); - } - - // Embed the constructed transaction data in wtxNew. - *static_cast(&wtxNew) = CTransaction(txNew); - // Limit size if (nBytes >= max_tx_size) { @@ -5721,6 +5712,15 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt CAmount nFeeNeeded = GetMinimumFee(txNew, nBytes); + // Remove scriptSigs if we used dummy signatures for fee calculation + if (!sign) { + for (CTxIn& vin : txNew.vin) + vin.scriptSig = CScript(); + } + + // Embed the constructed transaction data in wtxNew. + *static_cast(&wtxNew) = CTransaction(txNew); + // If we made it here and we aren't even able to meet the relay fee on the next pass, give up // because we must be at the maximum allowed fee. if (nFeeNeeded < ::minRelayTxFee.GetFeeForRelay(nBytes))