wallet: Pass replaces_txid to CommitTransaction outside of mapValue
What changed, and why it matters
This is a small internal code cleanup in Bitcoin Core's wallet. It changes how a transaction ID is passed when a user bumps a transaction fee, moving the value from a general metadata map into a dedicated function parameter. There is no security bug being fixed here and no user-facing behavior change.
No security action needed. Treat as ordinary refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors CWallet::CommitTransaction to accept an optional replaces_txid parameter instead of requiring callers to insert “replaces_txid” into the mapValue map before calling it. The fee bumper (feebumper.cpp) now passes the old transaction’s hash directly, and CommitTransaction writes it into mapValue internally. This is preparatory refactoring for eventually removing mapValue. The functional behavior is unchanged.
Changed components
src/wallet/feebumper.cppsrc/wallet/wallet.cppsrc/wallet/wallet.hInspect captured patch +15 / −6
diff --git a/src/wallet/feebumper.cpp b/src/wallet/feebumper.cpp
index 1a402c85..57a5b42f 100644
--- a/src/wallet/feebumper.cpp
+++ b/src/wallet/feebumper.cpp
@@ -370,10 +370,7 @@ Result CommitTransaction(CWallet& wallet, const Txid& txid, CMutableTransaction&
// commit/broadcast the tx
CTransactionRef tx = MakeTransactionRef(std::move(mtx));
- mapValue_t mapValue = oldWtx.mapValue;
- mapValue["replaces_txid"] = oldWtx.GetHash().ToString();
-
- wallet.CommitTransaction(tx, std::move(mapValue), oldWtx.vOrderForm);
+ wallet.CommitTransaction(tx, oldWtx.mapValue, oldWtx.vOrderForm, oldWtx.GetHash());
// mark the original tx as bumped
bumped_txid = tx->GetHash();
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 8d502049..ef3eb4b2 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2324,7 +2324,12 @@ OutputType CWallet::TransactionChangeType(const std::optional<OutputType>& chang
return m_default_address_type;
}
-void CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm)
+void CWallet::CommitTransaction(
+ CTransactionRef tx,
+ mapValue_t mapValue,
+ std::vector<std::pair<std::string, std::string>> orderForm,
+ std::optional<Txid> replaces_txid
+)
{
LOCK(cs_wallet);
WalletLogPrintf("CommitTransaction:\n%s\n", util::RemoveSuffixView(tx->ToString(), "\n"));
@@ -2335,6 +2340,7 @@ void CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve
CHECK_NONFATAL(wtx.mapValue.empty());
CHECK_NONFATAL(wtx.vOrderForm.empty());
wtx.mapValue = std::move(mapValue);
+ if (replaces_txid) wtx.mapValue["replaces_txid"] = replaces_txid->ToString();
wtx.vOrderForm = std::move(orderForm);
return true;
});
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 47701d7e..9a0fc4b3 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -692,8 +692,14 @@ public:
* @param[in] tx The transaction to be broadcast.
* @param[in] mapValue key-values to be set on the transaction.
* @param[in] orderForm BIP 70 / BIP 21 order form details to be set on the transaction.
+ * @param[in] replaces_txid The txid of the transaction that this transaction replaces
*/
- void CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm);
+ void CommitTransaction(
+ CTransactionRef tx,
+ mapValue_t mapValue,
+ std::vector<std::pair<std::string, std::string>> orderForm,
+ std::optional<Txid> replaces_txid = std::nullopt
+ );
/** Pass this transaction to node for optional mempool insertion and relay to peers. */
bool SubmitTxMemoryPoolAndRelay(CWalletTx& wtx, std::string& err_string, node::TxBroadcast broadcast_method) const
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.