Skip to content

Commit 742cd77

Browse files
committed
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
2 parents 6393da8 + 6659810 commit 742cd77

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939

4040
#include <univalue.h>
4141

42-
/** High fee rate for sendrawtransaction and testmempoolaccept.
43-
* By default, transaction with a fee rate higher than this will be rejected by
44-
* the RPCs. This can be overridden with the maxfeerate argument.
42+
/** Maximum fee rate for sendrawtransaction and testmempoolaccept.
43+
* By default, a transaction with a fee rate higher than this will be rejected
44+
* by the RPCs. This can be overridden with the maxfeerate argument.
4545
*/
4646
static const CFeeRate DEFAULT_MAX_RAW_TX_FEE_RATE{COIN / 10};
4747

test/functional/feature_segwit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def run_test(self):
257257
tx.vin.append(CTxIn(COutPoint(int(txid2, 16), 0), b""))
258258
tx.vout.append(CTxOut(int(49.95 * COIN), CScript([OP_TRUE, OP_DROP] * 15 + [OP_TRUE]))) # Huge fee
259259
tx.calc_sha256()
260-
txid3 = self.nodes[0].sendrawtransaction(ToHex(tx), 0)
260+
txid3 = self.nodes[0].sendrawtransaction(hexstring=ToHex(tx), maxfeerate=0)
261261
assert tx.wit.is_null()
262262
assert txid3 in self.nodes[0].getrawmempool()
263263

@@ -566,7 +566,7 @@ def mine_and_test_listunspent(self, script_list, ismine):
566566
tx.vout.append(CTxOut(10000000, i))
567567
tx.rehash()
568568
signresults = self.nodes[0].signrawtransactionwithwallet(tx.serialize_without_witness().hex())['hex']
569-
txid = self.nodes[0].sendrawtransaction(signresults, 0)
569+
txid = self.nodes[0].sendrawtransaction(hexstring=signresults, maxfeerate=0)
570570
txs_mined[txid] = self.nodes[0].generate(1)[0]
571571
self.sync_blocks()
572572
watchcount = 0
@@ -618,7 +618,7 @@ def create_and_mine_tx_from_txids(self, txids, success=True):
618618
tx.vout.append(CTxOut(0, CScript()))
619619
tx.rehash()
620620
signresults = self.nodes[0].signrawtransactionwithwallet(tx.serialize_without_witness().hex())['hex']
621-
self.nodes[0].sendrawtransaction(signresults, 0)
621+
self.nodes[0].sendrawtransaction(hexstring=signresults, maxfeerate=0)
622622
self.nodes[0].generate(1)
623623
self.sync_blocks()
624624

test/functional/rpc_rawtransaction.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -438,48 +438,50 @@ def run_test(self):
438438

439439
self.log.info('sendrawtransaction/testmempoolaccept with maxfeerate')
440440

441-
# Test a transaction with small fee
441+
# Test a transaction with a small fee.
442442
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.0)
443443
rawTx = self.nodes[0].getrawtransaction(txId, True)
444444
vout = next(o for o in rawTx['vout'] if o['value'] == Decimal('1.00000000'))
445445

