Skip to content

Commit

Permalink
Merge pull request #576 from newtonick/sign-message-allow-overflow
Browse files Browse the repository at this point in the history
[Bugfix] Message Signing TextDoesNotFitException on long no whitespace messages
  • Loading branch information
newtonick authored Jul 19, 2024
2 parents 07f0bbf + 98f6aed commit 13e1d60
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/seedsigner/gui/screens/seed_screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,7 @@ def __post_init__(self):
text=self.sign_message_data["message"],
width=renderer.canvas_width - 2*GUIConstants.EDGE_PADDING,
height=message_height,
allow_text_overflow=True,
)
self.sign_message_data["paged_message"] = paged

Expand Down
21 changes: 21 additions & 0 deletions tests/test_flows_seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ class TestMessageSigningFlows(FlowTest):
TESTNET_DERIVATION_PATH = "m/84h/1h/0h/0/0"
CUSTOM_DERIVATION_PATH = "m/99h/0/0"
SHORT_MESSAGE = "I attest that I control this bitcoin address blah blah blah"
NO_WHITESPACE_MESSAGE = """{"height":841407,"lightning_bolt12":"lno1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}"""
MULTIPAGE_MESSAGE = """Chancellor on brink of second bailout for banks
Billions may be needed as lending squeeze tightens
Expand Down Expand Up @@ -443,6 +444,10 @@ def load_multipage_message_into_decoder(self, view: View):
self.load_signmessage_into_decoder(view, self.MAINNET_DERIVATION_PATH, self.MULTIPAGE_MESSAGE)


def load_no_whitespace_message_into_decoder(self, view: View):
self.load_signmessage_into_decoder(view, self.MAINNET_DERIVATION_PATH, self.NO_WHITESPACE_MESSAGE)


def load_custom_derivation_into_decoder(self, view: View):
self.load_signmessage_into_decoder(view, self.CUSTOM_DERIVATION_PATH, self.SHORT_MESSAGE)

Expand All @@ -454,6 +459,7 @@ def inject_mesage_as_paged_message(self, view: View):
text=self.controller.sign_message_data["message"],
width=240 - 2*GUIConstants.EDGE_PADDING,
height=240 - GUIConstants.TOP_NAV_HEIGHT - 3*GUIConstants.EDGE_PADDING - GUIConstants.BUTTON_HEIGHT,
allow_text_overflow=True,
)
self.controller.sign_message_data["paged_message"] = paged

Expand Down Expand Up @@ -529,6 +535,21 @@ def test_sign_message_flow(self):
FlowStep(MainMenuView),
])

# Scenario 4: Load a long message without whitespace
self.controller.discard_seed(0)
self.run_sequence([
FlowStep(MainMenuView, button_data_selection=MainMenuView.SCAN),
FlowStep(scan_views.ScanView, before_run=self.load_seed_into_decoder), # simulate read SeedQR; ret val is ignored
FlowStep(seed_views.SeedFinalizeView, button_data_selection=seed_views.SeedFinalizeView.FINALIZE),
FlowStep(seed_views.SeedOptionsView, button_data_selection=seed_views.SeedOptionsView.SIGN_MESSAGE),
FlowStep(scan_views.ScanView, before_run=self.load_no_whitespace_message_into_decoder), # simulate read message QR; ret val is ignored
FlowStep(seed_views.SeedSignMessageStartView, is_redirect=True),
FlowStep(seed_views.SeedSignMessageConfirmMessageView, before_run=self.inject_mesage_as_paged_message, screen_return_value=0),
FlowStep(seed_views.SeedSignMessageConfirmAddressView, screen_return_value=0),
FlowStep(seed_views.SeedSignMessageSignedMessageQRView, screen_return_value=0),
FlowStep(MainMenuView),
])


def test_sign_message_network_mismatch_flow(self):
"""
Expand Down

0 comments on commit 13e1d60

Please sign in to comment.