mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
[rpc] add getprioritisedtransactions
This allows the user to see prioritisation for not-in-mempool transactions.
This commit is contained in:
parent
9e9ca36c80
commit
99f8046829
3 changed files with 39 additions and 0 deletions
3
doc/release-notes-27501.md
Normal file
3
doc/release-notes-27501.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
- A new `getprioritisedtransactions` RPC has been added. It returns a map of all fee deltas created by the
|
||||
user with prioritisetransaction, indexed by txid. The map also indicates whether each transaction is
|
||||
present in the mempool.
|
|
@ -480,6 +480,40 @@ static RPCHelpMan prioritisetransaction()
|
|||
};
|
||||
}
|
||||
|
||||
static RPCHelpMan getprioritisedtransactions()
|
||||
{
|
||||
return RPCHelpMan{"getprioritisedtransactions",
|
||||
"Returns a map of all user-created (see prioritisetransaction) fee deltas by txid, and whether the tx is present in mempool.",
|
||||
{},
|
||||
RPCResult{
|
||||
RPCResult::Type::OBJ_DYN, "prioritisation-map", "prioritisation keyed by txid",
|
||||
{
|
||||
{RPCResult::Type::OBJ, "txid", "", {
|
||||
{RPCResult::Type::NUM, "fee_delta", "transaction fee delta in satoshis"},
|
||||
{RPCResult::Type::BOOL, "in_mempool", "whether this transaction is currently in mempool"},
|
||||
}}
|
||||
},
|
||||
},
|
||||
RPCExamples{
|
||||
HelpExampleCli("getprioritisedtransactions", "")
|
||||
+ HelpExampleRpc("getprioritisedtransactions", "")
|
||||
},
|
||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||
{
|
||||
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||
CTxMemPool& mempool = EnsureMemPool(node);
|
||||
UniValue rpc_result{UniValue::VOBJ};
|
||||
for (const auto& delta_info : mempool.GetPrioritisedTransactions()) {
|
||||
UniValue result_inner{UniValue::VOBJ};
|
||||
result_inner.pushKV("fee_delta", delta_info.delta);
|
||||
result_inner.pushKV("in_mempool", delta_info.in_mempool);
|
||||
rpc_result.pushKV(delta_info.txid.GetHex(), result_inner);
|
||||
}
|
||||
return rpc_result;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// NOTE: Assumes a conclusive result; if result is inconclusive, it must be handled by caller
|
||||
static UniValue BIP22ValidationResult(const BlockValidationState& state)
|
||||
|
@ -1048,6 +1082,7 @@ void RegisterMiningRPCCommands(CRPCTable& t)
|
|||
{"mining", &getnetworkhashps},
|
||||
{"mining", &getmininginfo},
|
||||
{"mining", &prioritisetransaction},
|
||||
{"mining", &getprioritisedtransactions},
|
||||
{"mining", &getblocktemplate},
|
||||
{"mining", &submitblock},
|
||||
{"mining", &submitheader},
|
||||
|
|
|
@ -134,6 +134,7 @@ const std::vector<std::string> RPC_COMMANDS_SAFE_FOR_FUZZING{
|
|||
"getnetworkinfo",
|
||||
"getnodeaddresses",
|
||||
"getpeerinfo",
|
||||
"getprioritisedtransactions",
|
||||
"getrawmempool",
|
||||
"getrawtransaction",
|
||||
"getrpcinfo",
|
||||
|
|
Loading…
Reference in a new issue