Skip to content

Commit

Permalink
SFT-2458: first pass at new max sequence text
Browse files Browse the repository at this point in the history
  • Loading branch information
mjg-foundation committed Aug 9, 2023
1 parent 7fd0018 commit 094511a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions ports/stm32/boards/Passport/modules/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
'USER_SETTINGS_FULL',
'PSBT_TOO_LARGE',
'PSBT_OVERSIZED',
'QR_TOO_LARGE',
)
10 changes: 8 additions & 2 deletions ports/stm32/boards/Passport/modules/flows/scan_qr_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def __init__(self,
ur_types=None,
explicit_type=None,
data_description=None,
max_frames=None):
max_frames=None,
pass_error=False):
"""
Initialize the scan QR flow.
Expand All @@ -40,6 +41,7 @@ def __init__(self,
self.data_description = data_description
self.data = None
self.max_frames = max_frames
self.pass_error = pass_error

if len(self.qr_types) == 0:
raise ValueError('At least one QR type must be provided')
Expand All @@ -62,7 +64,11 @@ async def scan(self):
return

if result.is_failure():
await ErrorPage(text='Unable to scan QR code.\n\n{}'.format(result.error)).show()
if self.pass_error:
self.set_result(Error.QR_TOO_LARGE)
return

await ErrorPage('Unable to scan QR code.\n\n{}'.format(result.error)).show()
self.set_result(None)
return

Expand Down
12 changes: 10 additions & 2 deletions ports/stm32/boards/Passport/modules/flows/sign_psbt_qr_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ async def scan_transaction(self):
from data_codecs.qr_type import QRType
from flows import ScanQRFlow, SignPsbtMicroSDFlow
from errors import Error
from pages import YesNoChooserPage
from pages import YesNoChooserPage, ErrorPage
import microns
import passport

result = await ScanQRFlow(qr_types=[QRType.QR, QRType.UR2],
ur_types=[ur.Value.CRYPTO_PSBT, ur.Value.BYTES],
data_description='a PSBT file',
max_frames=self.max_frames).run()
max_frames=self.max_frames,
pass_error=True).run()
if result is None:
# User canceled the scan
self.set_result(False)
Expand All @@ -56,6 +57,13 @@ async def scan_transaction(self):
self.set_result(result)
return # Run it again with no max frames if the user wants

if result == Error.QR_TOO_LARGE:
await ErrorPage("This QR sequence is too large for Passport to handle. \
\nSpend fewer coins in a single transaction or sign via microSD card.").show()

self.set_result(False)
return

if isinstance(result, ur.Value):
self.ur_type = result.ur_type()

Expand Down

0 comments on commit 094511a

Please sign in to comment.