-
Notifications
You must be signed in to change notification settings - Fork 2
/
papergen.py
executable file
·76 lines (65 loc) · 3.19 KB
/
papergen.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python
import argparse
import sys
import pg.encryption as enc
import pg.entropy as ee
import pg.keys as keys
from pg.utils import clear
from pg.output import *
""" parsing arguments """
def parse_arguments():
global args
parser = argparse.ArgumentParser("papergen.py")
parser.add_argument("-t", "--type", help="Specify Wallet type. Choose \
'single' standalone address or 'bip39' HD(mnemonic), default single", type=str, required=False,
choices=['single', 'bip39'], default='single')
parser.add_argument("-n", "--network", help="Specify network. Choose \
mainnet or testnet, default mainnet", type=str, required=False, choices=['mainnet', 'testnet'],
default='mainnet')
parser.add_argument("-d", "--denomination", help="Specify a name for your Wallet.", type=str, required=False, default='default')
parser.add_argument("-e", "--entropy", help="Specify Entropy source. Choose \
mic or photo, default mic", type=str, required=False, choices=['mic', 'photo'], default='mic')
parser.add_argument("-w", "--write", help="Specify the recipient public key to use for \
creating an gpg encrypted file with the Wallet", type=str, required=False, default='')
args = parser.parse_args()
def main():
a = ee.Entropy(entropy_source)
clear()
working_message = "Getting data from mic.. please wait" if entropy_source == 'mic' else "Getting data from " \
"webcam.. please wait "
print(working_message)
priv = a.get_entropy()
if not priv:
print("Error: sound or video devices not working, aborted")
sys.exit()
clear()
"""Wallet: Jbok/single"""
if w_type == 'single':
jwallet = keys.Wallet(w_type, w_name, net)
jwallet.set_entropy(priv)
wallet_single = jwallet.get_jbok()
single_json=print_single(wallet_single)
mess = "QRCODES: {:12}".format("Created") if jwallet.qr_gen() else "QRCODES: {:12}".format("Error")
print(mess)
""" if a gpg recipient is specified then writing an encrypted file with Wallet and omitting writing qrcodes """
if gpg_recipient != "":
if enc.enc_data(w_name + ".asc", single_json, gpg_recipient):
print("Wrote armored gpg file %s to recipient key %s " % (w_name + ".asc", gpg_recipient))
else:
print("GPG error, check keys!")
else:
"""Wallet bip39"""
jwallet = keys.Wallet(w_type)
jwallet.set_entropy(priv)
words = jwallet.get_bip39()
bip39_json=print_bip39(words,priv)
if gpg_recipient != "":
if enc.enc_data(w_name + ".asc", bip39_json, gpg_recipient):
print("Wrote armored gpg file %s to recipient key %s " % (w_name + ".asc", gpg_recipient))
else:
print("GPG error, check keys!")
if __name__ == "__main__":
parse_arguments()
(net, w_name, w_type, entropy_source, gpg_recipient) = (
args.network, args.denomination, args.type, args.entropy, args.write)
main()