mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
Merge #18516: test: relax bumpfee dust_to_fee txsize an extra vbyte
25e03ba1ff
test: relax bumpfee dust_to_fee txsize an extra vbyte (Jon Atack) Pull request description: Hopefully closes #18511 by allowing the transaction size to be 140-141 vbytes rather than strictly 141, and bumps with a slightly larger fee to ensure dust in the 140 vbyte case. ACKs for top commit: jnewbery: utACK25e03ba1ff
Tree-SHA512: 76a04e1ce090e48befe048ed6d412222d7f8bc951ff822850833061a0606b1bebc5289f7249737d3fb9aa26eb857f99543981037cea6babe3e578e2cfe8afcdb
This commit is contained in:
commit
425a7f900e
1 changed files with 12 additions and 6 deletions
|
@ -253,12 +253,18 @@ def test_dust_to_fee(self, rbf_node, dest_address):
|
|||
self.log.info('Test that bumped output that is dust is dropped to fee')
|
||||
rbfid = spend_one_input(rbf_node, dest_address)
|
||||
fulltx = rbf_node.getrawtransaction(rbfid, 1)
|
||||
# size of transaction (p2wpkh, 1 input, 2 outputs): 141 vbytes
|
||||
assert_equal(fulltx["vsize"], 141)
|
||||
# bump with fee_rate of 0.00350000 BTC per 1000 vbytes
|
||||
# expected bump fee of 141 vbytes * fee_rate 0.00350000 BTC / 1000 vbytes = 0.00049350 BTC
|
||||
# but dust is dropped, so actual bump fee is 0.00050000
|
||||
bumped_tx = rbf_node.bumpfee(rbfid, {"fee_rate": 0.0035})
|
||||
# The DER formatting used by Bitcoin to serialize ECDSA signatures means that signatures can have a
|
||||
# variable size of 70-72 bytes (or possibly even less), with most being 71 or 72 bytes. The signature
|
||||
# in the witness is divided by 4 for the vsize, so this variance can take the weight across a 4-byte
|
||||
# boundary. Thus expected transaction size (p2wpkh, 1 input, 2 outputs) is 140-141 vbytes, usually 141.
|
||||
if not 140 <= fulltx["vsize"] <= 141:
|
||||
print("Error: Invalid tx vsize of {} (140-141 expected), full tx: {}".format(fulltx["vsize"], fulltx))
|
||||
raise AssertionError
|
||||
# Bump with fee_rate of 0.00350250 BTC per 1000 vbytes to create dust.
|
||||
# Expected fee is 141 vbytes * fee_rate 0.00350250 BTC / 1000 vbytes = 0.00049385 BTC.
|
||||
# or occasionally 140 vbytes * fee_rate 0.00350250 BTC / 1000 vbytes = 0.00049035 BTC.
|
||||
# Dust should be dropped to the fee, so actual bump fee is 0.00050000 BTC.
|
||||
bumped_tx = rbf_node.bumpfee(rbfid, {"fee_rate": 0.00350250})
|
||||
full_bumped_tx = rbf_node.getrawtransaction(bumped_tx["txid"], 1)
|
||||
assert_equal(bumped_tx["fee"], Decimal("0.00050000"))
|
||||
assert_equal(len(fulltx["vout"]), 2)
|
||||
|
|
Loading…
Add table
Reference in a new issue