From d5939ef063f326eb3d53ad2b5b84cc07acd8d317 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 2 Sep 2024 09:43:47 +0000 Subject: [PATCH] macOS: enable live autosigning (bugfix) --- mmgen/autosign.py | 5 ++++- mmgen/main_txbump.py | 5 ++--- mmgen/main_txcreate.py | 5 ++--- mmgen/main_txsend.py | 5 ++--- mmgen/tx/util.py | 3 ++- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/mmgen/autosign.py b/mmgen/autosign.py index 9b58a1f9..2ccd062d 100755 --- a/mmgen/autosign.py +++ b/mmgen/autosign.py @@ -731,7 +731,10 @@ class Autosign: if sys.platform == 'linux': return self.dev_label_path.exists() elif sys.platform == 'darwin': - return self.mountpoint.exists() + if self.cfg.test_suite_root_pfx: + return self.mountpoint.exists() + else: + return run(['diskutil', 'info', self.dev_label], stdout=DEVNULL, stderr=DEVNULL).returncode == 0 async def main_loop(self): if not self.cfg.stealth_led: diff --git a/mmgen/main_txbump.py b/mmgen/main_txbump.py index 07bce193..e4dd90e2 100755 --- a/mmgen/main_txbump.py +++ b/mmgen/main_txbump.py @@ -128,10 +128,9 @@ silent = cfg.yes and cfg.fee is not None and cfg.output_to_reduce is not None async def main(): if cfg.autosign: - from .tx.util import init_removable_device + from .tx.util import mount_removable_device from .autosign import Signable - asi = init_removable_device(cfg) - asi.do_mount() + asi = mount_removable_device(cfg) si = Signable.automount_transaction(asi) if si.unsigned or si.unsent: state = 'unsigned' if si.unsigned else 'unsent' diff --git a/mmgen/main_txcreate.py b/mmgen/main_txcreate.py index 2ad82ede..610ed714 100755 --- a/mmgen/main_txcreate.py +++ b/mmgen/main_txcreate.py @@ -87,10 +87,9 @@ cfg = Config(opts_data=opts_data) async def main(): if cfg.autosign: - from .tx.util import init_removable_device + from .tx.util import mount_removable_device from .autosign import Signable - asi = init_removable_device(cfg) - asi.do_mount() + asi = mount_removable_device(cfg) Signable.automount_transaction(asi).check_create_ok() from .tx import NewTX diff --git a/mmgen/main_txsend.py b/mmgen/main_txsend.py index 3ecc4e22..a78e0c91 100755 --- a/mmgen/main_txsend.py +++ b/mmgen/main_txsend.py @@ -63,10 +63,9 @@ if len(cfg._args) == 1: from .fileutil import check_infile check_infile(infile) elif not cfg._args and cfg.autosign: - from .tx.util import init_removable_device + from .tx.util import mount_removable_device from .autosign import Signable - asi = init_removable_device(cfg) - asi.do_mount() + asi = mount_removable_device(cfg) si = Signable.automount_transaction(asi) if cfg.abort: si.shred_abortable() # prompts user, then raises exception or exits diff --git a/mmgen/tx/util.py b/mmgen/tx/util.py index 96c5616a..d9e6937c 100755 --- a/mmgen/tx/util.py +++ b/mmgen/tx/util.py @@ -25,11 +25,12 @@ def get_autosign_obj(cfg): }) ) -def init_removable_device(cfg): +def mount_removable_device(cfg): asi = get_autosign_obj(cfg) if not asi.device_inserted: from ..util import die die(1, 'Removable device not present!') import atexit atexit.register(lambda: asi.do_umount()) + asi.do_mount() return asi