diff --git a/test/functional/wallet_abandonconflict.py b/test/functional/wallet_abandonconflict.py --- a/test/functional/wallet_abandonconflict.py +++ b/test/functional/wallet_abandonconflict.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright (c) 2014-2016 The Bitcoin Core developers +# Copyright (c) 2014-2019 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test the abandontransaction RPC. @@ -37,9 +37,10 @@ def total_fees(*txids): total = 0 for txid in txids: - total += self.nodes[0].calculate_fee_from_txid(txid) - + # '-=' is because gettransaction(txid)['fee'] returns a negative + total -= self.nodes[0].gettransaction(txid)['fee'] return satoshi_round(total) + self.nodes[1].generate(100) sync_blocks(self.nodes) balance = self.nodes[0].getbalance() @@ -72,12 +73,12 @@ disconnect_nodes(self.nodes[0], self.nodes[1]) # Identify the 10btc outputs - nA = next(i for i, vout in enumerate(self.nodes[0].getrawtransaction( - txA, 1)["vout"]) if vout["value"] == Decimal("10")) - nB = next(i for i, vout in enumerate(self.nodes[0].getrawtransaction( - txB, 1)["vout"]) if vout["value"] == Decimal("10")) - nC = next(i for i, vout in enumerate(self.nodes[0].getrawtransaction( - txC, 1)["vout"]) if vout["value"] == Decimal("10")) + nA = next(tx_out["vout"] for tx_out in self.nodes[0].gettransaction( + txA)["details"] if tx_out["amount"] == Decimal("10")) + nB = next(tx_out["vout"] for tx_out in self.nodes[0].gettransaction( + txB)["details"] if tx_out["amount"] == Decimal("10")) + nC = next(tx_out["vout"] for tx_out in self.nodes[0].gettransaction( + txC)["details"] if tx_out["amount"] == Decimal("10")) inputs = [] # spend 10btc outputs from txA and txB @@ -92,8 +93,8 @@ txAB1 = self.nodes[0].sendrawtransaction(signed["hex"]) # Identify the 14.99998btc output - nAB = next(i for i, vout in enumerate(self.nodes[0].getrawtransaction( - txAB1, 1)["vout"]) if vout["value"] == Decimal("14.99998")) + nAB = next(tx_out["vout"] for tx_out in self.nodes[0].gettransaction( + txAB1)["details"] if tx_out["amount"] == Decimal("14.99998")) # Create a child tx spending AB1 and C inputs = [] diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright (c) 2014-2016 The Bitcoin Core developers +# Copyright (c) 2014-2019 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test the wallet.""" @@ -194,7 +194,9 @@ txid = self.nodes[2].sendtoaddress(address, 10, "", "", False) self.nodes[2].generate(1) self.sync_all([self.nodes[0:3]]) - ctx = FromHex(CTransaction(), self.nodes[2].getrawtransaction(txid)) + ctx = FromHex(CTransaction(), + self.nodes[2].gettransaction(txid)['hex']) + node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), old_balance - Decimal('10'), fee_per_byte, ctx.billable_size()) assert_equal(self.nodes[0].getbalance(), Decimal('10')) @@ -206,14 +208,15 @@ node_2_bal -= Decimal('10') assert_equal(self.nodes[2].getbalance(), node_2_bal) node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), Decimal( - '20'), fee_per_byte, count_bytes(self.nodes[2].getrawtransaction(txid))) + '20'), fee_per_byte, count_bytes(self.nodes[2].gettransaction(txid)['hex'])) # Sendmany 10 BCH txid = self.nodes[2].sendmany('', {address: 10}, 0, "", []) self.nodes[2].generate(1) self.sync_all([self.nodes[0:3]]) node_0_bal += Decimal('10') - ctx = FromHex(CTransaction(), self.nodes[2].getrawtransaction(txid)) + ctx = FromHex(CTransaction(), + self.nodes[2].gettransaction(txid)['hex']) node_2_bal = self.check_fee_amount(self.nodes[2].getbalance( ), node_2_bal - Decimal('10'), fee_per_byte, ctx.billable_size()) assert_equal(self.nodes[0].getbalance(), node_0_bal) @@ -224,7 +227,8 @@ self.sync_all([self.nodes[0:3]]) node_2_bal -= Decimal('10') assert_equal(self.nodes[2].getbalance(), node_2_bal) - ctx = FromHex(CTransaction(), self.nodes[2].getrawtransaction(txid)) + ctx = FromHex(CTransaction(), + self.nodes[2].gettransaction(txid)['hex']) node_0_bal = self.check_fee_amount(self.nodes[0].getbalance( ), node_0_bal + Decimal('10'), fee_per_byte, ctx.billable_size()) @@ -391,7 +395,7 @@ self.nodes[0].setlabel(addr, label) assert_equal(self.nodes[0].getaddressinfo( addr)['label'], label) - assert(label in self.nodes[0].listlabels()) + assert label in self.nodes[0].listlabels() # restore to default self.nodes[0].rpc.ensure_ascii = True @@ -515,7 +519,7 @@ destination = self.nodes[1].getnewaddress() txid = self.nodes[0].sendtoaddress(destination, 0.123) tx = self.nodes[0].decoderawtransaction( - self.nodes[0].getrawtransaction(txid)) + self.nodes[0].gettransaction(txid)['hex']) output_addresses = [vout['scriptPubKey']['addresses'][0] for vout in tx["vout"]] assert len(output_addresses) > 1