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

(cherry picked from commit a3b466fc71)
This commit is contained in:
scgbckbone 2023-06-16 18:29:31 +02:00 committed by doc-hex
parent 7a21a37fb9
commit 14350452f0
4 changed files with 15 additions and 7 deletions

View File

@ -629,6 +629,6 @@ 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:]
# EOF

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
@ -175,7 +176,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][1:6], m[_id][7:]
start, end = detruncate_address(m[_id])
assert expected_addr.startswith(start)
assert expected_addr.endswith(end)
@ -317,7 +318,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][1:6], m[_id][7:]
start, end = detruncate_address(m[_id])
assert expected_addr.startswith(start)
assert expected_addr.endswith(end)

View File

@ -10,8 +10,8 @@ import time, pytest, os, random, json, shutil, pdb, io, base64
from psbt import BasicPSBT, BasicPSBTInput, BasicPSBTOutput
from ckcc.protocol import CCProtocolPacker, MAX_TXN_LEN
from pprint import pprint
from helpers import B2A, fake_dest_addr, swab32, xfp2str
from helpers import str_to_path, slip132undo
from helpers import B2A, fake_dest_addr, xfp2str, detruncate_address
from helpers import str_to_path, slip132undo, swab32
from struct import unpack, pack
from constants import *
from pycoin.key.BIP32Node import BIP32Node
@ -1892,8 +1892,9 @@ def test_ms_addr_explorer(descriptor, change, M, N, addr_fmt, make_multisig, cle
assert int(subpath.split('/')[-2]) == chng_idx
#print('../0/%s => \n %s' % (idx, B2A(script)))
assert addr[:5] == expect[:5]
assert addr[-6:] == expect[-6:]
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):