mk4=Q export wallet

This commit is contained in:
scgbckbone 2024-04-07 16:45:15 +02:00 committed by doc-hex
parent c7bc3e8348
commit 964c8b77ab
4 changed files with 40 additions and 18 deletions

View File

@ -183,7 +183,8 @@ async def make_summary_file(fname_pattern='public.txt'):
# generator function:
body = "".join(list(generate_public_contents()))
ch = chains.current_chain()
await write_text_file(fname_pattern, body, 'Summary', "m/44h/%dh/0h/0/0" % ch.b44_cointype,
await write_text_file(fname_pattern, body, 'Summary',
"m/44h/%dh/0h/0/0" % ch.b44_cointype,
AF_CLASSIC)
async def make_bitcoin_core_wallet(account_num=0, fname_pattern='bitcoin-core.txt'):
@ -259,7 +260,6 @@ def generate_bitcoin_core_wallet(account_num, example_addrs):
example_addrs.append( ('m/%s/%s' % (derive, sp), a) )
xfp = settings.get('xfp')
txt_xfp = xfp2str(xfp).lower()
_, vers, _ = version.get_mpy_version()
desc_obj = Descriptor(keys=[(xfp, derive, xpub)], addr_fmt=AF_P2WPKH)

View File

@ -386,7 +386,7 @@ def export_prompt_builder(what_it_is, no_qr=False, no_nfc=False, key0=None):
from version import has_qwerty, num_sd_slots, has_qr
from glob import NFC, VD
prompt, escape = None, KEY_CANCEL
prompt, escape = None, KEY_CANCEL+"x"
if (NFC or VD) or num_sd_slots>1 or key0:
# no need to spam with another prompt, only option is SD card

View File

@ -53,15 +53,16 @@ def _pick_menu_item(device, is_Q, text):
if text not in m:
raise KeyError(text, "%r not in menu: %r" % (text, m))
# double check we're looking at this menu, not stale data
# added strip as cap_screen does not contain whitespaces
# that are present in coundown chooser
# find menu item that does not contain triple dot char
target = [mi for mi in m if "" not in mi]
if target:
assert target[0][0:33].strip() in _cap_screen(device), 'not in menu mode'
else:
print("⋯ in all menu items - not sure about free - but continue")
if is_Q:
# double check we're looking at this menu, not stale data
# added strip as cap_screen does not contain whitespaces
# that are present in coundown chooser
# find menu item that does not contain triple dot char
target = [mi for mi in m if "" not in mi]
if target:
assert target[0][0:33].strip() in _cap_screen(device), 'not in menu mode'
else:
print("⋯ in all menu items - not sure about free - but continue")
m_pos = m.index(text)

View File

@ -19,12 +19,23 @@ from pprint import pprint
from charcodes import KEY_NFC
@pytest.fixture
def mk4_qr_not_allowed(is_q1):
def doit(way):
if way == "qr" and not is_q1:
pytest.skip("mk4 QR not allowed")
return doit
@pytest.mark.bitcoind
@pytest.mark.parametrize('acct_num', [None, '0', '99', '123'])
@pytest.mark.parametrize('way', ["sd", "vdisk", "nfc", "qr"])
def test_export_core(way, dev, use_regtest, acct_num, pick_menu_item, goto_home, cap_story,
need_keypress, microsd_path, virtdisk_path, bitcoind_wallet, bitcoind_d_wallet,
enter_number, nfc_read_text, load_export, bitcoind, press_select):
enter_number, nfc_read_text, load_export, bitcoind, press_select,
mk4_qr_not_allowed):
mk4_qr_not_allowed(way)
# test UX and operation of the 'bitcoin core' wallet export
from pycoin.contrib.segwit_addr import encode as sw_encode
use_regtest()
@ -203,8 +214,9 @@ def test_export_wasabi(way, dev, pick_menu_item, goto_home, cap_story, press_sel
@pytest.mark.parametrize('testnet', [True, False])
def test_export_electrum(way, dev, mode, acct_num, pick_menu_item, goto_home, cap_story, need_keypress,
microsd_path, nfc_read_json, virtdisk_path, use_mainnet, testnet, load_export,
press_select):
press_select, mk4_qr_not_allowed):
# lightly test electrum wallet export
mk4_qr_not_allowed(way)
if not testnet:
use_mainnet()
if "P2PKH" in mode:
@ -275,7 +287,9 @@ def test_export_electrum(way, dev, mode, acct_num, pick_menu_item, goto_home, ca
])
def test_export_coldcard(way, dev, acct_num, app, pick_menu_item, goto_home, cap_story, need_keypress,
microsd_path, nfc_read_json, virtdisk_path, addr_vs_path, enter_number,
load_export, testnet, use_mainnet, press_select):
load_export, testnet, use_mainnet, press_select, mk4_qr_not_allowed):
mk4_qr_not_allowed(way)
if not testnet:
use_mainnet()
@ -356,8 +370,10 @@ def test_export_coldcard(way, dev, acct_num, app, pick_menu_item, goto_home, cap
@pytest.mark.parametrize('acct_num', [None, '0', '99', '123'])
def test_export_unchained(way, dev, pick_menu_item, goto_home, cap_story, need_keypress, acct_num,
microsd_path, nfc_read_json, virtdisk_path, testnet, enter_number,
load_export, settings_set, use_mainnet, press_select):
load_export, settings_set, use_mainnet, press_select, mk4_qr_not_allowed):
# test UX and operation of the 'unchained export'
mk4_qr_not_allowed(way)
if not testnet:
use_mainnet()
goto_home()
@ -407,8 +423,10 @@ def test_export_unchained(way, dev, pick_menu_item, goto_home, cap_story, need_k
@pytest.mark.parametrize('testnet', [True, False])
def test_export_public_txt(way, dev, pick_menu_item, goto_home, press_select, microsd_path,
addr_vs_path, virtdisk_path, nfc_read_text, cap_story, use_mainnet,
load_export, testnet):
load_export, testnet, mk4_qr_not_allowed):
# test UX and values produced.
mk4_qr_not_allowed(way)
if not testnet:
use_mainnet()
goto_home()
@ -553,7 +571,10 @@ def test_export_xpub(use_nfc, acct_num, dev, cap_menu, pick_menu_item, goto_home
@pytest.mark.parametrize("int_ext", [True, False])
def test_generic_descriptor_export(chain, addr_fmt, acct_num, goto_home, settings_set, need_keypress,
pick_menu_item, way, cap_story, cap_menu, nfc_read_text, int_ext,
microsd_path, settings_get, virtdisk_path, load_export, press_select):
microsd_path, settings_get, virtdisk_path, load_export, press_select,
mk4_qr_not_allowed):
mk4_qr_not_allowed(way)
settings_set('chain', chain)
chain_num = 1 if chain in ["XTN", "XRT"] else 0
goto_home()