truncated address - add one more char to first part to view regtest segwit version

This commit is contained in:
scgbckbone 2023-06-16 18:29:31 +02:00 committed by doc-hex
parent 0fe230e150
commit a3b466fc71
4 changed files with 16 additions and 8 deletions

View File

@ -21,7 +21,7 @@ def truncate_address(addr):
# - 16 chars screen width
# - but 2 lost at left (menu arrow, corner arrow)
# - want to show not truncated on right side
return addr[0:5] + '' + addr[-6:]
return addr[0:6] + '' + addr[-6:]
class KeypathMenu(MenuSystem):
def __init__(self, path=None, nl=0):

View File

@ -253,4 +253,10 @@ def sign_msg(key, msg, addr_fmt, b64 = False):
else:
return sig
def detruncate_address(s):
if s[0] == "":
s = s[1:]
start, end = s.split('')
return start, end
# EOF

View File

@ -5,6 +5,7 @@ from ckcc_protocol.constants import *
from pycoin.key.BIP32Node import BIP32Node
from pycoin.contrib.segwit_addr import encode as sw_encode
from pycoin.encoding import a2b_hashed_base58, hash160
from helpers import detruncate_address
@pytest.fixture
@ -173,7 +174,7 @@ def test_stub_menu(sim_execfile, goto_address_explorer, need_keypress, cap_menu,
validate_address(expected_addr, sk)
# validate that stub is correct
[start, end] = m[_id].split('-')
start, end = detruncate_address(m[_id])
assert expected_addr.startswith(start)
assert expected_addr.endswith(end)
@ -315,7 +316,7 @@ def test_account_menu(way, account_num, sim_execfile, pick_menu_item, goto_addre
validate_address(expected_addr, sk)
# validate that stub is correct
[start, end] = m[_id].split('-')
start, end = detruncate_address(m[_id])
assert expected_addr.startswith(start)
assert expected_addr.endswith(end)

View File

@ -14,8 +14,8 @@ from psbt import BasicPSBT, BasicPSBTInput, BasicPSBTOutput
from ckcc.protocol import CCProtocolPacker, MAX_TXN_LEN
from pprint import pprint
from base64 import b64encode, b64decode
from helpers import B2A, fake_dest_addr, swab32, xfp2str
from helpers import path_to_str, str_to_path, slip132undo
from helpers import B2A, fake_dest_addr, xfp2str, detruncate_address
from helpers import path_to_str, str_to_path, slip132undo, swab32
from struct import unpack, pack
from constants import *
from pycoin.key.BIP32Node import BIP32Node
@ -1924,14 +1924,15 @@ def test_ms_addr_explorer(descriptor, change, M, N, addr_fmt, make_multisig, cle
chng_idx = 1 if change else 0
path_mapper = lambda co_idx: str_to_path(derivs[co_idx]) + [chng_idx, idx]
expect, pubkey, script, _ = make_ms_address(M, keys, idx=idx, addr_fmt=addr_fmt,
expect, pubkey, script, _ = make_ms_address(M, keys, idx=idx, addr_fmt=addr_fmt,
path_mapper=path_mapper)
assert int(subpath.split('/')[-1]) == idx
#print('../0/%s => \n %s' % (idx, B2A(script)))
trunc = expect[0:8] + "-" + expect[-7:]
assert trunc == addr
start, end = detruncate_address(addr)
assert expect.startswith(start)
assert expect.endswith(end)
def test_dup_ms_wallet_bug(goto_home, pick_menu_item, need_keypress, import_ms_wallet, clear_ms, M=2, N=3):