Created
December 5, 2022 18:29
-
-
Save kdmukai/92f73aa068a582524874b8dd74998619 to your computer and use it in GitHub Desktop.
Snippet: edits to wallet_basic.py to accommodate new, lower maxfeerate default
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# check if we can list zero value tx as available coins | |
# 1. create raw_tx | |
# 2. hex-changed one output to 0.0 | |
# 3. sign and send | |
# 4. check if recipient (node0) can list the zero value tx | |
usp = self.nodes[1].listunspent(query_options={'minimumAmount': '49.998'})[0] | |
inputs = [{"txid": usp['txid'], "vout": usp['vout']}] | |
test_amount = Decimal("0.00001000") # this output amount will be zeroed and thereby added to the fee | |
fee = Decimal("0.00000400") # start with a modest fee so our final fee won't exceed default maxfeerate | |
outputs = {self.nodes[1].getnewaddress(): usp['amount'] - test_amount - fee, self.nodes[0].getnewaddress(): test_amount} | |
raw_tx = self.nodes[1].createrawtransaction(inputs, outputs).replace("e8030000", "00000000") # replace test_amount with 0.0 (int32) | |
signed_raw_tx = self.nodes[1].signrawtransactionwithwallet(raw_tx) | |
decoded_raw_tx = self.nodes[1].decoderawtransaction(signed_raw_tx['hex']) | |
zero_value_txid = decoded_raw_tx['txid'] | |
self.nodes[1].sendrawtransaction(hexstring=signed_raw_tx['hex']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment