Skip to content

Commit 291276f

Browse files
committed
Remove use of GetCountWithDescendants in wallet code
This commit does not change behavior.
1 parent bdc6628 commit 291276f

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/interfaces/chain.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ class ChainImpl : public Chain
190190
LOCK(::mempool.cs);
191191
return IsRBFOptIn(tx, ::mempool);
192192
}
193+
bool hasDescendantsInMempool(const uint256& txid) override
194+
{
195+
LOCK(::mempool.cs);
196+
auto it_mp = ::mempool.mapTx.find(txid);
197+
return it_mp != ::mempool.mapTx.end() && it_mp->GetCountWithDescendants() > 1;
198+
}
193199
};
194200

195201
} // namespace

src/interfaces/chain.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ class Chain
135135

136136
//! Check if transaction is RBF opt in.
137137
virtual RBFTransactionState isRBFOptIn(const CTransaction& tx) = 0;
138+
139+
//! Check if transaction has descendants in mempool.
140+
virtual bool hasDescendantsInMempool(const uint256& txid) = 0;
138141
};
139142

140143
//! Interface to let node manage chain clients (wallets, or maybe tools for

src/wallet/feebumper.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ static feebumper::Result PreconditionChecks(interfaces::Chain::Lock& locked_chai
2727
}
2828

2929
{
30-
LOCK(mempool.cs);
31-
auto it_mp = mempool.mapTx.find(wtx.GetHash());
32-
if (it_mp != mempool.mapTx.end() && it_mp->GetCountWithDescendants() > 1) {
30+
if (wallet->chain().hasDescendantsInMempool(wtx.GetHash())) {
3331
errors.push_back("Transaction has descendants in the mempool");
3432
return feebumper::Result::INVALID_PARAMETER;
3533
}

0 commit comments

Comments
 (0)