@@ -91,6 +91,7 @@ class Record:
9191 wallet : str
9292 version : str
9393 fingerprint : str
94+ commitment : str
9495 account : int
9596
9697
@@ -924,11 +925,13 @@ def _record(
924925 core : BitcoinCore , secret : MasterSeed , name : str , timestamp : Timestamp , passphrase : str = ""
925926) -> Record :
926927 final = wallet_setup .fill (core , secret , name , passphrase , timestamp = timestamp )
928+ fingerprint , commitment = wallet_setup .identity (core , secret )
927929 return Record (
928930 secret .header .identifier .upper (),
929931 final ,
930932 wallet_setup .version_text (core ),
931- wallet_setup .fingerprint (core , secret ),
933+ fingerprint ,
934+ commitment ,
932935 0 ,
933936 )
934937
@@ -938,38 +941,52 @@ def _restore_identity_page(
938941 core : BitcoinCore ,
939942 secret : MasterSeed ,
940943 fingerprint : str ,
944+ commitment : str ,
941945) -> Adw .NavigationPage :
942- """Require the wallet record to match before any recovered key is imported."""
946+ """Require a separately stored strong commitment before importing recovered keys."""
947+ entered = Adw .EntryRow (title = "Recovery commitment from wallet record" )
948+ group = Adw .PreferencesGroup ()
949+ group .add (entered )
950+ status = _note ("" )
943951
944952 def continue_restore () -> None :
953+ if not wallet_setup .commitment_matches (commitment , entered .get_text ()):
954+ _say (status , "That commitment does not match this recovered wallet. Stop here." , "error" )
955+ return
956+ _empty (entered )
945957 _wallets (view , core , secret , 0 , restoring = True )
946958
947959 content = _column (
948960 _title (
949961 "Check the wallet before restoring it" ,
950- "Compare this master fingerprint with the wallet record you stored separately from the cards." ,
962+ "Type the recovery commitment from the wallet record stored separately from the cards." ,
951963 ),
952964 _rows (
953- "Recovered wallet identity" ,
965+ "Diagnostic identity" ,
954966 (
955967 ("Backup identifier" , secret .header .identifier .upper ()),
956968 ("Master fingerprint" , fingerprint ),
957969 ),
958970 ),
971+ group ,
972+ status ,
959973 _note (
960- "If the fingerprint does not match your wallet record, stop. Bitcoin Core has not been changed." ,
974+ "The expected commitment is deliberately not shown here. If your record has no recovery "
975+ "commitment, stop; do not substitute the master fingerprint. Bitcoin Core has not been changed." ,
961976 "warning" ,
962977 ),
963978 )
964- return _page (
979+ page = _page (
965980 "Verify wallet" ,
966981 content ,
967982 actions = _actions (
968983 _button ("Stop" , lambda : view .replace ([home (view )])),
969- _button ("Matches my record " , continue_restore , style = "suggested-action" ),
984+ _button ("Verify and continue " , continue_restore , style = "suggested-action" ),
970985 ),
971986 can_pop = False ,
972987 )
988+ _forget_when_gone (view , page , lambda : _empty (entered ))
989+ return page
973990
974991
975992def _verify_restore (view : Adw .NavigationView , core : BitcoinCore , secret : MasterSeed ) -> None :
@@ -978,11 +995,11 @@ def _verify_restore(view: Adw.NavigationView, core: BitcoinCore, secret: MasterS
978995 work .run (
979996 view ,
980997 page ,
981- lambda : wallet_setup .fingerprint (core , secret ),
998+ lambda : wallet_setup .identity (core , secret ),
982999 _then (
9831000 view ,
9841001 page ,
985- lambda fingerprint : _restore_identity_page (view , core , secret , fingerprint ),
1002+ lambda identity : _restore_identity_page (view , core , secret , * identity ),
9861003 CARDS_SAFE ,
9871004 ),
9881005 )
@@ -1026,6 +1043,7 @@ def _finished_page(view: Adw.NavigationView, record: Record, restoring: bool = F
10261043 ("Bitcoin Core version" , record .version ),
10271044 * dated ,
10281045 ("Master fingerprint" , record .fingerprint ),
1046+ ("Recovery commitment" , record .commitment ),
10291047 ("Derivation standards" , "BIP 44, 49, 84 and 86" ),
10301048 ("Account number" , str (record .account )),
10311049 ),
0 commit comments