Skip to content

Commit cfdbcd1

Browse files
committed
rpc: exposing modified_fee in getprioritisedtransactions
Instead of having modified_fee be hidden we are now exposing it to avoid having useless code
1 parent 252a867 commit cfdbcd1

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/rpc/mining.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ static RPCHelpMan getprioritisedtransactions()
492492
{RPCResult::Type::OBJ, "<transactionid>", "", {
493493
{RPCResult::Type::NUM, "fee_delta", "transaction fee delta in satoshis"},
494494
{RPCResult::Type::BOOL, "in_mempool", "whether this transaction is currently in mempool"},
495+
{RPCResult::Type::NUM, "modified_fee", /*optional=*/true, "modified fee in satoshis. Only returned if in_mempool=true"},
495496
}}
496497
},
497498
},
@@ -508,6 +509,9 @@ static RPCHelpMan getprioritisedtransactions()
508509
UniValue result_inner{UniValue::VOBJ};
509510
result_inner.pushKV("fee_delta", delta_info.delta);
510511
result_inner.pushKV("in_mempool", delta_info.in_mempool);
512+
if (delta_info.in_mempool) {
513+
result_inner.pushKV("modified_fee", *delta_info.modified_fee);
514+
}
511515
rpc_result.pushKV(delta_info.txid.GetHex(), result_inner);
512516
}
513517
return rpc_result;

test/functional/mempool_expiry.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ def test_transaction_expiry(self, timeout):
3636
node = self.nodes[0]
3737

3838
# Send a parent transaction that will expire.
39-
parent_txid = self.wallet.send_self_transfer(from_node=node)['txid']
39+
parent = self.wallet.send_self_transfer(from_node=node)
40+
parent_txid = parent["txid"]
4041
parent_utxo = self.wallet.get_utxo(txid=parent_txid)
4142
independent_utxo = self.wallet.get_utxo()
4243

4344
# Add prioritisation to this transaction to check that it persists after the expiry
4445
node.prioritisetransaction(parent_txid, 0, COIN)
45-
assert_equal(node.getprioritisedtransactions()[parent_txid], { "fee_delta" : COIN, "in_mempool" : True})
46+
assert_equal(node.getprioritisedtransactions()[parent_txid], { "fee_delta" : COIN, "in_mempool" : True, "modified_fee": COIN + COIN * parent["fee"] })
4647

4748
# Ensure the transactions we send to trigger the mempool check spend utxos that are independent of
4849
# the transactions being tested for expiration.

test/functional/mining_prioritisetransaction.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ def test_replacement(self):
4545
self.nodes[0].prioritisetransaction(tx_replacee["txid"], 0, 100)
4646
assert_equal(self.nodes[0].getprioritisedtransactions(), { tx_replacee["txid"] : { "fee_delta" : 100, "in_mempool" : False}})
4747
self.nodes[0].sendrawtransaction(tx_replacee["hex"])
48-
assert_equal(self.nodes[0].getprioritisedtransactions(), { tx_replacee["txid"] : { "fee_delta" : 100, "in_mempool" : True}})
48+
assert_equal(self.nodes[0].getprioritisedtransactions(), { tx_replacee["txid"] : { "fee_delta" : 100, "in_mempool" : True, "modified_fee": int(tx_replacee["fee"] * COIN + 100)}})
4949
self.nodes[0].sendrawtransaction(tx_replacement["hex"])
5050
assert tx_replacee["txid"] not in self.nodes[0].getrawmempool()
5151
assert_equal(self.nodes[0].getprioritisedtransactions(), { tx_replacee["txid"] : { "fee_delta" : 100, "in_mempool" : False}})
5252

5353
# PrioritiseTransaction is additive
5454
self.nodes[0].prioritisetransaction(tx_replacee["txid"], 0, COIN)
5555
self.nodes[0].sendrawtransaction(tx_replacee["hex"])
56-
assert_equal(self.nodes[0].getprioritisedtransactions(), { tx_replacee["txid"] : { "fee_delta" : COIN + 100, "in_mempool" : True}})
56+
assert_equal(self.nodes[0].getprioritisedtransactions(), { tx_replacee["txid"] : { "fee_delta" : COIN + 100, "in_mempool" : True, "modified_fee": int(tx_replacee["fee"] * COIN + COIN + 100)}})
5757
self.generate(self.nodes[0], 1)
5858
assert_equal(self.nodes[0].getprioritisedtransactions(), {})
5959

