forked from emg110/demo-local-state-expansion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sandbox.py
35 lines (26 loc) · 1011 Bytes
/
sandbox.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from algosdk.kmd import KMDClient
KMD_ADDRESS = "http://localhost:4002"
KMD_TOKEN = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
KMD_WALLET_NAME = "unencrypted-default-wallet"
KMD_WALLET_PASSWORD = ""
def get_accounts():
kmd = KMDClient(KMD_TOKEN, KMD_ADDRESS)
wallets = kmd.list_wallets()
walletID = None
for wallet in wallets:
if wallet["name"] == KMD_WALLET_NAME:
walletID = wallet["id"]
break
if walletID is None:
raise Exception("Wallet not found: {}".format(KMD_WALLET_NAME))
walletHandle = kmd.init_wallet_handle(walletID, KMD_WALLET_PASSWORD)
try:
addresses = kmd.list_keys(walletHandle)
privateKeys = [
kmd.export_key(walletHandle, KMD_WALLET_PASSWORD, addr)
for addr in addresses
]
kmdAccounts = [(addresses[i], privateKeys[i]) for i in range(len(privateKeys))]
finally:
kmd.release_wallet_handle(walletHandle)
return kmdAccounts