4545 (3 , 5 , "Five cards, any three recover" ),
4646 (0 , 1 , "One card" ),
4747)
48- CREATE_WALLET = "Create a new wallet"
48+ CREATE_ROW = (
49+ "Create a new wallet" ,
50+ "codex32 asks Bitcoin Core for a blank wallet, with a passphrase you choose" ,
51+ )
4952HANDWRITING = (
5053 "Mark the look-alikes as you write: slash every 0, cross 7 and Z, write S like $, close the loops of 6 "
5154 "and 9, and give G an open, obvious bar. Then 5 and S, 6 and G, and 2 and Z stay apart."
@@ -338,17 +341,17 @@ def _guessed(observed: str, corrected: str) -> frozenset[int]:
338341 return frozenset (changed )
339342
340343
341- def _radio_group (group : Adw .PreferencesGroup , rows : Sequence [tuple [str , str ]]) -> list [Gtk .CheckButton ]:
342- """Build one radio row per choice. Rows carry Bitcoin Core's text, so none of it is markup."""
343- first : Gtk .CheckButton | None = None
344+ def _radio_group (
345+ group : Adw .PreferencesGroup , rows : Sequence [tuple [str , str ]], action : Gtk .Button
346+ ) -> list [Gtk .CheckButton ]:
347+ """Build one radio row per choice, none chosen; `action` waits for one. Core's text is never markup."""
348+ # A hidden leader groups even one row, so it is a radio that cannot be unticked. Handlers keep it alive.
349+ leader = Gtk .CheckButton ()
350+ action .set_sensitive (False )
344351 buttons : list [Gtk .CheckButton ] = []
345352 for label , detail in rows :
346- choice = Gtk .CheckButton ()
347- if first is None :
348- first = choice
349- choice .set_active (True )
350- else :
351- choice .set_group (first )
353+ choice = Gtk .CheckButton (group = leader )
354+ choice .connect ("toggled" , lambda _choice , _leader = leader : action .set_sensitive (True ))
352355 row = Adw .ActionRow (title = label , subtitle = detail , activatable_widget = choice , use_markup = False )
353356 row .add_prefix (choice )
354357 group .add (row )
@@ -422,16 +425,16 @@ def _network_page(
422425 then : Callable [[BitcoinCore ], Adw .NavigationPage ],
423426) -> Adw .NavigationPage :
424427 group = Adw .PreferencesGroup (title = "Bitcoin Core is running on more than one network" )
425- buttons = _radio_group (group , [(label , "" ) for label in options ])
426- content = _column (
427- _title ("Which network?" , "Practise on signet. Use mainnet only for coins you cannot replace." ),
428- group ,
429- )
430428 action = _button (
431429 "Continue" ,
432430 lambda : _connect (view , options [_selected (buttons )], then ),
433431 style = "suggested-action" ,
434432 )
433+ buttons = _radio_group (group , [(label , "" ) for label in options ], action )
434+ content = _column (
435+ _title ("Which network?" , "Practise on signet. Use mainnet only for coins you cannot replace." ),
436+ group ,
437+ )
435438 return _page ("Network" , content , actions = _actions (action ))
436439
437440
@@ -578,7 +581,8 @@ def _layout_page(view: Adw.NavigationView, core: BitcoinCore) -> Adw.NavigationP
578581 "Something else" : "Choose the numbers yourself, and the size of the seed." ,
579582 }
580583 group = Adw .PreferencesGroup ()
581- buttons = _radio_group (group , [(label , details [label ]) for label in details ])
584+ action = _button ("Continue" , lambda : begin (), style = "suggested-action" )
585+ buttons = _radio_group (group , [(label , details [label ]) for label in details ], action )
582586 custom = Adw .PreferencesGroup (title = "Your own combination" , visible = False )
583587 needed = Adw .SpinRow (
584588 title = "Cards needed to recover" ,
@@ -626,9 +630,7 @@ def begin() -> None:
626630 group ,
627631 custom ,
628632 )
629- return _page (
630- "New wallet" , content , actions = _actions (_button ("Continue" , begin , style = "suggested-action" ))
631- )
633+ return _page ("New wallet" , content , actions = _actions (action ))
632634
633635
634636def _ready_page (
@@ -798,10 +800,36 @@ def _wallet_page(
798800 restoring : bool ,
799801) -> Adw .NavigationPage :
800802 """Name the wallet that will hold the keys. The library confirms that name again."""
801- group = Adw .PreferencesGroup (title = "Empty wallets Bitcoin Core has ready" )
802- rows = [(item .name , "Empty, encrypted" if item .encrypted else "Empty, not encrypted" ) for item in found ]
803- rows .append ((CREATE_WALLET , "codex32 asks Bitcoin Core for a blank wallet, with a passphrase you choose" ))
804- buttons = _radio_group (group , rows )
803+ # Like the CLI, ask Bitcoin Core again every second, so a wallet made there appears here.
804+ holder = Gtk .Box (orientation = Gtk .Orientation .VERTICAL )
805+ action = _button ("Continue" , lambda : go (), style = "suggested-action" )
806+ buttons : list [Gtk .CheckButton ] = []
807+
808+ def show (listed : tuple [wallet_setup .Wallet , ...]) -> None :
809+ nonlocal found , buttons
810+ # A refresh keeps the operator's choice by name; None stands for the create row.
811+ kept = next ((n for n , b in zip ([w .name for w in found ] + [None ], buttons ) if b .get_active ()), False )
812+ found = listed
813+ group = Adw .PreferencesGroup (title = "Empty wallets Bitcoin Core has ready" )
814+ rows = [(w .name , "Empty, encrypted" if w .encrypted else "Empty, not encrypted" ) for w in found ]
815+ buttons = _radio_group (group , [* rows , CREATE_ROW ], action )
816+ for choice , name in zip (buttons , [item .name for item in found ] + [None ], strict = True ):
817+ choice .set_active (name == kept )
818+ if (old := holder .get_first_child ()) is not None :
819+ holder .remove (old )
820+ holder .append (group )
821+
822+ def refreshed (listed : tuple [wallet_setup .Wallet , ...] | Exception ) -> None :
823+ # A failed poll keeps the list shown; Continue reports Bitcoin Core's error if it persists.
824+ if isinstance (listed , tuple ) and listed != found :
825+ show (listed )
826+
827+ def poll () -> bool :
828+ if view .get_visible_page () is page and not work .busy ():
829+ work .run (view , page , lambda : wallet_setup .eligible (core ), refreshed )
830+ return work .showing (view , page )
831+
832+ show (found )
805833
806834 def go () -> None :
807835 # By position, so that a wallet named like the create row is still reachable.
@@ -820,10 +848,10 @@ def go() -> None:
820848 "Which wallet should hold your keys?" ,
821849 f"Bitcoin Core { wallet_setup .version_text (core )} is running on { wallet_setup .network (core )} ." ,
822850 ),
823- group ,
851+ holder ,
824852 _note (
825- "Only empty wallets are listed, so no wallet you already use can be overwritten. You may also "
826- "create one in Bitcoin Core yourself and check again ."
853+ "Only empty wallets are listed, so no wallet you already use can be overwritten. A wallet you "
854+ "create in Bitcoin Core yourself appears here ."
827855 ),
828856 * (
829857 (
@@ -837,16 +865,9 @@ def go() -> None:
837865 else ()
838866 ),
839867 )
840- return _page (
841- "Wallet" ,
842- content ,
843- actions = _actions (
844- _button (
845- "Check again" , lambda : _wallets (view , core , secret , timestamp , expected , restoring = restoring )
846- ),
847- _button ("Continue" , go , style = "suggested-action" ),
848- ),
849- )
868+ page = _page ("Wallet" , content , actions = _actions (action ))
869+ GLib .timeout_add_seconds (1 , poll )
870+ return page
850871
851872
852873def _new_wallet_page (
0 commit comments