Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SFT-2458: update max sequence text #368

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 transaction is too large for QR signing. \
\nSpend fewer coins or sign via microSD card.").show()

self.set_result(False)
return

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

Expand Down
Loading