fix Mk4 re-export infinite loop
This commit is contained in:
parent
e2fc69661a
commit
ef72dc00ae
@ -813,8 +813,13 @@ async def done_signing(psbt, tx_req, input_method=None, filename=None,
|
||||
if txid:
|
||||
intro.append('TXID:\n' + txid)
|
||||
|
||||
# "force_prompt" is needed after first iteration as we can be Mk4, with NFC,Vdisk off,
|
||||
# no QR support & not finalizing (no option to show txid provided).
|
||||
# In that case this would just return dict and keep producing signed
|
||||
# files on SD infinitely (would never actually prompt).
|
||||
ch = await import_export_prompt(noun, intro="\n\n".join(intro), offer_kt=offer_kt,
|
||||
txid=txid, title=title)
|
||||
txid=txid, title=title, force_prompt=not first_time,
|
||||
no_qr=not version.has_qwerty)
|
||||
if ch == KEY_CANCEL:
|
||||
UserAuthorizedAction.cleanup()
|
||||
break
|
||||
|
||||
@ -2031,7 +2031,9 @@ def load_export(need_keypress, cap_story, microsd_path, virtdisk_path, nfc_read_
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def signing_artifacts_reexport(cap_story, need_keypress, load_export, press_cancel, is_q1):
|
||||
def signing_artifacts_reexport(cap_story, need_keypress, load_export, press_cancel, is_q1,
|
||||
settings_get):
|
||||
|
||||
def doit(way, tx_final=False, txid=None, encoding=None, del_after=False, is_usb=False):
|
||||
label = "Finalized TX ready for broadcast" if tx_final else "Partly Signed PSBT"
|
||||
def _check_story(the_way):
|
||||
@ -2058,6 +2060,9 @@ def signing_artifacts_reexport(cap_story, need_keypress, load_export, press_canc
|
||||
if not is_q1:
|
||||
to_do.remove("qr")
|
||||
|
||||
if not settings_get("nfc", None):
|
||||
to_do.remove("nfc")
|
||||
|
||||
res = []
|
||||
res_tx = []
|
||||
for _way in to_do:
|
||||
|
||||
@ -1725,12 +1725,17 @@ def test_bitcoind_missing_foreign_utxo(bitcoind, bitcoind_d_sim_watch, microsd_p
|
||||
cc_pubkey = cc.getaddressinfo(cc_addr)["pubkey"]
|
||||
# fund all addresses
|
||||
for addr in (alice_addr, bob_addr, cc_addr):
|
||||
bitcoind.supply_wallet.generatetoaddress(101, addr)
|
||||
bitcoind.supply_wallet.sendtoaddress(addr, 2.0)
|
||||
|
||||
# mine above sends
|
||||
bitcoind.supply_wallet.generatetoaddress(1, bitcoind.supply_wallet.getnewaddress())
|
||||
|
||||
psbt_list = []
|
||||
for w in (alice, bob, cc):
|
||||
assert w.listunspent()
|
||||
psbt = w.walletcreatefundedpsbt([], [{dest_address: 1.0}], 0, {"fee_rate": 20})["psbt"]
|
||||
psbt_list.append(psbt)
|
||||
|
||||
# join PSBTs to one
|
||||
the_psbt = bitcoind.supply_wallet.joinpsbts(psbt_list)
|
||||
the_psbt_obj = BasicPSBT().parse(the_psbt.encode())
|
||||
@ -3057,4 +3062,23 @@ def test_null_data_op_return(fake_txn, start_sign, end_sign, reset_seed_words):
|
||||
assert "null-data" in story
|
||||
assert "OP_RETURN" in story
|
||||
|
||||
|
||||
def test_mk4_done_signing_infinite_loop(goto_home, try_sign, fake_txn, enable_hw_ux,
|
||||
settings_get, is_q1):
|
||||
if is_q1:
|
||||
raise pytest.skip("Irrelecant on Q as it always provides QR option")
|
||||
|
||||
goto_home()
|
||||
had_nfc = settings_get("nfc", None)
|
||||
had_vdisk = settings_get("vidsk", None)
|
||||
enable_hw_ux("nfc", disable=True)
|
||||
enable_hw_ux("vdisk", disable=True)
|
||||
psbt = fake_txn(1, 2, segwit_in=True, change_outputs=[0])
|
||||
try_sign(psbt, accept=True)
|
||||
# above never returns in unpatched version and fills up the disk
|
||||
if had_nfc:
|
||||
enable_hw_ux("nfc")
|
||||
if had_vdisk:
|
||||
enable_hw_ux("vdisk")
|
||||
|
||||
# EOF
|
||||
|
||||
@ -10,7 +10,7 @@ from bip32 import BIP32Node
|
||||
|
||||
@pytest.fixture
|
||||
def enable_hw_ux(pick_menu_item, cap_story, press_select, goto_home):
|
||||
def doit(way):
|
||||
def doit(way, disable=False):
|
||||
pick_menu_item("Settings")
|
||||
pick_menu_item("Hardware On/Off")
|
||||
if way == "vdisk":
|
||||
@ -18,13 +18,19 @@ def enable_hw_ux(pick_menu_item, cap_story, press_select, goto_home):
|
||||
_, story = cap_story()
|
||||
if "emulate a virtual disk drive" in story:
|
||||
press_select()
|
||||
pick_menu_item("Enable")
|
||||
if disable:
|
||||
pick_menu_item("Default Off")
|
||||
else:
|
||||
pick_menu_item("Enable")
|
||||
elif way == "nfc":
|
||||
pick_menu_item("NFC Sharing")
|
||||
_, story = cap_story()
|
||||
if "(Near Field Communications)" in story:
|
||||
press_select()
|
||||
pick_menu_item("Enable NFC")
|
||||
if disable:
|
||||
pick_menu_item("Default Off")
|
||||
else:
|
||||
pick_menu_item("Enable NFC")
|
||||
else:
|
||||
raise RuntimeError("TODO")
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user