Skip to content

Commit

Permalink
Merge pull request #217 from kdmukai/bugfix_large_consolidation
Browse files Browse the repository at this point in the history
[Bugfix] Allow PSBTOverviewScreen to truncate "self-transfer"
  • Loading branch information
newtonick authored Jun 14, 2022
2 parents 97c7eaf + 6f60622 commit a21d427
Showing 1 changed file with 8 additions and 4 deletions.
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

0 comments on commit a21d427

Please sign in to comment.