-
Notifications
You must be signed in to change notification settings - Fork 174
/
seed_phrase_to_qr.py
44 lines (33 loc) · 1.55 KB
/
seed_phrase_to_qr.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
from seedsigner.models.encode_qr import CompactSeedQrEncoder, SeedQrEncoder
from seedsigner.models.seed import Seed
from seedsigner.models.settings_definition import SettingsConstants
"""
This is a utility for testing / dev purposes only.
"""
if __name__ == "__main__":
import qrcode
import sys
print("""
*******************************************************************************
This is a utility for testing / dev purposes ONLY.
A SeedQR for a real seed holding actual value should never be created
this way.
*******************************************************************************
""")
COMPACT = 1
STANDARD = 2
format = int(input("1. Compact SeedQR\n2. Standard SeedQR\nEnter 1 or 2: ").strip())
if format not in [COMPACT, STANDARD]:
print("Invalid option")
sys.exit(1)
seed_phrase = input("\nEnter 12- or 24-word test seed phrase: ").strip().split(" ")
if format == COMPACT:
encoder = CompactSeedQrEncoder(seed_phrase=seed_phrase, wordlist_language_code=SettingsConstants.WORDLIST_LANGUAGE__ENGLISH)
else:
encoder = SeedQrEncoder(seed_phrase=seed_phrase, wordlist_language_code=SettingsConstants.WORDLIST_LANGUAGE__ENGLISH)
qr = qrcode.QRCode( version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=5, border=3)
qr.add_data(encoder.next_part())
qr.make(fit=True)
qr.make_image(fill_color="black", back_color="white").resize((240,240)).convert('RGB').show()
seed = Seed(seed_phrase)
print(f"\nfingerprint: {seed.get_fingerprint()}\n")