MCPcopy Create free account
hub / github.com/ElementsProject/elements / test_change_script_match

Function test_change_script_match

test/functional/wallet_bumpfee.py:565–583  ·  view source on GitHub ↗
(self, rbf_node, dest_address)

Source from the content-addressed store, hash-verified

563
564
565def test_change_script_match(self, rbf_node, dest_address):
566 self.log.info('Test that the same change addresses is used for the replacement transaction when possible')
567
568 def get_change_address(tx):
569 tx_details = rbf_node.getrawtransaction(tx, 1)
570 txout_addresses = [txout['scriptPubKey']['address'] for txout in tx_details["vout"] if txout['scriptPubKey']['type'] != 'fee']
571 return [address for address in txout_addresses if rbf_node.getaddressinfo(address)["ischange"]]
572
573 # Check that there is only one change output
574 rbfid = spend_one_input(rbf_node, dest_address)
575 change_addresses = get_change_address(rbfid)
576 assert_equal(len(change_addresses), 1)
577
578 # Now find that address in each subsequent tx, and no other change
579 bumped_total_tx = rbf_node.bumpfee(rbfid, {"fee_rate": ECONOMICAL})
580 assert_equal(change_addresses, get_change_address(bumped_total_tx['txid']))
581 bumped_rate_tx = rbf_node.bumpfee(bumped_total_tx["txid"])
582 assert_equal(change_addresses, get_change_address(bumped_rate_tx['txid']))
583 self.clear_mempool()
584
585
586def spend_one_input(node, dest_address, change_size=Decimal("0.00049000")):

Callers 1

run_testMethod · 0.85

Calls 5

assert_equalFunction · 0.90
get_change_addressFunction · 0.85
infoMethod · 0.80
clear_mempoolMethod · 0.80
spend_one_inputFunction · 0.70

Tested by

no test coverage detected