Skip to content

Commit 5c1cd78

Browse files
committed
doc: improve rawtransaction code/test docs
1 parent acc14c5 commit 5c1cd78

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
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/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.99990000") } # 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')

0 commit comments

Comments
 (0)