Skip to content

Commit

Permalink
refactor: move oversized transaction check to tail end of scope
Browse files Browse the repository at this point in the history
Change needed so that next commit can extend check to include
post-signature size.
  • Loading branch information
kwvg committed Feb 9, 2025
1 parent 6ca51df commit 05c319e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/wallet/spend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,12 +796,6 @@ bool CWallet::CreateTransactionInternal(
nBytes += GetSizeOfCompactSize(nExtraPayloadSize) + nExtraPayloadSize;
}

if (static_cast<size_t>(nBytes) > MAX_STANDARD_TX_SIZE) {
// Do not create oversized transactions (bad-txns-oversize).
error = _("Transaction too large");
return false;
}

// Remove scriptSigs to eliminate the fee calculation dummy signatures
for (auto& txin : txNew.vin) {
txin.scriptSig = CScript();
Expand Down Expand Up @@ -962,6 +956,12 @@ bool CWallet::CreateTransactionInternal(

// Return the constructed transaction data.
tx = MakeTransactionRef(std::move(txNew));

// Limit size
if (static_cast<size_t>(nBytes) > MAX_STANDARD_TX_SIZE) {
error = _("Transaction too large");
return false;
}
}

if (nFeeRet > m_default_max_tx_fee) {
Expand Down

0 comments on commit 05c319e

Please sign in to comment.