diff --git a/ports/stm32/boards/Passport/modules/utils.py b/ports/stm32/boards/Passport/modules/utils.py index a33a64a1..ca5b2bb9 100644 --- a/ports/stm32/boards/Passport/modules/utils.py +++ b/ports/stm32/boards/Passport/modules/utils.py @@ -871,10 +871,8 @@ async def needs_microsd(): def format_btc_address(address, addr_type): from public_constants import AF_P2WPKH - if addr_type == AF_P2WPKH: - width = 14 - else: - width = 16 + # The max number of characters on a single line + width = 14 return split_to_lines(address, width) @@ -904,4 +902,18 @@ def split_by_char_size(msg, font): lines.append(ln) return lines +def partition_evenly_by_max_size(total, max_part_size): + num_total_parts = (total + max_part_size - 1) // max_part_size + min_size = int(total / num_total_parts) + num_big_parts = total % num_total_parts + parts = [] + + for i in range(0, num_big_parts): + parts.append(min_size + 1) + + for i in range(num_big_parts, num_total_parts): + parts.append(min_size) + + return parts + # EOF diff --git a/ports/stm32/boards/Passport/modules/wallets/utils.py b/ports/stm32/boards/Passport/modules/wallets/utils.py index 01ba692d..5e0fb118 100644 --- a/ports/stm32/boards/Passport/modules/wallets/utils.py +++ b/ports/stm32/boards/Passport/modules/wallets/utils.py @@ -95,16 +95,18 @@ def get_deriv_fmt_from_address(address, is_multisig): # Map the address prefix to a standard derivation path and insert the account number if is_multisig: - if address[0] == '3': + if (address[0] == '3' or address[0] == 'n'): return "m/48'/{coin_type}'/{acct}'/1'" - elif address[0] == 'b' and address[1] == 'c' and address[2] == '1': + elif ((address[0] == 'b' and address[1] == 'c' and address[2] == '1') or + (address[0] == 't' and address[1] == 'b' and address[2] == '1')): return "m/48'/{coin_type}'/{acct}'/2'" else: - if address[0] == '1': + if (address[0] == '1' or address[0] == 'm'): return "m/44'/{coin_type}'/{acct}'" - elif address[0] == '3': + elif (address[0] == '3' or address[0] == 'n'): return "m/49'/{coin_type}'/{acct}'" - elif address[0] == 'b' and address[1] == 'c' and address[2] == '1': + elif ((address[0] == 'b' and address[1] == 'c' and address[2] == '1') or + (address[0] == 't' and address[1] == 'b' and address[2] == '1')): return "m/84'/{coin_type}'/{acct}'" return None