diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -6,6 +6,7 @@ #define BITCOIN_INTERFACES_CHAIN_H #include +#include #include #include @@ -140,6 +141,9 @@ //! Estimate fraction of total transactions verified if blocks up to //! the specified block hash are verified. virtual double guessVerificationProgress(const BlockHash &block_hash) = 0; + + //! Check if transaction has descendants in mempool. + virtual bool hasDescendantsInMempool(const TxId &txid) = 0; }; //! Interface to let node manage chain clients (wallets, or maybe tools for diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp --- a/src/interfaces/chain.cpp +++ b/src/interfaces/chain.cpp @@ -188,6 +188,12 @@ return GuessVerificationProgress(Params().TxData(), LookupBlockIndex(block_hash)); } + bool hasDescendantsInMempool(const TxId &txid) override { + LOCK(::g_mempool.cs); + auto it_mp = ::g_mempool.mapTx.find(txid); + return it_mp != ::g_mempool.mapTx.end() && + it_mp->GetCountWithDescendants() > 1; + } }; } // namespace