Skip to content

Commit 980deaf

Browse files
committed
Merge #10252: RPC/Mining: Restore API compatibility for prioritisetransaction
870824e RPC/Mining: Restore API compatibility for prioritisetransaction (Luke Dashjr) Tree-SHA512: eb507500dc5ba8d17521f34f3d6eae45aa9259c38d15a75dc3e3ad45774ffb53db943be1720a97e6cd5f08e7832801e27ffb636da081a58955018b6f8f9d8fba
2 parents 30853e1 + 870824e commit 980deaf

File tree

6 files changed

+26
-20
lines changed

6 files changed

+26
-20
lines changed

src/rpc/client.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ static const CRPCConvertParam vRPCConvertParams[] =
112112
{ "estimaterawfee", 0, "nblocks" },
113113
{ "estimaterawfee", 1, "threshold" },
114114
{ "estimaterawfee", 2, "horizon" },
115-
{ "prioritisetransaction", 1, "fee_delta" },
115+
{ "prioritisetransaction", 1, "priority_delta" },
116+
{ "prioritisetransaction", 2, "fee_delta" },
116117
{ "setban", 2, "bantime" },
117118
{ "setban", 3, "absolute" },
118119
{ "setnetworkactive", 0, "state" },

src/rpc/mining.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,26 +257,31 @@ UniValue getmininginfo(const JSONRPCRequest& request)
257257
// NOTE: Unlike wallet RPC (which use BTC values), mining RPCs follow GBT (BIP 22) in using satoshi amounts
258258
UniValue prioritisetransaction(const JSONRPCRequest& request)
259259
{
260-
if (request.fHelp || request.params.size() != 2)
260+
if (request.fHelp || request.params.size() != 3)
261261
throw std::runtime_error(
262-
"prioritisetransaction <txid> <fee delta>\n"
262+
"prioritisetransaction <txid> <priority delta> <fee delta>\n"
263263
"Accepts the transaction into mined blocks at a higher (or lower) priority\n"
264264
"\nArguments:\n"
265265
"1. \"txid\" (string, required) The transaction id.\n"
266-
"2. fee_delta (numeric, required) The fee value (in satoshis) to add (or subtract, if negative).\n"
266+
"2. priority_delta (numeric, optional) Fee-independent priority adjustment. Not supported, so must be zero or null.\n"
267+
"3. fee_delta (numeric, required) The fee value (in satoshis) to add (or subtract, if negative).\n"
267268
" The fee is not actually paid, only the algorithm for selecting transactions into a block\n"
268269
" considers the transaction as it would have paid a higher (or lower) fee.\n"
269270
"\nResult:\n"
270271
"true (boolean) Returns true\n"
271272
"\nExamples:\n"
272-
+ HelpExampleCli("prioritisetransaction", "\"txid\" 10000")
273-
+ HelpExampleRpc("prioritisetransaction", "\"txid\", 10000")
273+
+ HelpExampleCli("prioritisetransaction", "\"txid\" 0.0 10000")
274+
+ HelpExampleRpc("prioritisetransaction", "\"txid\", 0.0, 10000")
274275
);
275276

276277
LOCK(cs_main);
277278

278279
uint256 hash = ParseHashStr(request.params[0].get_str(), "txid");
279-
CAmount nAmount = request.params[1].get_int64();
280+
CAmount nAmount = request.params[2].get_int64();
281+
282+
if (!(request.params[1].isNull() || request.params[1].get_real() == 0)) {
283+
throw JSONRPCError(RPC_INVALID_PARAMETER, "Priority is not supported, and adjustment thereof must be zero.");
284+
}
280285

281286
mempool.PrioritiseTransaction(hash, nAmount);
282287
return true;
@@ -959,7 +964,7 @@ static const CRPCCommand commands[] =
959964
// --------------------- ------------------------ ----------------------- ----------
960965
{ "mining", "getnetworkhashps", &getnetworkhashps, true, {"nblocks","height"} },
961966
{ "mining", "getmininginfo", &getmininginfo, true, {} },
962-
{ "mining", "prioritisetransaction", &prioritisetransaction, true, {"txid","fee_delta"} },
967+
{ "mining", "prioritisetransaction", &prioritisetransaction, true, {"txid","priority_delta","fee_delta"} },
963968
{ "mining", "getblocktemplate", &getblocktemplate, true, {"template_request"} },
964969
{ "mining", "submitblock", &submitblock, true, {"hexdata","parameters"} },
965970

test/functional/bip68-sequence.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def test_nonzero_locks(orig_tx, node, relayfee, use_height_lock):
241241

242242
# Now mine some blocks, but make sure tx2 doesn't get mined.
243243
# Use prioritisetransaction to lower the effective feerate to 0
244-
self.nodes[0].prioritisetransaction(tx2.hash, int(-self.relayfee*COIN))
244+
self.nodes[0].prioritisetransaction(txid=tx2.hash, fee_delta=int(-self.relayfee*COIN))
245245
cur_time = int(time.time())
246246
for i in range(10):
247247
self.nodes[0].setmocktime(cur_time + 600)
@@ -254,7 +254,7 @@ def test_nonzero_locks(orig_tx, node, relayfee, use_height_lock):
254254
test_nonzero_locks(tx2, self.nodes[0], self.relayfee, use_height_lock=False)
255255

256256
# Mine tx2, and then try again
257-
self.nodes[0].prioritisetransaction(tx2.hash, int(self.relayfee*COIN))
257+
self.nodes[0].prioritisetransaction(txid=tx2.hash, fee_delta=int(self.relayfee*COIN))
258258

259259
# Advance the time on the node so that we can test timelocks
260260
self.nodes[0].setmocktime(cur_time+600)

test/functional/mempool_packages.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,19 @@ def run_test(self):
9696

9797
# Check that ancestor modified fees includes fee deltas from
9898
# prioritisetransaction
99-
self.nodes[0].prioritisetransaction(chain[0], 1000)
99+
self.nodes[0].prioritisetransaction(txid=chain[0], fee_delta=1000)
100100
mempool = self.nodes[0].getrawmempool(True)
101101
ancestor_fees = 0
102102
for x in chain:
103103
ancestor_fees += mempool[x]['fee']
104104
assert_equal(mempool[x]['ancestorfees'], ancestor_fees * COIN + 1000)
105105

106106
# Undo the prioritisetransaction for later tests
107-
self.nodes[0].prioritisetransaction(chain[0], -1000)
107+
self.nodes[0].prioritisetransaction(txid=chain[0], fee_delta=-1000)
108108

109109
# Check that descendant modified fees includes fee deltas from
110110
# prioritisetransaction
111-
self.nodes[0].prioritisetransaction(chain[-1], 1000)
111+
self.nodes[0].prioritisetransaction(txid=chain[-1], fee_delta=1000)
112112
mempool = self.nodes[0].getrawmempool(True)
113113

114114
descendant_fees = 0
@@ -126,7 +126,7 @@ def run_test(self):
126126
assert_equal(len(self.nodes[0].getrawmempool()), 0)
127127
# Prioritise a transaction that has been mined, then add it back to the
128128
# mempool by using invalidateblock.
129-
self.nodes[0].prioritisetransaction(chain[-1], 2000)
129+
self.nodes[0].prioritisetransaction(txid=chain[-1], fee_delta=2000)
130130
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
131131
# Keep node1's tip synced with node0
132132
self.nodes[1].invalidateblock(self.nodes[1].getbestblockhash())

test/functional/prioritise_transaction.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def run_test(self):
4646

4747
# add a fee delta to something in the cheapest bucket and make sure it gets mined
4848
# also check that a different entry in the cheapest bucket is NOT mined
49-
self.nodes[0].prioritisetransaction(txids[0][0], int(3*base_fee*COIN))
49+
self.nodes[0].prioritisetransaction(txid=txids[0][0], fee_delta=int(3*base_fee*COIN))
5050

5151
self.nodes[0].generate(1)
5252

@@ -65,7 +65,7 @@ def run_test(self):
6565

6666
# Add a prioritisation before a tx is in the mempool (de-prioritising a
6767
# high-fee transaction so that it's now low fee).
68-
self.nodes[0].prioritisetransaction(high_fee_tx, -int(2*base_fee*COIN))
68+
self.nodes[0].prioritisetransaction(txid=high_fee_tx, fee_delta=-int(2*base_fee*COIN))
6969

7070
# Add everything back to mempool
7171
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
@@ -109,7 +109,7 @@ def run_test(self):
109109
# This is a less than 1000-byte transaction, so just set the fee
110110
# to be the minimum for a 1000 byte transaction and check that it is
111111
# accepted.
112-
self.nodes[0].prioritisetransaction(tx_id, int(self.relayfee*COIN))
112+
self.nodes[0].prioritisetransaction(txid=tx_id, fee_delta=int(self.relayfee*COIN))
113113

114114
self.log.info("Assert that prioritised free transaction is accepted to mempool")
115115
assert_equal(self.nodes[0].sendrawtransaction(tx_hex), tx_id)
@@ -120,7 +120,7 @@ def run_test(self):
120120
mock_time = int(time.time())
121121
self.nodes[0].setmocktime(mock_time)
122122
template = self.nodes[0].getblocktemplate()
123-
self.nodes[0].prioritisetransaction(tx_id, -int(self.relayfee*COIN))
123+
self.nodes[0].prioritisetransaction(txid=tx_id, fee_delta=-int(self.relayfee*COIN))
124124
self.nodes[0].setmocktime(mock_time+10)
125125
new_template = self.nodes[0].getblocktemplate()
126126

test/functional/replace-by-fee.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ def test_prioritised_transactions(self):
482482
assert_raises_jsonrpc(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx1b_hex, True)
483483

484484
# Use prioritisetransaction to set tx1a's fee to 0.
485-
self.nodes[0].prioritisetransaction(tx1a_txid, int(-0.1*COIN))
485+
self.nodes[0].prioritisetransaction(txid=tx1a_txid, fee_delta=int(-0.1*COIN))
486486

487487
# Now tx1b should be able to replace tx1a
488488
tx1b_txid = self.nodes[0].sendrawtransaction(tx1b_hex, True)
@@ -509,7 +509,7 @@ def test_prioritised_transactions(self):
509509
assert_raises_jsonrpc(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx2b_hex, True)
510510

511511
# Now prioritise tx2b to have a higher modified fee
512-
self.nodes[0].prioritisetransaction(tx2b.hash, int(0.1*COIN))
512+
self.nodes[0].prioritisetransaction(txid=tx2b.hash, fee_delta=int(0.1*COIN))
513513

514514
# tx2b should now be accepted
515515
tx2b_txid = self.nodes[0].sendrawtransaction(tx2b_hex, True)

0 commit comments

Comments
 (0)