5
5
import math
6
6
import os
7
7
import re
8
+ import sys
8
9
import subprocess
9
10
10
11
from itertools import islice
@@ -415,24 +416,26 @@ def update_seed_data( event, window, values ):
415
416
if 'BIP' in update_seed_data .src :
416
417
bits = 512
417
418
try :
419
+ passphrase = pwd .strip ().encode ( 'UTF-8' )
418
420
seed_data = recover_bip39 (
419
421
mnemonic = dat .strip (),
420
- passphrase = pwd . strip (). encode ( 'UTF-8' )
422
+ passphrase = passphrase ,
421
423
)
422
424
except Exception as exc :
423
- log .exception ( f"BIP-39 recovery failed w/ { dat !r} ( { pwd !r} ) : { exc } " )
425
+ log .exception ( f"BIP-39 recovery failed w/ { dat !r} w/ passphrase: { pwd !r} : { exc } " )
424
426
status = f"Invalid BIP-39 recovery mnemonic: { exc } "
425
427
elif 'SLIP' in update_seed_data .src :
426
428
bits = 128
427
429
window ['-SD-PASS-F-' ].update ( visible = values ['-SD-PASS-C-' ] )
428
430
try :
431
+ passphrase = pwd .strip ().encode ( 'UTF-8' )
429
432
seed_data = recover (
430
433
mnemonics = list ( mnemonic_continuation ( dat .strip ().split ( '\n ' ))),
431
- passphrase = pwd . strip (). encode ( 'UTF-8' )
434
+ passphrase = passphrase ,
432
435
)
433
436
bits = len ( seed_data ) * 4
434
437
except Exception as exc :
435
- log .exception ( f"SLIP-39 recovery failed w/ { dat !r} ( { pwd !r} ) : { exc } " )
438
+ log .exception ( f"SLIP-39 recovery failed w/ { dat !r} w/ passphrase: { pwd !r} : { exc } " )
436
439
status = f"Invalid SLIP-39 recovery mnemonics: { exc } "
437
440
elif 'FIX' in update_seed_data .src :
438
441
bits = int ( update_seed_data .src .split ( '-' )[2 ] )
@@ -674,7 +677,7 @@ def app(
674
677
#
675
678
# If no name(s) supplied, try to get the User's full name.
676
679
#
677
- if not names :
680
+ if not names and sys . platform == 'darwin' :
678
681
try :
679
682
scutil = subprocess .run (
680
683
[ '/usr/sbin/scutil' ],
@@ -735,7 +738,9 @@ def app(
735
738
window ['-MNEMONICS-F-' ].expand ( expand_x = True )
736
739
window ['-GROUPS-F-' ].expand ( expand_x = True )
737
740
else :
738
- window = sg .Window ( f"{ ', ' .join ( names or [ 'SLIP-39' ] )} Mnemonic Cards" , layout )
741
+ window = sg .Window (
742
+ f"{ ', ' .join ( names or [ 'SLIP-39' ] )} Mnemonic Cards" , layout , grab_anywhere = True ,
743
+ )
739
744
timeout = 0 # First time through w/ new window, refresh immediately
740
745
741
746
# Block (except for first loop) and obtain current event and input values. Until we get a
@@ -898,17 +903,24 @@ def app(
898
903
details = None
899
904
900
905
# Produce a summary of the SLIP-39 recovery groups, including any passphrase needed for
901
- # decryption, and how few/many cards will need to be collected to recover the Seed. If the
902
- # SLIP-39 passphrase has changed, force regeneration of SLIP-39. NOTE: this passphrase is
903
- # NOT Trezor-compatible; use the Trezor "hidden wallet" feature instead.
906
+ # decryption of the SLIP-39 seed, and how few/many cards will need to be collected to
907
+ # recover the Seed. If the SLIP-39 passphrase has changed, force regeneration of SLIP-39.
908
+ # NOTE: this SLIP-39 standard passphrase is NOT Trezor-compatible; use the Trezor "hidden
909
+ # wallet" feature instead.
904
910
summary_groups = ', ' .join ( f"{ n } ({ need } /{ size } )" for n ,(need ,size ) in groups_recovered .items ())
905
911
summary = f"Requires collecting { group_threshold } of { len (groups_recovered )} the Groups: { summary_groups } "
912
+
913
+ tot_cards = sum ( size for _ ,size in groups_recovered .values () )
914
+ min_req = sum ( islice ( sorted ( ( need for need ,_ in groups_recovered .values () ), reverse = False ), group_threshold ))
915
+ max_req = sum ( islice ( sorted ( ( need for need ,_ in groups_recovered .values () ), reverse = True ), group_threshold ))
916
+ summary += f" (from { min_req } -{ max_req } of { tot_cards } Mnemonic cards)"
917
+
906
918
if values ['-PASSPHRASE-C-' ]:
907
919
window ['-PASSPHRASE-F-' ].update ( visible = True )
908
920
passphrase_now = values ['-PASSPHRASE-' ].strip ()
909
921
if passphrase_now :
910
- summary += f", decrypted w/ passphrase { passphrase_now !r} "
911
- passphrase_now = passphrase .encode ( 'utf -8' )
922
+ summary += f", w/ passphrase: { passphrase_now !r} ) "
923
+ passphrase_now = passphrase_now .encode ( 'UTF -8' )
912
924
if passphrase != passphrase_now :
913
925
passphrase = passphrase_now
914
926
details = None
@@ -918,11 +930,6 @@ def app(
918
930
details = None
919
931
passphrase = b''
920
932
921
- tot_cards = sum ( size for _ ,size in groups_recovered .values () )
922
- min_req = sum ( islice ( sorted ( ( need for need ,_ in groups_recovered .values () ), reverse = False ), group_threshold ))
923
- max_req = sum ( islice ( sorted ( ( need for need ,_ in groups_recovered .values () ), reverse = True ), group_threshold ))
924
- summary += f", and { min_req } -{ max_req } of all { tot_cards } Mnemonics cards produced"
925
-
926
933
window ['-SUMMARY-' ].update ( summary )
927
934
928
935
# Re-compute the SLIP39 Seed details. For multiple names, each subsequent slip39.create
@@ -943,7 +950,7 @@ def app(
943
950
master_secret_n = compute_master_secret ( window , values , n = n )
944
951
assert n > 0 or codecs .encode ( master_secret_n , 'hex_codec' ).decode ( 'ascii' ) == master_secret , \
945
952
"Computed Seed for 1st SLIP39 Mnemonics didn't match"
946
- log .info ( f"SLIP39 for { name } from master_secret: { codecs .encode ( master_secret_n , 'hex_codec' ).decode ( 'ascii' )} " )
953
+ log .info ( f"SLIP39 for { name } from master_secret: { codecs .encode ( master_secret_n , 'hex_codec' ).decode ( 'ascii' )} (w/ passphrase: { passphrase !r } " )
947
954
details [name ] = create (
948
955
name = name ,
949
956
group_threshold = group_threshold ,
0 commit comments