Skip to content

Commit 0528026

Browse files
laanwjPastaPastaPasta
authored andcommitted
Merge #16929: test: follow-up to rpc: default maxfeerate value as BTC/kB
6659810 test: use named args for sendrawtransaction calls (Jon Atack) 5c1cd78 doc: improve rawtransaction code/test docs (Jon Atack) acc14c5 test: fix incorrect value in rpc_rawtransaction.py (Jon Atack) Pull request description: Follow-up to PR #16521. - Fix incorrect value in rpc_rawtransaction test as per https://github.com/bitcoin/bitcoin/pull/16521/files#r325842308 - Improve the code docs - Use named arguments as per https://github.com/bitcoin/bitcoin/pull/16521/files#r310715127 Happy to squash or keep only the first commit if the others are too fixup-y. ACKs for top commit: laanwj: ACK 6659810 Tree-SHA512: bf5258f23802ab3ba3defb8791097e08e63f3e2af21023f832cd270dc88d1fa04349e921d69f9f5fedac5dce5cd3c1cc46b48febbede4bc18dccb8be994565b2
1 parent 08d5428 commit 0528026

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

src/rpc/rawtransaction.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949

5050
#include <univalue.h>
5151

52-
/** High fee rate for sendrawtransaction and testmempoolaccept.
53-
* By default, transaction with a fee rate higher than this will be rejected by
54-
* the RPCs. This can be overridden with the maxfeerate argument.
52+
/** Maximum fee rate for sendrawtransaction and testmempoolaccept.
53+
* By default, a transaction with a fee rate higher than this will be rejected
54+
* by the RPCs. This can be overridden with the maxfeerate argument.
5555
*/
5656
static const CFeeRate DEFAULT_MAX_RAW_TX_FEE_RATE{COIN / 10};
5757

test/functional/rpc_rawtransaction.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -370,48 +370,50 @@ def run_test(self):
370370

371371
self.log.info('sendrawtransaction/testmempoolaccept with maxfeerate')
372372

373-
# Test a transaction with small fee
373+
# Test a transaction with a small fee.
374374
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.0)
375375
rawTx = self.nodes[0].getrawtransaction(txId, True)
376376
vout = next(o for o in rawTx['vout'] if o['value'] == Decimal('1.00000000'))
377377

378378
self.sync_all()
379379
inputs = [{ "txid" : txId, "vout" : vout['n'] }]
380-
outputs = { self.nodes[0].getnewaddress() : Decimal("0.999990000") } # 10000 sat fee
380+
# Fee 10,000 satoshis, (1 - (10000 sat * 0.00000001 BTC/sat)) = 0.9999
381+
outputs = { self.nodes[0].getnewaddress() : Decimal("0.99990000") }
381382
rawTx = self.nodes[2].createrawtransaction(inputs, outputs)
382383
rawTxSigned = self.nodes[2].signrawtransactionwithwallet(rawTx)
383384
assert_equal(rawTxSigned['complete'], True)
384-
# 10000 sat fee, ~200 b transaction, fee rate should land around 50 sat/b = 0.0005000 BTC/kB
385+
# Fee 10,000 satoshis, ~200 b transaction, fee rate should land around 50 sat/byte = 0.00500000 BTC/kB
385386
# Thus, testmempoolaccept should reject
386387
testres = self.nodes[2].testmempoolaccept([rawTxSigned['hex']], 0.00001000)[0]
387388
assert_equal(testres['allowed'], False)
388389
assert_equal(testres['reject-reason'], '256: absurdly-high-fee')
389390
# and sendrawtransaction should throw
390391
assert_raises_rpc_error(-26, "absurdly-high-fee", self.nodes[2].sendrawtransaction, rawTxSigned['hex'], 0.00001000)
391-
# And below calls should both succeed
392+
# and the following calls should both succeed
392393
testres = self.nodes[2].testmempoolaccept(rawtxs=[rawTxSigned['hex']])[0]
393394
assert_equal(testres['allowed'], True)
394395
self.nodes[2].sendrawtransaction(hexstring=rawTxSigned['hex'])
395396

396-
# Test a transaction with large fee
397+
# Test a transaction with a large fee.
397398
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.0)
398399
rawTx = self.nodes[0].getrawtransaction(txId, True)
399400
vout = next(o for o in rawTx['vout'] if o['value'] == Decimal('1.00000000'))
400401

401402
self.sync_all()
402403
inputs = [{ "txid" : txId, "vout" : vout['n'] }]
403-
outputs = { self.nodes[0].getnewaddress() : Decimal("0.98000000") } # 2000000 sat fee
404+
# Fee 2,000,000 satoshis, (1 - (2000000 sat * 0.00000001 BTC/sat)) = 0.98
405+
outputs = { self.nodes[0].getnewaddress() : Decimal("0.98000000") }
404406
rawTx = self.nodes[2].createrawtransaction(inputs, outputs)
405407
rawTxSigned = self.nodes[2].signrawtransactionwithwallet(rawTx)
406408
assert_equal(rawTxSigned['complete'], True)
407-
# 2000000 sat fee, ~100 b transaction, fee rate should land around 20000 sat/b = 0.20000000 BTC/kB
409+
# Fee 2,000,000 satoshis, ~100 b transaction, fee rate should land around 20,000 sat/byte = 0.20000000 BTC/kB
408410
# Thus, testmempoolaccept should reject
409411
testres = self.nodes[2].testmempoolaccept([rawTxSigned['hex']])[0]
410412
assert_equal(testres['allowed'], False)
411413
assert_equal(testres['reject-reason'], '256: absurdly-high-fee')
412414
# and sendrawtransaction should throw
413415
assert_raises_rpc_error(-26, "absurdly-high-fee", self.nodes[2].sendrawtransaction, rawTxSigned['hex'])
414-
# And below calls should both succeed
416+
# and the following calls should both succeed
415417
testres = self.nodes[2].testmempoolaccept(rawtxs=[rawTxSigned['hex']], maxfeerate='0.20000000')[0]
416418
assert_equal(testres['allowed'], True)
417419
self.nodes[2].sendrawtransaction(hexstring=rawTxSigned['hex'], maxfeerate='0.20000000')

test/functional/wallet_basic.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ def run_test(self):
166166
totalfee += fee_per_input
167167

168168
# Have node 1 (miner) send the transactions
169-
self.nodes[1].sendrawtransaction(txns_to_send[0]["hex"], 0)
170-
self.nodes[1].sendrawtransaction(txns_to_send[1]["hex"], 0)
169+
self.nodes[1].sendrawtransaction(hexstring=txns_to_send[0]["hex"], maxfeerate=0)
170+
self.nodes[1].sendrawtransaction(hexstring=txns_to_send[1]["hex"], maxfeerate=0)
171171

172172
# Have node1 mine a block to confirm transactions:
173173
self.nodes[1].generate(1)
@@ -426,7 +426,7 @@ def run_test(self):
426426
# Split into two chains
427427
rawtx = self.nodes[0].createrawtransaction([{"txid": singletxid, "vout": 0}], {chain_addrs[0]: node0_balance / 2 - Decimal('0.01'), chain_addrs[1]: node0_balance / 2 - Decimal('0.01')})
428428
signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx)
429-
singletxid = self.nodes[0].sendrawtransaction(signedtx["hex"], 0)
429+
singletxid = self.nodes[0].sendrawtransaction(hexstring=signedtx["hex"], maxfeerate=0)
430430
self.nodes[0].generate(1)
431431

432432
# Make a long chain of unconfirmed payments without hitting mempool limit

0 commit comments

Comments
 (0)