From 2b4577d6c439b959019cb0d4fc555f87044dccb8 Mon Sep 17 00:00:00 2001 From: kdmukai Date: Sun, 28 Jan 2024 09:31:16 -0600 Subject: [PATCH 1/2] Update seed_phrase_to_qr.py --- tools/seed_phrase_to_qr.py | 39 +++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/tools/seed_phrase_to_qr.py b/tools/seed_phrase_to_qr.py index 0c818c754..397d509d7 100644 --- a/tools/seed_phrase_to_qr.py +++ b/tools/seed_phrase_to_qr.py @@ -1,19 +1,40 @@ +from seedsigner.models.encode_qr import CompactSeedQrEncoder, SeedQrEncoder +from seedsigner.models.settings_definition import SettingsConstants + +""" +This is a utility for testing / dev purposes only. +""" if __name__ == "__main__": import qrcode import sys - from embit import bip39 - print(sys.argv) - seed_phrase = sys.argv[1:] - print(seed_phrase) + 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("Enter 12- or 24-word test seed phrase: ").strip().split(" ") - data = "" - for word in seed_phrase: - index = bip39.WORDLIST.index(word) - data += str("%04d" % index) + 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(data) + 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() From 35f2e2af90450733a99b214fbe8be25ef9775831 Mon Sep 17 00:00:00 2001 From: kdmukai Date: Sun, 28 Jan 2024 10:10:45 -0600 Subject: [PATCH 2/2] add fingerprint output --- tools/seed_phrase_to_qr.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/seed_phrase_to_qr.py b/tools/seed_phrase_to_qr.py index 397d509d7..57041e9c4 100644 --- a/tools/seed_phrase_to_qr.py +++ b/tools/seed_phrase_to_qr.py @@ -1,4 +1,5 @@ from seedsigner.models.encode_qr import CompactSeedQrEncoder, SeedQrEncoder +from seedsigner.models.seed import Seed from seedsigner.models.settings_definition import SettingsConstants """ @@ -27,7 +28,7 @@ print("Invalid option") sys.exit(1) - seed_phrase = input("Enter 12- or 24-word test seed phrase: ").strip().split(" ") + 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) @@ -38,3 +39,6 @@ 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")