-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathwallets.py
More file actions
54 lines (46 loc) · 1.63 KB
/
wallets.py
File metadata and controls
54 lines (46 loc) · 1.63 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import json
import os
import subprocess
def create_wallets(no_of_wallets):
try:
with open("wallets.json", "r") as file:
wallets = json.load(file)
except FileNotFoundError:
wallets = []
print("No of wallets to create", no_of_wallets)
print("No of wallets in wallets.json", len(wallets))
while len(wallets) < no_of_wallets:
pay_wallet_command = """
cardano-cli address key-gen \\
--signing-key-file payment.skey \\
--verification-key-file payment.vkey
"""
subprocess.call(["bash", "-c", pay_wallet_command])
stake_wallet_command = """
cardano-cli stake-address key-gen \\
--signing-key-file stake.skey \\
--verification-key-file stake.vkey
"""
subprocess.call(["bash", "-c", stake_wallet_command])
address_command = """
cardano-cli address build \\
--payment-verification-key-file payment.vkey \\
--stake-verification-key-file stake.vkey \\
--out-file payment.addr \\
--testnet-magic 4
"""
subprocess.call(["bash", "-c", address_command])
wallet = {}
with open("payment.skey", "r") as file:
wallet["skey"] = json.load(file)
with open("payment.addr", "r") as file:
wallet["address"] = file.read()
wallets.append(wallet)
os.remove("payment.skey")
os.remove("payment.vkey")
os.remove("stake.skey")
os.remove("stake.vkey")
os.remove("payment.addr")
with open("wallets.json", "w") as file:
json.dump(wallets, file)
create_wallets(100)