Skip to content

Commit 601bac8

Browse files
committed
[rpc] return effective-includes in testmempoolaccept and submitpackage
1 parent 1691eaa commit 601bac8

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

src/rpc/mempool.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ static RPCHelpMan testmempoolaccept()
127127
{
128128
{RPCResult::Type::STR_AMOUNT, "base", "transaction fee in " + CURRENCY_UNIT},
129129
{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."},
130+
{RPCResult::Type::ARR, "effective-includes", /*optional=*/false, "transactions whose fees and vsizes are included in effective-feerate.",
131+
{RPCResult{RPCResult::Type::STR_HEX, "", "transaction wtxid in hex"},
132+
}},
130133
}},
131134
{RPCResult::Type::STR, "reject-reason", /*optional=*/true, "Rejection string (only present when 'allowed' is false)"},
132135
}},
@@ -219,6 +222,11 @@ static RPCHelpMan testmempoolaccept()
219222
UniValue fees(UniValue::VOBJ);
220223
fees.pushKV("base", ValueFromAmount(fee));
221224
fees.pushKV("effective-feerate", ValueFromAmount(tx_result.m_effective_feerate.value().GetFeePerK()));
225+
UniValue effective_includes_res(UniValue::VARR);
226+
for (const auto& wtxid : tx_result.m_wtxids_fee_calculations.value()) {
227+
effective_includes_res.push_back(wtxid.ToString());
228+
}
229+
fees.pushKV("effective-includes", effective_includes_res);
222230
result_inner.pushKV("fees", fees);
223231
}
224232
} else {
@@ -771,6 +779,9 @@ static RPCHelpMan submitpackage()
771779
{RPCResult::Type::OBJ, "fees", "Transaction fees", {
772780
{RPCResult::Type::STR_AMOUNT, "base", "transaction fee in " + CURRENCY_UNIT},
773781
{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."},
782+
{RPCResult::Type::ARR, "effective-includes", /*optional=*/true, "if effective-feerate is provided, the wtxids of the transactions whose fees and vsizes are included in effective-feerate.",
783+
{{RPCResult::Type::STR_HEX, "", "transaction wtxid in hex"},
784+
}},
774785
}},
775786
}}
776787
}},
@@ -873,6 +884,11 @@ static RPCHelpMan submitpackage()
873884
// though modified fees is known, because it is unknown whether package
874885
// feerate was used when it was originally submitted.
875886
fees.pushKV("effective-feerate", ValueFromAmount(tx_result.m_effective_feerate.value().GetFeePerK()));
887+
UniValue effective_includes_res(UniValue::VARR);
888+
for (const auto& wtxid : tx_result.m_wtxids_fee_calculations.value()) {
889+
effective_includes_res.push_back(wtxid.ToString());
890+
}
891+
fees.pushKV("effective-includes", effective_includes_res);
876892
}
877893
result_inner.pushKV("fees", fees);
878894
if (it->second.m_replaced_transactions.has_value()) {

test/functional/mempool_accept.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def check_mempool_result(self, result_expected, *args, **kwargs):
6262
r.pop('wtxid')
6363
if "fees" in r:
6464
r["fees"].pop("effective-feerate")
65+
r["fees"].pop("effective-includes")
6566
assert_equal(result_expected, result_test)
6667
assert_equal(self.nodes[0].getmempoolinfo()['size'], self.mempool_size) # Must not change mempool state
6768

test/functional/p2p_segwit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ def test_standardness_v0(self):
624624
# in blocks and the tx is impossible to mine right now.
625625
testres3 = self.nodes[0].testmempoolaccept([tx3.serialize_with_witness().hex()])
626626
testres3[0]["fees"].pop("effective-feerate")
627+
testres3[0]["fees"].pop("effective-includes")
627628
assert_equal(testres3,
628629
[{
629630
'txid': tx3.hash,
@@ -642,6 +643,7 @@ def test_standardness_v0(self):
642643
tx3.rehash()
643644
testres3_replaced = self.nodes[0].testmempoolaccept([tx3.serialize_with_witness().hex()])
644645
testres3_replaced[0]["fees"].pop("effective-feerate")
646+
testres3_replaced[0]["fees"].pop("effective-includes")
645647
assert_equal(testres3_replaced,
646648
[{
647649
'txid': tx3.hash,

test/functional/rpc_packages.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def test_rbf(self):
247247
assert_equal(testres_replaceable["vsize"], replaceable_tx["tx"].get_vsize())
248248
assert_equal(testres_replaceable["fees"]["base"], fee)
249249
assert_fee_amount(fee, replaceable_tx["tx"].get_vsize(), testres_replaceable["fees"]["effective-feerate"])
250+
assert_equal(testres_replaceable["fees"]["effective-includes"], [replaceable_tx["wtxid"]])
250251

251252
# Replacement transaction is identical except has double the fee
252253
replacement_tx = self.wallet.create_self_transfer(utxo_to_spend=coin, sequence=MAX_BIP125_RBF_SEQUENCE, fee = 2 * fee)
@@ -315,6 +316,7 @@ def test_submit_child_with_parents(self, num_parents, partial_submit):
315316
assert_equal(tx_result["fees"]["base"], DEFAULT_FEE)
316317
if wtxid not in presubmitted_wtxids:
317318
assert_fee_amount(DEFAULT_FEE, tx.get_vsize(), tx_result["fees"]["effective-feerate"])
319+
assert_equal(tx_result["fees"]["effective-includes"], [wtxid])
318320

319321
# submitpackage result should be consistent with testmempoolaccept and getmempoolentry
320322
self.assert_equal_package_results(node, testmempoolaccept_result, submitpackage_result)
@@ -353,10 +355,13 @@ def test_submit_cpfp(self):
353355
assert_equal(child_result["fees"]["base"], DEFAULT_FEE)
354356
# The "rich" parent does not require CPFP so its effective feerate.
355357
assert_fee_amount(DEFAULT_FEE, tx_rich["tx"].get_vsize(), rich_parent_result["fees"]["effective-feerate"])
358+
assert_equal(rich_parent_result["fees"]["effective-includes"], [tx_rich["wtxid"]])
356359
# The "poor" parent and child's effective feerates are the same, composed of the child's fee
357360
# divided by their combined vsize.
358361
assert_fee_amount(DEFAULT_FEE, tx_poor["tx"].get_vsize() + tx_child["tx"].get_vsize(), poor_parent_result["fees"]["effective-feerate"])
359362
assert_fee_amount(DEFAULT_FEE, tx_poor["tx"].get_vsize() + tx_child["tx"].get_vsize(), child_result["fees"]["effective-feerate"])
363+
assert_equal([tx_poor["wtxid"], tx_child["tx"].getwtxid()], poor_parent_result["fees"]["effective-includes"])
364+
assert_equal([tx_poor["wtxid"], tx_child["tx"].getwtxid()], child_result["fees"]["effective-includes"])
360365

361366
# Package feerate is calculated for the remaining transactions after deduplication and
362367
# individual submission. Since this package had a 0-fee parent, package feerate must have

0 commit comments

Comments
 (0)