diff --git a/releases/Next-ChangeLog.md b/releases/Next-ChangeLog.md index 337a00f4..9fbc4297 100644 --- a/releases/Next-ChangeLog.md +++ b/releases/Next-ChangeLog.md @@ -25,7 +25,9 @@ This lists the new changes that have not yet been published in a normal release. - Enhancement: 10% performance improvement in USB upload speed for large files - Bugfix: Fix stuck progress bar under `Receiving...` after a USB communications failure - Bugfix: Showing derivation path in Address Explorer for root key (m) showed double slash (//) -- Bugfix: Enable to restore dev backup with custom password other than 12 words format +- Bugfix: Enable to restore dev backup with custom password other than 12 words format +- Bugfix: Virtual Disk auto mode ignore already signed PSBTs (with "-signed" in file name) +- Bugfix: Virtual Disk auto mode stuck on "Reading..." screen # Mk4 Specific Changes diff --git a/shared/auth.py b/shared/auth.py index 3559f763..a09dc077 100644 --- a/shared/auth.py +++ b/shared/auth.py @@ -13,7 +13,7 @@ from public_constants import AFC_SCRIPT, AF_CLASSIC, AFC_BECH32, AF_P2WPKH, AF_P from public_constants import STXN_FINALIZE, STXN_VISUALIZE, STXN_SIGNED from sffile import SFFile from ux import ux_aborted, ux_show_story, abort_and_goto, ux_dramatic_pause, ux_clear_keys -from ux import show_qr_code, OK, X, ux_input_text, ux_enter_bip32_index +from ux import show_qr_code, OK, X, ux_input_text, ux_enter_bip32_index, abort_and_push from usb import CCBusyError from utils import HexWriter, xfp2str, problem_file_line, cleanup_deriv_path, chunk_checksum from utils import B2A, to_ascii_printable, show_single_address @@ -1439,7 +1439,7 @@ async def done_signing(psbt, input_method=None, filename=None, force_vdisk=False n += 1 -async def sign_psbt_file(filename, force_vdisk=False, slot_b=None): +async def sign_psbt_file(filename, force_vdisk=False, slot_b=None, abort=False): # sign a PSBT file found on a MicroSD card # - or from VirtualDisk (mk4) from files import CardSlot @@ -1498,7 +1498,11 @@ async def sign_psbt_file(filename, force_vdisk=False, slot_b=None): "force_vdisk": force_vdisk, "output_encoder": output_encoder} ) - the_ux.push(UserAuthorizedAction.active_request) + if abort: + # needed for auto vdisk mode + abort_and_push(UserAuthorizedAction.active_request) + else: + the_ux.push(UserAuthorizedAction.active_request) class RemoteBackup(UserAuthorizedAction): def __init__(self): diff --git a/shared/vdisk.py b/shared/vdisk.py index 8b4fcab4..483281d0 100644 --- a/shared/vdisk.py +++ b/shared/vdisk.py @@ -111,10 +111,10 @@ class VirtDisk: return actual - def new_psbt(self, filename, sz): + def new_psbt(self, filename): # New incoming PSBT has been detected, start to sign it. from auth import sign_psbt_file - uasyncio.create_task(sign_psbt_file(filename, force_vdisk=True)) + uasyncio.create_task(sign_psbt_file(filename, force_vdisk=True, abort=True)) def new_firmware(self, filename, sz): # potential new firmware file detected @@ -157,9 +157,9 @@ class VirtDisk: lfn = fn.lower() - if lfn.endswith('.psbt') and sz > 100: + if lfn.endswith('.psbt') and sz > 100 and ("-signed" not in lfn): self.ignore.add(fn) - self.new_psbt(fn, sz) + self.new_psbt(fn) break if lfn.endswith('.dfu') and sz > FW_MIN_LENGTH: diff --git a/unix/variant/sim_vdisk.py b/unix/variant/sim_vdisk.py index 321617f5..16097655 100644 --- a/unix/variant/sim_vdisk.py +++ b/unix/variant/sim_vdisk.py @@ -75,9 +75,12 @@ class SimulatedVirtDisk(vdisk.VirtDisk): def import_file(self, filename, sz): # copy file into another area of PSRAM where rest of system can use it print("sim-virtdisk: read %s" % filename) - contents = open(SIMDIR_PATH+filename, 'rb').read(sz) + with open(filename, 'rb') as f: + contents = f.read(sz) from glob import PSRAM - PSRAM.write_at(0, sz)[:] = contents + runt = (4 - sz % 4) + sz = sz + runt + PSRAM.write_at(0, sz)[:] = contents + bytes(runt) return sz vdisk.VirtDisk = SimulatedVirtDisk