aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorglozow <gloriajzhao@gmail.com>2022-09-28 14:07:56 +0100
committerglozow <gloriajzhao@gmail.com>2023-01-10 11:06:10 +0000
commit1691eaa818f7a7b22907f756490b842d80a9a21d (patch)
tree13c1c1eb75c8d1a3d432e5f35070796e0cde528c /src/rpc
parentd6c7b78ef2924af72f677ce2a7472c2447141e18 (diff)
[rpc] return effective-feerate in testmempoolaccept and submitpackage
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/mempool.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/rpc/mempool.cpp b/src/rpc/mempool.cpp
index 58e71a0604..5a8724196a 100644
--- a/src/rpc/mempool.cpp
+++ b/src/rpc/mempool.cpp
@@ -126,6 +126,7 @@ static RPCHelpMan testmempoolaccept()
{RPCResult::Type::OBJ, "fees", /*optional=*/true, "Transaction fees (only present if 'allowed' is true)",
{
{RPCResult::Type::STR_AMOUNT, "base", "transaction fee in " + CURRENCY_UNIT},
+ {RPCResult::Type::STR_AMOUNT, "effective-feerate", /*optional=*/false, "the effective feerate in " + CURRENCY_UNIT + " per KvB. May differ from the base feerate if, for example, there are modified fees from prioritisetransaction or a package feerate was used."},
}},
{RPCResult::Type::STR, "reject-reason", /*optional=*/true, "Rejection string (only present when 'allowed' is false)"},
}},
@@ -217,6 +218,7 @@ static RPCHelpMan testmempoolaccept()
result_inner.pushKV("vsize", virtual_size);
UniValue fees(UniValue::VOBJ);
fees.pushKV("base", ValueFromAmount(fee));
+ fees.pushKV("effective-feerate", ValueFromAmount(tx_result.m_effective_feerate.value().GetFeePerK()));
result_inner.pushKV("fees", fees);
}
} else {
@@ -768,6 +770,7 @@ static RPCHelpMan submitpackage()
{RPCResult::Type::NUM, "vsize", "Virtual transaction size as defined in BIP 141."},
{RPCResult::Type::OBJ, "fees", "Transaction fees", {
{RPCResult::Type::STR_AMOUNT, "base", "transaction fee in " + CURRENCY_UNIT},
+ {RPCResult::Type::STR_AMOUNT, "effective-feerate", /*optional=*/true, "if the transaction was not already in the mempool, the effective feerate in " + CURRENCY_UNIT + " per KvB. For example, the package feerate and/or feerate with modified fees from prioritisetransaction."},
}},
}}
}},
@@ -856,6 +859,7 @@ static RPCHelpMan submitpackage()
CHECK_NONFATAL(it != package_result.m_tx_results.end());
UniValue result_inner{UniValue::VOBJ};
result_inner.pushKV("txid", tx->GetHash().GetHex());
+ const auto& tx_result = it->second;
if (it->second.m_result_type == MempoolAcceptResult::ResultType::DIFFERENT_WITNESS) {
result_inner.pushKV("other-wtxid", it->second.m_other_wtxid.value().GetHex());
}
@@ -864,6 +868,12 @@ static RPCHelpMan submitpackage()
result_inner.pushKV("vsize", int64_t{it->second.m_vsize.value()});
UniValue fees(UniValue::VOBJ);
fees.pushKV("base", ValueFromAmount(it->second.m_base_fees.value()));
+ if (tx_result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
+ // Effective feerate is not provided for MEMPOOL_ENTRY transactions even
+ // though modified fees is known, because it is unknown whether package
+ // feerate was used when it was originally submitted.
+ fees.pushKV("effective-feerate", ValueFromAmount(tx_result.m_effective_feerate.value().GetFeePerK()));
+ }
result_inner.pushKV("fees", fees);
if (it->second.m_replaced_transactions.has_value()) {
for (const auto& ptx : it->second.m_replaced_transactions.value()) {