diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-05-01 17:36:17 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-03-07 12:18:15 +0100 |
commit | fa4e088cbac035b8029a10b492849540150d0622 (patch) | |
tree | d17dcac856a41aa29af39a03dcfd7588bf709722 | |
parent | ed25cb58f605ba583c735f330482df0bf9348f3a (diff) | |
download | bitcoin-fa4e088cbac035b8029a10b492849540150d0622.tar.xz |
wallet: Mark replaced tx to not be in the mempool anymore
-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 ec976fe9bf..53f13aadf4 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 08e480225d..2e742f2927 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; |