From c76aaaf90034a15917d02a71e3fdc36e8dd927f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Mon, 13 May 2024 22:03:27 +0200 Subject: [PATCH 1/2] Reserve space for transaction outputs in CreateTransactionInternal Accommodating possible later insert as well Co-authored-by: Cory Fields --- src/wallet/spend.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 0a59353052b..e1a4e8afc4d 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -1154,6 +1154,7 @@ static util::Result CreateTransactionInternal( result.GetSelectedValue()); // vouts to the payees + txNew.vout.reserve(vecSend.size() + 1); // + 1 because of possible later insert for (const auto& recipient : vecSend) { txNew.vout.emplace_back(recipient.nAmount, GetScriptForDestination(recipient.dest)); From ec585f11c38bbe277a596dcea3c813e7c6626050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Mon, 13 May 2024 22:04:04 +0200 Subject: [PATCH 2/2] Reserve space for transaction inputs in CreateTransactionInternal Co-authored-by: Cory Fields --- src/wallet/spend.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index e1a4e8afc4d..245c5852246 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -1205,6 +1205,7 @@ static util::Result CreateTransactionInternal( // behavior." bool use_anti_fee_sniping = true; const uint32_t default_sequence{coin_control.m_signal_bip125_rbf.value_or(wallet.m_signal_rbf) ? MAX_BIP125_RBF_SEQUENCE : CTxIn::MAX_SEQUENCE_NONFINAL}; + txNew.vin.reserve(selected_coins.size()); for (const auto& coin : selected_coins) { std::optional sequence = coin_control.GetSequence(coin->outpoint); if (sequence) {