@@ -850,7 +850,6 @@ def run(self):
850
850
851
851
852
852
853
-
854
853
class SeedExportXpubWarningView (View ):
855
854
def __init__ (self , seed_num : int , sig_type : str , script_type : str , coordinator : str , custom_derivation : str ):
856
855
super ().__init__ ()
@@ -1196,6 +1195,7 @@ def run(self):
1196
1195
)
1197
1196
1198
1197
1198
+
1199
1199
class SeedBIP85InvalidChildIndexView (View ):
1200
1200
def __init__ (self , seed_num : int , num_words : int ):
1201
1201
super ().__init__ ()
@@ -1419,19 +1419,21 @@ def run(self):
1419
1419
Export as SeedQR
1420
1420
****************************************************************************"""
1421
1421
class SeedTranscribeSeedQRFormatView (View ):
1422
+ # SeedQR dims for 12-word seeds
1423
+ STANDARD_12 = ButtonOption ("Standard: 25x25" , return_data = 25 )
1424
+ COMPACT_12 = ButtonOption ("Compact: 21x21" , return_data = 21 )
1425
+
1426
+ # SeedQR dims for 24-word seeds
1427
+ STANDARD_24 = ButtonOption ("Standard: 29x29" , return_data = 29 )
1428
+ COMPACT_24 = ButtonOption ("Compact: 25x25" , return_data = 25 )
1429
+
1422
1430
def __init__ (self , seed_num : int ):
1423
1431
super ().__init__ ()
1424
1432
self .seed_num = seed_num
1425
1433
1426
1434
1427
1435
def run (self ):
1428
1436
seed = self .controller .get_seed (self .seed_num )
1429
- if len (seed .mnemonic_list ) == 12 :
1430
- STANDARD = ButtonOption ("Standard: 25x25" , return_data = 25 )
1431
- COMPACT = ButtonOption ("Compact: 21x21" , return_data = 21 )
1432
- else :
1433
- STANDARD = ButtonOption ("Standard: 29x29" , return_data = 29 )
1434
- COMPACT = ButtonOption ("Compact: 25x25" , return_data = 25 )
1435
1437
1436
1438
if self .settings .get_value (SettingsConstants .SETTING__COMPACT_SEEDQR ) != SettingsConstants .OPTION__ENABLED :
1437
1439
# Only configured for standard SeedQR
@@ -1440,22 +1442,26 @@ def run(self):
1440
1442
view_args = {
1441
1443
"seed_num" : self .seed_num ,
1442
1444
"seedqr_format" : QRType .SEED__SEEDQR ,
1443
- "num_modules" : STANDARD .return_data ,
1445
+ "num_modules" : self . STANDARD_12 .return_data ,
1444
1446
},
1445
1447
skip_current_view = True ,
1446
1448
)
1447
1449
1448
- button_data = [STANDARD , COMPACT ]
1450
+ if len (seed .mnemonic_list ) == 12 :
1451
+ button_data = [self .STANDARD_12 , self .COMPACT_12 ]
1452
+ else :
1453
+ button_data = [self .STANDARD_24 , self .COMPACT_24 ]
1449
1454
1450
- selected_menu_num = seed_screens .SeedTranscribeSeedQRFormatScreen (
1455
+ selected_menu_num = self .run_screen (
1456
+ seed_screens .SeedTranscribeSeedQRFormatScreen ,
1451
1457
title = _ ("SeedQR Format" ),
1452
1458
button_data = button_data ,
1453
- ). display ()
1459
+ )
1454
1460
1455
1461
if selected_menu_num == RET_CODE__BACK_BUTTON :
1456
1462
return Destination (BackStackView )
1457
1463
1458
- if button_data [selected_menu_num ] == STANDARD :
1464
+ if button_data [selected_menu_num ] in [ self . STANDARD_12 , self . STANDARD_24 ] :
1459
1465
seedqr_format = QRType .SEED__SEEDQR
1460
1466
else :
1461
1467
seedqr_format = QRType .SEED__COMPACTSEEDQR
@@ -1496,10 +1502,11 @@ def run(self):
1496
1502
# Forward straight to transcribing the SeedQR
1497
1503
return destination
1498
1504
1499
- selected_menu_num = DireWarningScreen (
1505
+ selected_menu_num = self .run_screen (
1506
+ DireWarningScreen ,
1500
1507
status_headline = _ ("SeedQR is your private key!" ),
1501
1508
text = _ ("Never photograph or scan it into a device that connects to the internet." ),
1502
- ). display ()
1509
+ )
1503
1510
1504
1511
if selected_menu_num == RET_CODE__BACK_BUTTON :
1505
1512
return Destination (BackStackView )
@@ -1529,10 +1536,11 @@ def run(self):
1529
1536
1530
1537
data = e .next_part ()
1531
1538
1532
- ret = seed_screens .SeedTranscribeSeedQRWholeQRScreen (
1539
+ ret = self .run_screen (
1540
+ seed_screens .SeedTranscribeSeedQRWholeQRScreen ,
1533
1541
qr_data = data ,
1534
1542
num_modules = self .num_modules ,
1535
- ). display ()
1543
+ )
1536
1544
1537
1545
if ret == RET_CODE__BACK_BUTTON :
1538
1546
return Destination (BackStackView )
@@ -1607,10 +1615,11 @@ def __init__(self, seed_num: int):
1607
1615
def run (self ):
1608
1616
button_data = [self .SCAN , self .DONE ]
1609
1617
1610
- selected_menu_option = seed_screens .SeedTranscribeSeedQRConfirmQRPromptScreen (
1618
+ selected_menu_option = self .run_screen (
1619
+ seed_screens .SeedTranscribeSeedQRConfirmQRPromptScreen ,
1611
1620
title = _ ("Confirm SeedQR?" ),
1612
1621
button_data = button_data ,
1613
- ). display ()
1622
+ )
1614
1623
1615
1624
if selected_menu_option == RET_CODE__BACK_BUTTON :
1616
1625
return Destination (BackStackView )
@@ -1625,61 +1634,100 @@ def run(self):
1625
1634
1626
1635
class SeedTranscribeSeedQRConfirmScanView (View ):
1627
1636
def __init__ (self , seed_num : int ):
1637
+ from seedsigner .models .decode_qr import DecodeQR
1628
1638
super ().__init__ ()
1629
1639
self .seed_num = seed_num
1630
1640
self .seed = self .controller .get_seed (seed_num )
1641
+ wordlist_language_code = self .settings .get_value (SettingsConstants .SETTING__WORDLIST_LANGUAGE )
1642
+ self .decoder = DecodeQR (wordlist_language_code = wordlist_language_code )
1631
1643
1632
1644
def run (self ):
1633
1645
from seedsigner .gui .screens .scan_screens import ScanScreen
1634
- from seedsigner .models .decode_qr import DecodeQR
1635
1646
1636
1647
# Run the live preview and QR code capture process
1637
1648
# TODO: Does this belong in its own BaseThread?
1638
- wordlist_language_code = self .settings .get_value (SettingsConstants .SETTING__WORDLIST_LANGUAGE )
1639
- self .decoder = DecodeQR (wordlist_language_code = wordlist_language_code )
1640
- ScanScreen (
1649
+ self .run_screen (
1650
+ ScanScreen ,
1641
1651
decoder = self .decoder ,
1642
1652
instructions_text = _ ("Scan your SeedQR" )
1643
- ). display ()
1653
+ )
1644
1654
1645
1655
if self .decoder .is_complete :
1646
1656
if self .decoder .is_seed :
1647
1657
seed_mnemonic = self .decoder .get_seed_phrase ()
1648
1658
# Found a valid mnemonic seed! But does it match?
1649
1659
if seed_mnemonic != self .seed .mnemonic_list :
1650
- DireWarningScreen (
1651
- title = _ ("Confirm SeedQR" ),
1652
- status_headline = _ ("Error!" ),
1653
- text = _ ("Your transcribed SeedQR does not match your original seed!" ),
1654
- show_back_button = False ,
1655
- button_data = [_ ("Review SeedQR" )],
1656
- ).display ()
1657
-
1658
- return Destination (BackStackView , skip_current_view = True )
1659
-
1660
+ return Destination (SeedTranscribeSeedQRConfirmWrongSeedView , skip_current_view = True )
1660
1661
else :
1661
- from seedsigner .gui .screens .screen import LargeIconStatusScreen
1662
- LargeIconStatusScreen (
1663
- title = _ ("Confirm SeedQR" ),
1664
- status_headline = _ ("Success!" ),
1665
- text = _ ("Your transcribed SeedQR successfully scanned and yielded the same seed." ),
1666
- show_back_button = False ,
1667
- button_data = [_ ("OK" )],
1668
- ).display ()
1662
+ return Destination (SeedTranscribeSeedQRConfirmSuccessView , view_args = {"seed_num" : self .seed_num })
1669
1663
1670
- return Destination (SeedOptionsView , view_args = {"seed_num" : self .seed_num })
1664
+ else :
1665
+ # Will this case ever happen? Will trigger if a different kind of QR code is scanned
1666
+ return Destination (SeedTranscribeSeedQRConfirmInvalidQRView , skip_current_view = True )
1671
1667
1672
- else :
1673
- # Will this case ever happen? Will trigger if a different kind of QR code is scanned
1674
- DireWarningScreen (
1675
- title = _ ("Confirm SeedQR" ),
1676
- status_headline = _ ("Error!" ),
1677
- text = _ ("Your transcribed SeedQR could not be read!" ),
1678
- show_back_button = False ,
1679
- button_data = [_ ("Review SeedQR" )],
1680
- ).display ()
1681
-
1682
- return Destination (BackStackView , skip_current_view = True )
1668
+
1669
+
1670
+ class SeedTranscribeSeedQRConfirmWrongSeedView (View ):
1671
+ """
1672
+ A valid SeedQR was scanned but it did NOT match the one we just transcribed!
1673
+ """
1674
+ def run (self ):
1675
+ self .run_screen (
1676
+ DireWarningScreen ,
1677
+ title = _ ("Confirm SeedQR" ),
1678
+ status_headline = _ ("Error!" ),
1679
+ text = _ ("Your transcribed SeedQR does not match your original seed!" ),
1680
+ show_back_button = False ,
1681
+ button_data = [ButtonOption ("Review SeedQR" )],
1682
+ )
1683
+
1684
+ # Skip BACK to the zoomed in transcription view
1685
+ return Destination (BackStackView , skip_current_view = True )
1686
+
1687
+
1688
+
1689
+ class SeedTranscribeSeedQRConfirmInvalidQRView (View ):
1690
+ """
1691
+ A QR code was scanned but it was not a SeedQR and certainly not the SeedQR we just
1692
+ transcribed!
1693
+ """
1694
+ def run (self ):
1695
+ # TODO: A better error message would be something like: "The QR code you scanned does not contain a valid SeedQR."
1696
+ self .run_screen (
1697
+ DireWarningScreen ,
1698
+ title = _ ("Confirm SeedQR" ),
1699
+ status_headline = _ ("Error!" ),
1700
+ text = _ ("Your transcribed SeedQR could not be read!" ),
1701
+ show_back_button = False ,
1702
+ button_data = [ButtonOption ("Review SeedQR" )],
1703
+ )
1704
+
1705
+ # Skip BACK to the zoomed in transcription view
1706
+ return Destination (BackStackView , skip_current_view = True )
1707
+
1708
+
1709
+
1710
+ class SeedTranscribeSeedQRConfirmSuccessView (View ):
1711
+ """
1712
+ The SeedQR we just scanned matched the one we just transcribed.
1713
+ """
1714
+ def __init__ (self , seed_num : int ):
1715
+ super ().__init__ ()
1716
+ self .seed_num = seed_num
1717
+
1718
+
1719
+ def run (self ):
1720
+ from seedsigner .gui .screens .screen import LargeIconStatusScreen
1721
+ self .run_screen (
1722
+ LargeIconStatusScreen ,
1723
+ title = _ ("Confirm SeedQR" ),
1724
+ status_headline = _ ("Success!" ),
1725
+ text = _ ("Your transcribed SeedQR successfully scanned and yielded the same seed." ),
1726
+ show_back_button = False ,
1727
+ button_data = [ButtonOption ("OK" )],
1728
+ )
1729
+
1730
+ return Destination (SeedOptionsView , view_args = {"seed_num" : self .seed_num })
1683
1731
1684
1732
1685
1733
0 commit comments