[CoinControl] Allow non-wallet owned change addresses
[bitcoinplatinum.git] / qa / rpc-tests / zapwallettxes.py
blob17ba53a844b4fa78a9072c20be882e95c8d3cc2c
1 #!/usr/bin/env python3
2 # Copyright (c) 2014-2016 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 from test_framework.test_framework import BitcoinTestFramework
7 from test_framework.util import *
10 class ZapWalletTXesTest (BitcoinTestFramework):
12 def __init__(self):
13 super().__init__()
14 self.setup_clean_chain = True
15 self.num_nodes = 3
17 def setup_network(self, split=False):
18 self.nodes = start_nodes(self.num_nodes, self.options.tmpdir)
19 connect_nodes_bi(self.nodes,0,1)
20 connect_nodes_bi(self.nodes,1,2)
21 connect_nodes_bi(self.nodes,0,2)
22 self.is_network_split=False
23 self.sync_all()
25 def run_test (self):
26 print("Mining blocks...")
27 self.nodes[0].generate(1)
28 self.sync_all()
29 self.nodes[1].generate(101)
30 self.sync_all()
32 assert_equal(self.nodes[0].getbalance(), 50)
34 txid0 = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)
35 txid1 = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10)
36 self.sync_all()
37 self.nodes[0].generate(1)
38 self.sync_all()
40 txid2 = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)
41 txid3 = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10)
43 tx0 = self.nodes[0].gettransaction(txid0)
44 assert_equal(tx0['txid'], txid0) #tx0 must be available (confirmed)
46 tx1 = self.nodes[0].gettransaction(txid1)
47 assert_equal(tx1['txid'], txid1) #tx1 must be available (confirmed)
49 tx2 = self.nodes[0].gettransaction(txid2)
50 assert_equal(tx2['txid'], txid2) #tx2 must be available (unconfirmed)
52 tx3 = self.nodes[0].gettransaction(txid3)
53 assert_equal(tx3['txid'], txid3) #tx3 must be available (unconfirmed)
55 #restart bitcoind
56 self.nodes[0].stop()
57 bitcoind_processes[0].wait()
58 self.nodes[0] = start_node(0,self.options.tmpdir)
60 tx3 = self.nodes[0].gettransaction(txid3)
61 assert_equal(tx3['txid'], txid3) #tx must be available (unconfirmed)
63 self.nodes[0].stop()
64 bitcoind_processes[0].wait()
66 #restart bitcoind with zapwallettxes
67 self.nodes[0] = start_node(0,self.options.tmpdir, ["-zapwallettxes=1"])
69 assert_raises(JSONRPCException, self.nodes[0].gettransaction, [txid3])
70 #there must be a expection because the unconfirmed wallettx0 must be gone by now
72 tx0 = self.nodes[0].gettransaction(txid0)
73 assert_equal(tx0['txid'], txid0) #tx0 (confirmed) must still be available because it was confirmed
76 if __name__ == '__main__':
77 ZapWalletTXesTest ().main ()