Skip to content

Commit e5ea05e

Browse files
committed
RPC/Mempool: Add "rbf_policy" to getmempoolinfo result
1 parent 9b6167f commit e5ea05e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/rpc/mempool.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,11 @@ UniValue MempoolInfoToJSON(const CTxMemPool& pool, const std::optional<MempoolHi
727727
ret.pushKV("incrementalrelayfee", ValueFromAmount(pool.m_opts.incremental_relay_feerate.GetFeePerK()));
728728
ret.pushKV("unbroadcastcount", uint64_t{pool.GetUnbroadcastTxs().size()});
729729
ret.pushKV("fullrbf", (pool.m_opts.rbf_policy == RBFPolicy::Always));
730+
switch (pool.m_opts.rbf_policy) {
731+
case RBFPolicy::Never : ret.pushKV("rbf_policy", "never"); break;
732+
case RBFPolicy::OptIn : ret.pushKV("rbf_policy", "optin"); break;
733+
case RBFPolicy::Always: ret.pushKV("rbf_policy", "always"); break;
734+
}
730735

731736
if (histogram_floors) {
732737
const MempoolHistogramFeeRates& floors{histogram_floors.value()};
@@ -810,6 +815,7 @@ static RPCHelpMan getmempoolinfo()
810815
{RPCResult::Type::NUM, "incrementalrelayfee", "minimum fee rate increment for mempool limiting or replacement in " + CURRENCY_UNIT + "/kvB"},
811816
{RPCResult::Type::NUM, "unbroadcastcount", "Current number of transactions that haven't passed initial broadcast yet"},
812817
{RPCResult::Type::BOOL, "fullrbf", "True if the mempool accepts RBF without replaceability signaling inspection"},
818+
{RPCResult::Type::STR, "rbf_policy", "Policy used for replacing conflicting transactions by fee (one of: never, optin, always)"},
813819
{RPCResult::Type::OBJ_DYN, "fee_histogram", /*optional=*/true, "",
814820
{
815821
{RPCResult::Type::OBJ, "<fee_rate_group>", "Fee rate group named by its lower bound (in " + CURRENCY_ATOM + "/vB), identical to the \"from_feerate\" field below",

test/functional/feature_rbf.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ def set_test_params(self):
5555
def run_test(self):
5656
self.wallet = MiniWallet(self.nodes[0])
5757

58+
self.log.info("Running test RPC rbf_policy")
59+
def test_rpc_rbf_policy():
60+
assert_equal(self.nodes[0].getmempoolinfo()["rbf_policy"], 'optin')
61+
assert_equal(self.nodes[1].getmempoolinfo()["rbf_policy"], 'optin')
62+
assert_equal(self.nodes[2].getmempoolinfo()["rbf_policy"], 'never')
63+
assert_equal(self.nodes[3].getmempoolinfo()["rbf_policy"], 'always')
64+
test_rpc_rbf_policy()
65+
5866
self.log.info("Running test simple doublespend...")
5967
self.test_simple_doublespend()
6068

@@ -743,6 +751,7 @@ def test_fullrbf(self):
743751
confirmed_utxo = self.make_utxo(self.nodes[0], int(2 * COIN))
744752
self.restart_node(0, extra_args=["-mempoolfullrbf=1"])
745753
assert self.nodes[0].getmempoolinfo()["fullrbf"]
754+
assert_equal(self.nodes[0].getmempoolinfo()["rbf_policy"], 'always')
746755

747756
# Create an explicitly opt-out transaction
748757
optout_tx = self.wallet.send_self_transfer(

0 commit comments

Comments
 (0)