2 # Copyright (c) 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.
9 - getaddressesbyaccount
11 - sendfrom (with account arguments)
12 - move (with account arguments)
15 from test_framework
.test_framework
import BitcoinTestFramework
16 from test_framework
.util
import (
21 class WalletAccountsTest(BitcoinTestFramework
):
25 self
.setup_clean_chain
= True
27 self
.extra_args
= [[]]
31 # Check that there's no UTXO on any of the nodes
32 assert_equal(len(node
.listunspent()), 0)
36 assert_equal(node
.getbalance(), 50)
38 accounts
= ["a","b","c","d","e"]
40 account_addresses
= dict()
41 for account
in accounts
:
42 address
= node
.getaccountaddress(account
)
43 account_addresses
[account
] = address
45 node
.getnewaddress(account
)
46 assert_equal(node
.getaccount(address
), account
)
47 assert(address
in node
.getaddressesbyaccount(account
))
49 node
.sendfrom("", address
, amount_to_send
)
53 for i
in range(len(accounts
)):
54 from_account
= accounts
[i
]
55 to_account
= accounts
[(i
+1)%len(accounts
)]
56 to_address
= account_addresses
[to_account
]
57 node
.sendfrom(from_account
, to_address
, amount_to_send
)
61 for account
in accounts
:
62 address
= node
.getaccountaddress(account
)
63 assert(address
!= account_addresses
[account
])
64 assert_equal(node
.getreceivedbyaccount(account
), 2)
65 node
.move(account
, "", node
.getbalance(account
))
69 expected_account_balances
= {"": 5200}
70 for account
in accounts
:
71 expected_account_balances
[account
] = 0
73 assert_equal(node
.listaccounts(), expected_account_balances
)
75 assert_equal(node
.getbalance(""), 5200)
77 for account
in accounts
:
78 address
= node
.getaccountaddress("")
79 node
.setaccount(address
, account
)
80 assert(address
in node
.getaddressesbyaccount(account
))
81 assert(address
not in node
.getaddressesbyaccount(""))
83 for account
in accounts
:
86 addresses
.append(node
.getnewaddress())
87 multisig_address
= node
.addmultisigaddress(5, addresses
, account
)
88 node
.sendfrom("", multisig_address
, 50)
92 for account
in accounts
:
93 assert_equal(node
.getbalance(account
), 50)
95 if __name__
== '__main__':
96 WalletAccountsTest().main ()