Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_abandonconflict.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2014-2016 The Bitcoin Core developers | # Copyright (c) 2014-2016 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test the abandontransaction RPC. | """Test the abandontransaction RPC. | ||||
The abandontransaction RPC marks a transaction and all its in-wallet | The abandontransaction RPC marks a transaction and all its in-wallet | ||||
descendants as abandoned which allows their inputs to be respent. It can be | descendants as abandoned which allows their inputs to be respent. It can be | ||||
used to replace "stuck" or evicted transactions. It only works on transactions | used to replace "stuck" or evicted transactions. It only works on transactions | ||||
which are not included in a block and are not currently in the mempool. It has | which are not included in a block and are not currently in the mempool. It has | ||||
no effect on transactions which are already abandoned. | no effect on transactions which are already abandoned. | ||||
""" | """ | ||||
from decimal import Decimal | from decimal import Decimal | ||||
from test_framework.messages import CTransaction, FromHex | |||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import ( | from test_framework.util import ( | ||||
assert_equal, | assert_equal, | ||||
assert_raises_rpc_error, | assert_raises_rpc_error, | ||||
connect_nodes, | connect_nodes, | ||||
disconnect_nodes, | disconnect_nodes, | ||||
satoshi_round, | satoshi_round, | ||||
sync_blocks, | sync_blocks, | ||||
sync_mempools, | sync_mempools, | ||||
) | ) | ||||
class AbandonConflictTest(BitcoinTestFramework): | class AbandonConflictTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 2 | self.num_nodes = 2 | ||||
self.extra_args = [["-minrelaytxfee=0.00001"], []] | self.extra_args = [["-minrelaytxfee=0.00001"], []] | ||||
def run_test(self): | def run_test(self): | ||||
def total_fees(*txids): | def total_fees(*txids): | ||||
total = 0 | total = 0 | ||||
for txid in txids: | for txid in txids: | ||||
ctx = FromHex(CTransaction(), | |||||
self.nodes[0].getrawtransaction(txid)) | |||||
total += self.nodes[0].calculate_fee_from_txid(txid) | total += self.nodes[0].calculate_fee_from_txid(txid) | ||||
return satoshi_round(total) | return satoshi_round(total) | ||||
self.nodes[1].generate(100) | self.nodes[1].generate(100) | ||||
sync_blocks(self.nodes) | sync_blocks(self.nodes) | ||||
balance = self.nodes[0].getbalance() | balance = self.nodes[0].getbalance() | ||||
txA = self.nodes[0].sendtoaddress( | txA = self.nodes[0].sendtoaddress( | ||||
self.nodes[0].getnewaddress(), Decimal("10")) | self.nodes[0].getnewaddress(), Decimal("10")) | ||||
▲ Show 20 Lines • Show All 173 Lines • Show Last 20 Lines |