wallet: Mark replaced tx to not be in the mempool anymore

pull/826/head
MarcoFalke 5 years ago
parent ed25cb58f6
commit fa4e088cba
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

@ -159,6 +159,9 @@ public:
//! Check if transaction is RBF opt in. //! Check if transaction is RBF opt in.
virtual RBFTransactionState isRBFOptIn(const CTransaction& tx) = 0; 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. //! Check if transaction has descendants in mempool.
virtual bool hasDescendantsInMempool(const uint256& txid) = 0; virtual bool hasDescendantsInMempool(const uint256& txid) = 0;

@ -526,6 +526,12 @@ public:
LOCK(m_node.mempool->cs); LOCK(m_node.mempool->cs);
return IsRBFOptIn(tx, *m_node.mempool); 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 bool hasDescendantsInMempool(const uint256& txid) override
{ {
if (!m_node.mempool) return false; if (!m_node.mempool) return false;

@ -791,6 +791,12 @@ bool CWallet::MarkReplaced(const uint256& originalHash, const uint256& newHash)
wtx.mapValue["replaced_by_txid"] = newHash.ToString(); 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()); WalletBatch batch(GetDatabase());
bool success = true; bool success = true;

Loading…
Cancel
Save