RPC/Mining: Include priority delta in getprioritisedtransactions result

This commit is contained in:
Luke Dashjr 2023-08-08 22:15:55 +00:00
parent 1c73e6e630
commit 13e42976e7
4 changed files with 12 additions and 1 deletions

View File

@ -511,6 +511,7 @@ static RPCHelpMan getprioritisedtransactions()
{RPCResult::Type::NUM, "fee_delta", "transaction fee delta in satoshis"}, {RPCResult::Type::NUM, "fee_delta", "transaction fee delta in satoshis"},
{RPCResult::Type::BOOL, "in_mempool", "whether this transaction is currently in mempool"}, {RPCResult::Type::BOOL, "in_mempool", "whether this transaction is currently in mempool"},
{RPCResult::Type::NUM, "modified_fee", /*optional=*/true, "modified fee in satoshis. Only returned if in_mempool=true"}, {RPCResult::Type::NUM, "modified_fee", /*optional=*/true, "modified fee in satoshis. Only returned if in_mempool=true"},
{RPCResult::Type::NUM, "priority_delta", /*optional=*/true, "transaction coin-age priority delta"},
}} }}
}, },
}, },
@ -530,6 +531,7 @@ static RPCHelpMan getprioritisedtransactions()
if (delta_info.in_mempool) { if (delta_info.in_mempool) {
result_inner.pushKV("modified_fee", *delta_info.modified_fee); result_inner.pushKV("modified_fee", *delta_info.modified_fee);
} }
result_inner.pushKV("priority_delta", delta_info.priority_delta);
rpc_result.pushKV(delta_info.txid.GetHex(), std::move(result_inner)); rpc_result.pushKV(delta_info.txid.GetHex(), std::move(result_inner));
} }
return rpc_result; return rpc_result;

View File

@ -947,7 +947,7 @@ std::vector<CTxMemPool::delta_info> CTxMemPool::GetPrioritisedTransactions() con
const bool in_mempool{iter != mapTx.end()}; const bool in_mempool{iter != mapTx.end()};
std::optional<CAmount> modified_fee; std::optional<CAmount> modified_fee;
if (in_mempool) modified_fee = iter->GetModifiedFee(); if (in_mempool) modified_fee = iter->GetModifiedFee();
result.emplace_back(delta_info{in_mempool, delta.second, modified_fee, txid}); result.emplace_back(delta_info{in_mempool, delta.second, delta.first, modified_fee, txid});
} }
return result; return result;
} }

View File

@ -511,6 +511,7 @@ public:
const bool in_mempool; const bool in_mempool;
/** The fee delta added using PrioritiseTransaction(). */ /** The fee delta added using PrioritiseTransaction(). */
const CAmount delta; const CAmount delta;
const double priority_delta;
/** The modified fee (base fee + delta) of this entry. Only present if in_mempool=true. */ /** The modified fee (base fee + delta) of this entry. Only present if in_mempool=true. */
std::optional<CAmount> modified_fee; std::optional<CAmount> modified_fee;
/** The prioritised transaction's txid. */ /** The prioritised transaction's txid. */

View File

@ -346,6 +346,14 @@ class TestNode():
assert not invalid_call assert not invalid_call
return self.__getattr__('generatetodescriptor')(*args, **kwargs) return self.__getattr__('generatetodescriptor')(*args, **kwargs)
def getprioritisedtransactions(self, *args, **kwargs):
res = self.__getattr__('getprioritisedtransactions')(*args, **kwargs)
assert not (args or kwargs)
for res_val in res.values():
if res_val['priority_delta'] == 0:
del res_val['priority_delta']
return res
def setmocktime(self, timestamp): def setmocktime(self, timestamp):
"""Wrapper for setmocktime RPC, sets self.mocktime""" """Wrapper for setmocktime RPC, sets self.mocktime"""
if timestamp == 0: if timestamp == 0: