mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
rpc: exposing modified_fee in getprioritisedtransactions
Instead of having modified_fee be hidden we are now exposing it to avoid having useless code
This commit is contained in:
parent
252a86729a
commit
cfdbcd19b3
3 changed files with 14 additions and 9 deletions
|
@ -492,6 +492,7 @@ static RPCHelpMan getprioritisedtransactions()
|
|||
{RPCResult::Type::OBJ, "<transactionid>", "", {
|
||||
{RPCResult::Type::NUM, "fee_delta", "transaction fee delta in satoshis"},
|
||||
{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"},
|
||||
}}
|
||||
},
|
||||
},
|
||||
|
@ -508,6 +509,9 @@ static RPCHelpMan getprioritisedtransactions()
|
|||
UniValue result_inner{UniValue::VOBJ};
|
||||
result_inner.pushKV("fee_delta", delta_info.delta);
|
||||
result_inner.pushKV("in_mempool", delta_info.in_mempool);
|
||||
if (delta_info.in_mempool) {
|
||||
result_inner.pushKV("modified_fee", *delta_info.modified_fee);
|
||||
}
|
||||
rpc_result.pushKV(delta_info.txid.GetHex(), result_inner);
|
||||
}
|
||||
return rpc_result;
|
||||
|
|
|
@ -36,13 +36,14 @@ class MempoolExpiryTest(BitcoinTestFramework):
|
|||
node = self.nodes[0]
|
||||
|
||||
# Send a parent transaction that will expire.
|
||||
parent_txid = self.wallet.send_self_transfer(from_node=node)['txid']
|
||||
parent = self.wallet.send_self_transfer(from_node=node)
|
||||
parent_txid = parent["txid"]
|
||||
parent_utxo = self.wallet.get_utxo(txid=parent_txid)
|
||||
independent_utxo = self.wallet.get_utxo()
|
||||
|
||||
# Add prioritisation to this transaction to check that it persists after the expiry
|
||||
node.prioritisetransaction(parent_txid, 0, COIN)
|
||||
assert_equal(node.getprioritisedtransactions()[parent_txid], { "fee_delta" : COIN, "in_mempool" : True})
|
||||
assert_equal(node.getprioritisedtransactions()[parent_txid], { "fee_delta" : COIN, "in_mempool" : True, "modified_fee": COIN + COIN * parent["fee"] })
|
||||
|
||||
# Ensure the transactions we send to trigger the mempool check spend utxos that are independent of
|
||||
# the transactions being tested for expiration.
|
||||
|
|
|
@ -45,7 +45,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
|||
self.nodes[0].prioritisetransaction(tx_replacee["txid"], 0, 100)
|
||||
assert_equal(self.nodes[0].getprioritisedtransactions(), { tx_replacee["txid"] : { "fee_delta" : 100, "in_mempool" : False}})
|
||||
self.nodes[0].sendrawtransaction(tx_replacee["hex"])
|
||||
assert_equal(self.nodes[0].getprioritisedtransactions(), { tx_replacee["txid"] : { "fee_delta" : 100, "in_mempool" : True}})
|
||||
assert_equal(self.nodes[0].getprioritisedtransactions(), { tx_replacee["txid"] : { "fee_delta" : 100, "in_mempool" : True, "modified_fee": int(tx_replacee["fee"] * COIN + 100)}})
|
||||
self.nodes[0].sendrawtransaction(tx_replacement["hex"])
|
||||
assert tx_replacee["txid"] not in self.nodes[0].getrawmempool()
|
||||
assert_equal(self.nodes[0].getprioritisedtransactions(), { tx_replacee["txid"] : { "fee_delta" : 100, "in_mempool" : False}})
|
||||
|
@ -53,7 +53,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
|||
# PrioritiseTransaction is additive
|
||||
self.nodes[0].prioritisetransaction(tx_replacee["txid"], 0, COIN)
|
||||
self.nodes[0].sendrawtransaction(tx_replacee["hex"])
|
||||
assert_equal(self.nodes[0].getprioritisedtransactions(), { tx_replacee["txid"] : { "fee_delta" : COIN + 100, "in_mempool" : True}})
|
||||
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)}})
|
||||
self.generate(self.nodes[0], 1)
|
||||
assert_equal(self.nodes[0].getprioritisedtransactions(), {})
|
||||
|
||||
|
@ -111,7 +111,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
|||
raw_after = self.nodes[0].getrawmempool(verbose=True)
|
||||
assert_equal(raw_before[txid_a], raw_after[txid_a])
|
||||
assert_equal(raw_before, raw_after)
|
||||
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}})
|
||||
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"])}})
|
||||
# Clear prioritisation, otherwise the transactions' fee deltas are persisted to mempool.dat and loaded again when the node
|
||||
# is restarted at the end of this subtest. Deltas are removed when a transaction is mined, but only at that time. We do
|
||||
# not check whether mapDeltas transactions were mined when loading from mempool.dat.
|
||||
|
@ -130,7 +130,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
|||
raw_after = self.nodes[0].getrawmempool(verbose=True)
|
||||
assert_equal(raw_before[txid_a], raw_after[txid_a])
|
||||
assert_equal(raw_before, raw_after)
|
||||
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}})
|
||||
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"])}})
|
||||
|
||||
# Clear mempool
|
||||
self.generate(self.nodes[0], 1)
|
||||
|
@ -211,7 +211,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
|||
# add a fee delta to something in the cheapest bucket and make sure it gets mined
|
||||
# also check that a different entry in the cheapest bucket is NOT mined
|
||||
self.nodes[0].prioritisetransaction(txid=txids[0][0], fee_delta=int(3*base_fee*COIN))
|
||||
assert_equal(self.nodes[0].getprioritisedtransactions(), {txids[0][0] : { "fee_delta" : 3*base_fee*COIN, "in_mempool" : True}})
|
||||
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)}})
|
||||
|
||||
# Priority disappears when prioritisetransaction is called with an inverse value...
|
||||
self.nodes[0].prioritisetransaction(txid=txids[0][0], fee_delta=int(-3*base_fee*COIN))
|
||||
|
@ -258,7 +258,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
|||
mempool = self.nodes[0].getrawmempool()
|
||||
self.log.info("Assert that de-prioritised transaction is still in mempool")
|
||||
assert high_fee_tx in mempool
|
||||
assert_equal(self.nodes[0].getprioritisedtransactions()[high_fee_tx], { "fee_delta" : -2*base_fee*COIN, "in_mempool" : True})
|
||||
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)})
|
||||
for x in txids[2]:
|
||||
if (x != high_fee_tx):
|
||||
assert x not in mempool
|
||||
|
@ -281,7 +281,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
|||
self.log.info("Assert that prioritised free transaction is accepted to mempool")
|
||||
assert_equal(self.nodes[0].sendrawtransaction(tx_hex), tx_id)
|
||||
assert tx_id in self.nodes[0].getrawmempool()
|
||||
assert_equal(self.nodes[0].getprioritisedtransactions()[tx_id], { "fee_delta" : self.relayfee*COIN, "in_mempool" : True})
|
||||
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"])})
|
||||
|
||||
# Test that calling prioritisetransaction is sufficient to trigger
|
||||
# getblocktemplate to (eventually) return a new block.
|
||||
|
|
Loading…
Add table
Reference in a new issue