diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-03-09 07:54:13 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-03-09 07:54:18 +0100 |
commit | 6c156e49cb7a8ee76780b3dae6e0a53899ffc5e9 (patch) | |
tree | 8651303e747b4cc3f2d82cf90865d569a6c39149 | |
parent | a8b0892b743bf5b0bd7192f801fbc6144320052b (diff) | |
parent | fa4e088cbac035b8029a10b492849540150d0622 (diff) | |
download | bitcoin-6c156e49cb7a8ee76780b3dae6e0a53899ffc5e9.tar.xz |
Merge #18842: wallet: Mark replaced tx to not be in the mempool anymore
fa4e088cbac035b8029a10b492849540150d0622 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 fa4e088cbac035b8029a10b492849540150d0622
ryanofsky:
Code review ACK fa4e088cbac035b8029a10b492849540150d0622, and previous ACK faeedff5c87091fd83d2fb2b29eb49c948363f29 is also still valid in case there's a preference for the original fix
Tree-SHA512: 9858f40f5fb5a43a7b584b5c4268b6befa82e6a84583be5206fe721bcb6c255e8d35479d347d0b9aed72703df49887c02b14ab680e8efdd28b90dd6b93d9439a
-rw-r--r-- | src/interfaces/chain.h | 3 | ||||
-rw-r--r-- | src/node/interfaces.cpp | 6 | ||||
-rw-r--r-- | src/wallet/wallet.cpp | 6 |
3 files changed, 15 insertions, 0 deletions
diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index 1a49518d69..ebc5466173 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -159,6 +159,9 @@ public: //! Check if transaction is RBF opt in. virtual RBFTransactionState isRBFOptIn(const CTransaction& tx) = 0; + //! Check if transaction is in mempool. + virtual bool isInMempool(const uint256& txid) = 0; + //! Check if transaction has descendants in mempool. virtual bool hasDescendantsInMempool(const uint256& txid) = 0; diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index acd6d7847e..62ef72ef38 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -526,6 +526,12 @@ public: LOCK(m_node.mempool->cs); return IsRBFOptIn(tx, *m_node.mempool); } + bool isInMempool(const uint256& txid) override + { + if (!m_node.mempool) return false; + LOCK(m_node.mempool->cs); + return m_node.mempool->exists(txid); + } bool hasDescendantsInMempool(const uint256& txid) override { if (!m_node.mempool) return false; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 9e0befac43..58ab124061 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -791,6 +791,12 @@ bool CWallet::MarkReplaced(const uint256& originalHash, const uint256& newHash) wtx.mapValue["replaced_by_txid"] = newHash.ToString(); + // Refresh mempool status without waiting for transactionRemovedFromMempool + // notification so the wallet is in an internally consistent state and + // immediately knows the old transaction should not be considered trusted + // and is eligible to be abandoned + wtx.fInMempool = chain().isInMempool(originalHash); + WalletBatch batch(GetDatabase()); bool success = true; |