diff --git a/src/seedsigner/gui/screens/psbt_screens.py b/src/seedsigner/gui/screens/psbt_screens.py index 16d94554..6bf6bf55 100644 --- a/src/seedsigner/gui/screens/psbt_screens.py +++ b/src/seedsigner/gui/screens/psbt_screens.py @@ -704,10 +704,15 @@ def __post_init__(self): )) return except UnicodeDecodeError: - # Contains data that can't be converted to UTF-8; probably encoded and not - # meant to be human readable. - chars_per_line = 16 + # Contains data that can't be converted to UTF-8; it's probably just a blob + # of raw bytes that aren't meant to be human readable. + + # Force the raw bytes into a display string by omitting non-decodable chars decoded_str = self.op_return.decode(errors="ignore") + + # Assume there won't be any whitespace for TextArea to auto linebreak on so + # we just manually break it up into lines here. + chars_per_line = 16 num_lines = math.ceil(len(decoded_str) / chars_per_line) text = "" for i in range(num_lines): @@ -724,7 +729,6 @@ def __post_init__(self): self.components.append(TextArea( text=text, - # font_name=GUIConstants.FIXED_WIDTH_FONT_NAME, font_size=font_size, screen_y=label.screen_y + label.height + GUIConstants.COMPONENT_PADDING, )) diff --git a/tests/screenshot_generator/generator.py b/tests/screenshot_generator/generator.py index a6cc8cc2..9f0dbec1 100644 --- a/tests/screenshot_generator/generator.py +++ b/tests/screenshot_generator/generator.py @@ -220,7 +220,7 @@ def add_op_return_to_psbt(psbt: PSBT, raw_payload_data: bytes): (psbt_views.PSBTAddressDetailsView, dict(address_num=0)), (NotYetImplementedView, {}, "PSBTOverviewView_op_return"), # Placeholder - (NotYetImplementedView, {}, "PSBTOpReturnView_text"), # Placeholder + (NotYetImplementedView, {}, "PSBTOpReturnView_text"), # Placeholder (NotYetImplementedView, {}, "PSBTOpReturnView_raw_bytes"), # Placeholder