446446
self.sync_all()
447447
inputs = [{ "txid" : txId, "vout" : vout['n'] }]
448-
outputs = { self.nodes[0].getnewaddress() : Decimal("0.999990000") } # 10000 sat fee
448+
# Fee 10,000 satoshis, (1 - (10000 sat * 0.00000001 BTC/sat)) = 0.9999
449+
outputs = { self.nodes[0].getnewaddress() : Decimal("0.99990000") }
449450
rawTx = self.nodes[2].createrawtransaction(inputs, outputs)
450451
rawTxSigned = self.nodes[2].signrawtransactionwithwallet(rawTx)
451452
assert_equal(rawTxSigned['complete'], True)
452-
# 10000 sat fee, ~100 b transaction, fee rate should land around 100 sat/b = 0.00100000 BTC/kB
453+
# Fee 10,000 satoshis, ~100 b transaction, fee rate should land around 100 sat/byte = 0.00100000 BTC/kB
453454
# Thus, testmempoolaccept should reject
454455
testres = self.nodes[2].testmempoolaccept([rawTxSigned['hex']], 0.00001000)[0]
455456
assert_equal(testres['allowed'], False)
456457
assert_equal(testres['reject-reason'], '256: absurdly-high-fee')
457458
# and sendrawtransaction should throw
458459
assert_raises_rpc_error(-26, "absurdly-high-fee", self.nodes[2].sendrawtransaction, rawTxSigned['hex'], 0.00001000)
459-
# And below calls should both succeed
460+
# and the following calls should both succeed
460461
testres = self.nodes[2].testmempoolaccept(rawtxs=[rawTxSigned['hex']])[0]
461462
assert_equal(testres['allowed'], True)
462463
self.nodes[2].sendrawtransaction(hexstring=rawTxSigned['hex'])
463464

464-
# Test a transaction with large fee
465+
# Test a transaction with a large fee.
465466
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.0)
466467
rawTx = self.nodes[0].getrawtransaction(txId, True)
467468
vout = next(o for o in rawTx['vout'] if o['value'] == Decimal('1.00000000'))
468469

469470
self.sync_all()
470471
inputs = [{ "txid" : txId, "vout" : vout['n'] }]
471-
outputs = { self.nodes[0].getnewaddress() : Decimal("0.98000000") } # 2000000 sat fee
472+
# Fee 2,000,000 satoshis, (1 - (2000000 sat * 0.00000001 BTC/sat)) = 0.98
473+
outputs = { self.nodes[0].getnewaddress() : Decimal("0.98000000") }
472474
rawTx = self.nodes[2].createrawtransaction(inputs, outputs)
473475
rawTxSigned = self.nodes[2].signrawtransactionwithwallet(rawTx)
474476
assert_equal(rawTxSigned['complete'], True)
475-
# 2000000 sat fee, ~100 b transaction, fee rate should land around 20000 sat/b = 0.20000000 BTC/kB
477+
# Fee 2,000,000 satoshis, ~100 b transaction, fee rate should land around 20,000 sat/byte = 0.20000000 BTC/kB
476478
# Thus, testmempoolaccept should reject
477479
testres = self.nodes[2].testmempoolaccept([rawTxSigned['hex']])[0]
478480
assert_equal(testres['allowed'], False)
479481
assert_equal(testres['reject-reason'], '256: absurdly-high-fee')
480482
# and sendrawtransaction should throw
481483
assert_raises_rpc_error(-26, "absurdly-high-fee", self.nodes[2].sendrawtransaction, rawTxSigned['hex'])
482-
# And below calls should both succeed
484+
# and the following calls should both succeed
483485
testres = self.nodes[2].testmempoolaccept(rawtxs=[rawTxSigned['hex']], maxfeerate='0.20000000')[0]
484486
assert_equal(testres['allowed'], True)
485487
self.nodes[2].sendrawtransaction(hexstring=rawTxSigned['hex'], maxfeerate='0.20000000')

test/functional/wallet_basic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ def run_test(self):
169169
txns_to_send.append(self.nodes[0].signrawtransactionwithwallet(raw_tx))
170170

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

175175
# Have node1 mine a block to confirm transactions:
176176
self.nodes[1].generate(1)
@@ -433,7 +433,7 @@ def run_test(self):
433433
# Split into two chains
434434
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')})
435435
signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx)
436-
singletxid = self.nodes[0].sendrawtransaction(signedtx["hex"], 0)
436+
singletxid = self.nodes[0].sendrawtransaction(hexstring=signedtx["hex"], maxfeerate=0)
437437
self.nodes[0].generate(1)
438438

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

0 commit comments

Comments
 (0)