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

[Bugfix] Allow PSBTOverviewScreen to truncate "self-transfer" #217

Merged
merged 3 commits into from
Jun 14, 2022
Merged
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
12 changes: 8 additions & 4 deletions src/seedsigner/gui/screens/psbt_screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,12 @@ def __post_init__(self):
# max_destination_col_width += curve_width

# Now let's maximize the actual destination col by adjusting our addr truncation
def calculate_destination_col_width(truncate_at: int):
def calculate_destination_col_width(truncate_at: int = 0):
def truncate_destination_addr(addr):
# TODO: Properly handle the ellipsis truncation in different languages
if len(addr) <= truncate_at + len("..."):
# No point in truncating
return addr
return f"{addr[:truncate_at]}..."

destination_column = []
Expand All @@ -129,7 +133,7 @@ def truncate_destination_addr(addr):
destination_column.append(truncate_destination_addr(addr))

for i in range(0, self.num_self_transfer_outputs):
destination_column.append(f"self-transfer")
destination_column.append(truncate_destination_addr("self-transfer"))
else:
# destination_column.append(f"{len(self.destination_addresses)} recipients")
destination_column.append(f"recipient 1")
Expand All @@ -151,10 +155,10 @@ def truncate_destination_addr(addr):

if len(self.destination_addresses) + self.num_self_transfer_outputs > 3:
# We're not going to display any destination addrs so truncation doesn't matter
(destination_text_width, destination_column) = calculate_destination_col_width(truncate_at=0)
(destination_text_width, destination_column) = calculate_destination_col_width()
else:
# Steadliy widen out the destination column until we run out of space
for i in range(6, 13):
for i in range(6, 14):
(new_width, new_col_text) = calculate_destination_col_width(truncate_at=i)
if new_width > max_destination_col_width:
break
Expand Down