@@ -111,7 +111,7 @@ def test_diamond(self):
111111
raw_after = self.nodes[0].getrawmempool(verbose=True)
112112
assert_equal(raw_before[txid_a], raw_after[txid_a])
113113
assert_equal(raw_before, raw_after)
114-
assert_equal(self.nodes[0].getprioritisedtransactions(), {txid_b: {"fee_delta" : fee_delta_b*COIN, "in_mempool" : True}, txid_c: {"fee_delta" : (fee_delta_c_1 + fee_delta_c_2)*COIN, "in_mempool" : True}})
114+
assert_equal(self.nodes[0].getprioritisedtransactions(), {txid_b: {"fee_delta" : fee_delta_b*COIN, "in_mempool" : True, "modified_fee": int(fee_delta_b*COIN + COIN * tx_o_b["fee"])}, txid_c: {"fee_delta" : (fee_delta_c_1 + fee_delta_c_2)*COIN, "in_mempool" : True, "modified_fee": int((fee_delta_c_1 + fee_delta_c_2 ) * COIN + COIN * tx_o_c["fee"])}})
115115
# Clear prioritisation, otherwise the transactions' fee deltas are persisted to mempool.dat and loaded again when the node
116116
# is restarted at the end of this subtest. Deltas are removed when a transaction is mined, but only at that time. We do
117117
# not check whether mapDeltas transactions were mined when loading from mempool.dat.
@@ -130,7 +130,7 @@ def test_diamond(self):
130130
raw_after = self.nodes[0].getrawmempool(verbose=True)
131131
assert_equal(raw_before[txid_a], raw_after[txid_a])
132132
assert_equal(raw_before, raw_after)
133-
assert_equal(self.nodes[0].getprioritisedtransactions(), {txid_b: {"fee_delta" : fee_delta_b*COIN, "in_mempool" : True}, txid_c: {"fee_delta" : (fee_delta_c_1 + fee_delta_c_2)*COIN, "in_mempool" : True}})
133+
assert_equal(self.nodes[0].getprioritisedtransactions(), {txid_b: {"fee_delta" : fee_delta_b*COIN, "in_mempool" : True, "modified_fee": int(fee_delta_b*COIN + COIN * tx_o_b["fee"])}, txid_c: {"fee_delta" : (fee_delta_c_1 + fee_delta_c_2)*COIN, "in_mempool" : True, "modified_fee": int((fee_delta_c_1 + fee_delta_c_2 ) * COIN + COIN * tx_o_c["fee"])}})
134134

135135
# Clear mempool
136136
self.generate(self.nodes[0], 1)
@@ -211,7 +211,7 @@ def run_test(self):
211211
# add a fee delta to something in the cheapest bucket and make sure it gets mined
212212
# also check that a different entry in the cheapest bucket is NOT mined
213213
self.nodes[0].prioritisetransaction(txid=txids[0][0], fee_delta=int(3*base_fee*COIN))
214-
assert_equal(self.nodes[0].getprioritisedtransactions(), {txids[0][0] : { "fee_delta" : 3*base_fee*COIN, "in_mempool" : True}})
214+
assert_equal(self.nodes[0].getprioritisedtransactions(), {txids[0][0] : { "fee_delta" : 3*base_fee*COIN, "in_mempool" : True, "modified_fee": int(3*base_fee*COIN + COIN * 1 * base_fee)}})
215215

216216
# Priority disappears when prioritisetransaction is called with an inverse value...
217217
self.nodes[0].prioritisetransaction(txid=txids[0][0], fee_delta=int(-3*base_fee*COIN))
@@ -258,7 +258,7 @@ def run_test(self):
258258
mempool = self.nodes[0].getrawmempool()
259259
self.log.info("Assert that de-prioritised transaction is still in mempool")
260260
assert high_fee_tx in mempool
261-
assert_equal(self.nodes[0].getprioritisedtransactions()[high_fee_tx], { "fee_delta" : -2*base_fee*COIN, "in_mempool" : True})
261+
assert_equal(self.nodes[0].getprioritisedtransactions()[high_fee_tx], { "fee_delta" : -2*base_fee*COIN, "in_mempool" : True, "modified_fee": int(-2*base_fee*COIN + COIN * 3 * base_fee)})
262262
for x in txids[2]:
263263
if (x != high_fee_tx):
264264
assert x not in mempool
@@ -281,7 +281,7 @@ def run_test(self):
281281
self.log.info("Assert that prioritised free transaction is accepted to mempool")
282282
assert_equal(self.nodes[0].sendrawtransaction(tx_hex), tx_id)
283283
assert tx_id in self.nodes[0].getrawmempool()
284-
assert_equal(self.nodes[0].getprioritisedtransactions()[tx_id], { "fee_delta" : self.relayfee*COIN, "in_mempool" : True})
284+
assert_equal(self.nodes[0].getprioritisedtransactions()[tx_id], { "fee_delta" : self.relayfee*COIN, "in_mempool" : True, "modified_fee": int(self.relayfee*COIN + COIN * tx_res["fee"])})
285285

286286
# Test that calling prioritisetransaction is sufficient to trigger
287287
# getblocktemplate to (eventually) return a new block.

0 commit comments

Comments
 (0)