Calculate convential fee in `CreateTransaction` before stripping sigs.

This commit is contained in:
Kris Nuttycombe 2023-04-17 21:04:39 -06:00
parent bf68d69439
commit e566955acb
1 changed files with 9 additions and 9 deletions

View File

@ -5703,15 +5703,6 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& 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<CTransaction*>(&wtxNew) = CTransaction(txNew);
// Limit size
if (nBytes >= max_tx_size)
{
@ -5721,6 +5712,15 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& 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<CTransaction*>(&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))