Skip to content

Commit 99f8046

Browse files
committed
[rpc] add getprioritisedtransactions
This allows the user to see prioritisation for not-in-mempool transactions.
1 parent 9e9ca36 commit 99f8046

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

doc/release-notes-27501.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- A new `getprioritisedtransactions` RPC has been added. It returns a map of all fee deltas created by the
2+
user with prioritisetransaction, indexed by txid. The map also indicates whether each transaction is
3+
present in the mempool.

src/rpc/mining.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,40 @@ static RPCHelpMan prioritisetransaction()
480480
};
481481
}
482482

483+
static RPCHelpMan getprioritisedtransactions()
484+
{
485+
return RPCHelpMan{"getprioritisedtransactions",
486+
"Returns a map of all user-created (see prioritisetransaction) fee deltas by txid, and whether the tx is present in mempool.",
487+
{},
488+
RPCResult{
489+
RPCResult::Type::OBJ_DYN, "prioritisation-map", "prioritisation keyed by txid",
490+
{
491+
{RPCResult::Type::OBJ, "txid", "", {
492+
{RPCResult::Type::NUM, "fee_delta", "transaction fee delta in satoshis"},
493+
{RPCResult::Type::BOOL, "in_mempool", "whether this transaction is currently in mempool"},
494+
}}
495+
},
496+
},
497+
RPCExamples{
498+
HelpExampleCli("getprioritisedtransactions", "")
499+
+ HelpExampleRpc("getprioritisedtransactions", "")
500+
},
501+
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
502+
{
503+
NodeContext& node = EnsureAnyNodeContext(request.context);
504+
CTxMemPool& mempool = EnsureMemPool(node);
505+
UniValue rpc_result{UniValue::VOBJ};
506+
for (const auto& delta_info : mempool.GetPrioritisedTransactions()) {
507+
UniValue result_inner{UniValue::VOBJ};
508+
result_inner.pushKV("fee_delta", delta_info.delta);
509+
result_inner.pushKV("in_mempool", delta_info.in_mempool);
510+
rpc_result.pushKV(delta_info.txid.GetHex(), result_inner);
511+
}
512+
return rpc_result;
513+
},
514+
};
515+
}
516+
483517

484518
// NOTE: Assumes a conclusive result; if result is inconclusive, it must be handled by caller
485519
static UniValue BIP22ValidationResult(const BlockValidationState& state)
@@ -1048,6 +1082,7 @@ void RegisterMiningRPCCommands(CRPCTable& t)
10481082
{"mining", &getnetworkhashps},
10491083
{"mining", &getmininginfo},
10501084
{"mining", &prioritisetransaction},
1085+
{"mining", &getprioritisedtransactions},
10511086
{"mining", &getblocktemplate},
10521087
{"mining", &submitblock},
10531088
{"mining", &submitheader},

src/test/fuzz/rpc.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ const std::vector<std::string> RPC_COMMANDS_SAFE_FOR_FUZZING{
134134
"getnetworkinfo",
135135
"getnodeaddresses",
136136
"getpeerinfo",
137+
"getprioritisedtransactions",
137138
"getrawmempool",
138139
"getrawtransaction",
139140
"getrpcinfo",

0 commit comments

Comments
 (0)