99
1010from seedsigner .gui .components import FontAwesomeIconConstants , SeedSignerIconConstants
1111from seedsigner .gui .screens import (RET_CODE__BACK_BUTTON , ButtonListScreen ,
12- WarningScreen , DireWarningScreen , seed_screens )
12+ WarningScreen , DireWarningScreen , LargeIconStatusScreen , seed_screens )
1313from seedsigner .gui .screens .screen import ButtonOption
1414from seedsigner .models .encode_qr import CompactSeedQrEncoder , GenericStaticQrEncoder , SeedQrEncoder , SpecterXPubQrEncoder , StaticXpubQrEncoder , UrXpubQrEncoder
1515from seedsigner .models .qr_type import QRType
16- from seedsigner .models .seed import Seed , ShamirSeed
16+ from seedsigner .models .seed import Seed , ShamirSeed , InvalidSeedException
1717from seedsigner .models .settings import Settings , SettingsConstants
1818from seedsigner .models .settings_definition import SettingsDefinition
1919from seedsigner .models .threads import BaseThread , ThreadsafeCounter
@@ -2446,29 +2446,55 @@ def run(self):
24462446
24472447 # Add the completed share
24482448 self .controller .storage .add_pending_shamir_share ()
2449- return Destination (SeedShamirShareOptionsView )
2449+ can_finalize = self .controller .storage .can_finalize_pending_shamir_share_set ()
2450+ share_threshold = self .controller .storage .get_pending_shamir_threshold ()
2451+ share_count = self .controller .storage .pending_shamir_share_set_length
2452+ return Destination (
2453+ SeedShamirShareOptionsView ,
2454+ view_args = {
2455+ "can_finalize" : can_finalize ,
2456+ "share_threshold" : share_threshold ,
2457+ "share_count" : share_count
2458+ }
2459+ )
24502460
24512461
24522462
24532463class SeedShamirShareOptionsView (View ):
24542464 # TRANSLATOR_NOTE: These options apply to SLIP-39 Shamir shares (add another share or finalize share set).
24552465 ADD_SHARE = ButtonOption ("Add another share" )
24562466 FINALIZE = ButtonOption ("Finalize" )
2457- # TRANSLATOR_NOTE: "Shares" here means SLIP-39 Shamir secret shares.
2458- toast_error_message : str = _ ("Need more shares to reconstruct seed" )
2459-
2467+
2468+ def __init__ (self , can_finalize , share_threshold , share_count ):
2469+ super ().__init__ ()
2470+ self .can_finalize = can_finalize
2471+ self .share_threshold = share_threshold
2472+ self .share_count = share_count
2473+ self .shares_remaining = share_threshold - share_count
2474+
24602475
24612476 def run (self ):
2462- button_data = [self .ADD_SHARE , self .FINALIZE ]
2477+ button_data = []
2478+ if self .can_finalize :
2479+ button_data .append (self .FINALIZE )
2480+ else :
2481+ button_data .append (self .ADD_SHARE )
24632482
2464- share_count = self .controller .storage .pending_shamir_share_set_length
24652483 # TRANSLATOR_NOTE: "Shares" here means SLIP-39 Shamir's secret shares.
2466- title = _ ("Shares Added: {}" ).format (share_count )
2484+ title = _ ("Share Added" )
2485+ text = None
2486+ if self .share_threshold is not None and self .shares_remaining is not None :
2487+ if self .shares_remaining > 0 :
2488+ # TRANSLATOR_NOTE: Indicates how many more SLIP-39 shares must be collected.
2489+ text = _ ("Shares entered: {}\n Shares remaining: {}" ).format (self .share_count , self .shares_remaining )
2490+ else :
2491+ text = _ ("Required shares collected.\n Ready to finalize." )
24672492
24682493 selected_menu_num = self .run_screen (
2469- ButtonListScreen ,
2494+ LargeIconStatusScreen ,
24702495 title = title ,
24712496 button_data = button_data ,
2497+ text = text ,
24722498 )
24732499
24742500 if selected_menu_num == RET_CODE__BACK_BUTTON :
@@ -2478,16 +2504,19 @@ def run(self):
24782504 return Destination (SeedShamirShareMnemonicEntryView )
24792505
24802506 elif button_data [selected_menu_num ] == self .FINALIZE :
2481- # Try to finalize with current shares
2482- from seedsigner .models .seed import InvalidSeedException
24832507 try :
24842508 self .controller .storage .convert_pending_shamir_share_set_to_pending_seed (finalize = False )
2485- return Destination (SeedShamirShareFinalizeView )
24862509 except InvalidSeedException :
2487- # If seed does not reconstruct, more shares are needed
2488- from seedsigner .gui .toast import ErrorToast
2489- self .controller .activate_toast (ErrorToast (self .toast_error_message ))
2490- return Destination (SeedShamirShareOptionsView )
2510+ logger .exception ("Pending Shamir share set unexpectedly failed to reconstruct despite eligibility." )
2511+ return Destination (
2512+ SeedShamirShareOptionsView ,
2513+ view_args = {
2514+ "can_finalize" : self .can_finalize ,
2515+ "share_threshold" : self .share_threshold ,
2516+ "share_count" : self .share_count
2517+ }
2518+ )
2519+ return Destination (SeedShamirShareFinalizeView )
24912520
24922521
24932522
@@ -2523,7 +2552,17 @@ def run(self):
25232552 return Destination (MainMenuView )
25242553
25252554 else :
2526- return Destination (SeedShamirShareOptionsView )
2555+ can_finalize = self .controller .storage .can_finalize_pending_shamir_share_set ()
2556+ share_threshold = self .controller .storage .get_pending_shamir_threshold ()
2557+ share_count = self .controller .storage .pending_shamir_share_set_length
2558+ return Destination (
2559+ SeedShamirShareOptionsView ,
2560+ view_args = {
2561+ "can_finalize" : can_finalize ,
2562+ "share_threshold" : share_threshold ,
2563+ "share_count" : share_count
2564+ }
2565+ )
25272566
25282567
25292568
0 commit comments