Skip to content

Commit 6c156e4

Browse files
author
MarcoFalke
committed
Merge #18842: wallet: Mark replaced tx to not be in the mempool anymore
fa4e088 wallet: Mark replaced tx to not be in the mempool anymore (MarcoFalke) Pull request description: The wallet does not mark the replaced tx as out-of-mempool. This causes failures in user scripts, because later RPCs may depend on this state change from `bumpfee`. For example, the following might fail on current master: ``` txid = sendtoaddress(...) bumpfee(txid) abandontransaction(txid) # fails because txid is still marked as "in mempool" ``` Fixes #18831 ACKs for top commit: meshcollider: utACK fa4e088 ryanofsky: Code review ACK fa4e088, and previous ACK faeedff5c87091fd83d2fb2b29eb49c948363f29 is also still valid in case there's a preference for the original fix Tree-SHA512: 9858f40f5fb5a43a7b584b5c4268b6befa82e6a84583be5206fe721bcb6c255e8d35479d347d0b9aed72703df49887c02b14ab680e8efdd28b90dd6b93d9439a
2 parents a8b0892 + fa4e088 commit 6c156e4

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/interfaces/chain.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ class Chain
159159
//! Check if transaction is RBF opt in.
160160
virtual RBFTransactionState isRBFOptIn(const CTransaction& tx) = 0;
161161

162+
//! Check if transaction is in mempool.
163+
virtual bool isInMempool(const uint256& txid) = 0;
164+
162165
//! Check if transaction has descendants in mempool.
163166
virtual bool hasDescendantsInMempool(const uint256& txid) = 0;
164167

src/node/interfaces.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,12 @@ class ChainImpl : public Chain
526526
LOCK(m_node.mempool->cs);
527527
return IsRBFOptIn(tx, *m_node.mempool);
528528
}
529+
bool isInMempool(const uint256& txid) override
530+
{
531+
if (!m_node.mempool) return false;
532+
LOCK(m_node.mempool->cs);
533+
return m_node.mempool->exists(txid);
534+
}
529535
bool hasDescendantsInMempool(const uint256& txid) override
530536
{
531537
if (!m_node.mempool) return false;

src/wallet/wallet.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,12 @@ bool CWallet::MarkReplaced(const uint256& originalHash, const uint256& newHash)
791791

792792
wtx.mapValue["replaced_by_txid"] = newHash.ToString();
793793

794+
// Refresh mempool status without waiting for transactionRemovedFromMempool
795+
// notification so the wallet is in an internally consistent state and
796+
// immediately knows the old transaction should not be considered trusted
797+
// and is eligible to be abandoned
798+
wtx.fInMempool = chain().isInMempool(originalHash);
799+
794800
WalletBatch batch(GetDatabase());
795801

796802
bool success = true;

0 commit comments

Comments
 (0)