diff --git a/mmgen/autosign.py b/mmgen/autosign.py index 82448d9b..92c93bcc 100755 --- a/mmgen/autosign.py +++ b/mmgen/autosign.py @@ -470,7 +470,9 @@ class Autosign: 'enable_swap', 'disable_swap', 'clean', - 'wipe_key') + 'wipe_key', + 'list_led', + 'test_led') mn_fmts = { 'mmgen': 'words', diff --git a/mmgen/main_autosign.py b/mmgen/main_autosign.py index c81c9b37..0af456c2 100755 --- a/mmgen/main_autosign.py +++ b/mmgen/main_autosign.py @@ -22,7 +22,7 @@ autosign: Auto-sign MMGen transactions, message files and XMR wallet output file import sys -from .util import msg, die, fmt_list, exit_if_mswin, async_run +from .util import msg, ymsg, gmsg, die, fmt_list, exit_if_mswin, async_run exit_if_mswin('autosigning') @@ -94,6 +94,8 @@ wipe_key - wipe the wallet encryption key on the removable device, making signing transactions or stealing the user’s seed impossible. The operation is intended as a ‘kill switch’ and thus performed without prompting +list_led - list boards with tested LED signaling support +test_led - test the current board for LED signaling support USAGE NOTES @@ -107,10 +109,6 @@ If invoked with ‘wait’, the program waits in a loop, mounting the removable device, performing signing operations and unmounting the device every time it is inserted. -On supported platforms (currently Orange Pi, Rock Pi and Raspberry Pi boards), -the status LED indicates whether the program is busy or in standby mode, i.e. -ready for device insertion or removal. - The removable device must have a partition with a filesystem labeled MMGEN_TX and a user-writable root directory. For interoperability between OS-es, it’s recommended to use the exFAT file system. @@ -126,6 +124,27 @@ the directory ‘{asi.wallet_dir}’ (as currently configured). The wallet is encrypted with a 32-byte password saved in the file ‘autosign.key’ in the root of the removable device’s filesystem. + + LED SIGNALING SUPPORT + +On supported platforms (selected Orange Pi, Rock Pi, Banana Pi, Nano Pi and +Raspberry Pi boards), a flashing LED indicates whether signing is in progress +or the program is in standby mode, i.e. ready for device insertion or removal. + +The operation ‘test_led’ tests the current installation for LED support, while +‘list_led’ displays a list of supported board/OS combinations. Note that this +list is not exhaustive: signaling may work with other boards, especially those +produced by the listed manufacturers. If ‘test_led’ reports that your board is +not supported, please submit an issue to the mmgen-wallet repository on Github +or via e-mail, including the board model, OS version and output of the +following shell command: + + ls -RH /sys/class/leds/{{*status*,*led*}} + +In the absence of LED support, the user must observe the signing progress +on-screen and wait for the “safe to extract” message to appear. + + The password and temporary wallet may be created in one operation by invoking ‘mmgen-autosign setup’ with the removable device inserted. In this case, the temporary wallet is created from the user’s default wallet, if it exists and @@ -206,6 +225,23 @@ cmd = cfg._args[0] if len(cfg._args) == 1 else 'sign' if not cfg._args else cfg. if cmd not in Autosign.cmds + Autosign.util_cmds: die(1, f'‘{cmd}’: unrecognized command') +if cmd in ('test_led', 'list_led'): + from .led import LEDControl + match cmd: + case 'list_led': + msg( + 'Boards with tested LED signaling support:\n' + + '\n'.join(f' {v.name}' for k, v in LEDControl.boards.items() if k != 'dummy')) + case 'test_led': + from .exception import NoLEDSupport + try: + LEDControl(enabled=True) + except NoLEDSupport: + ymsg('No LED signaling support for this platform') + else: + gmsg('LED signaling is supported by this platform!') + sys.exit(0) + if cmd != 'setup': for opt in ('seed_len', 'mnemonic_fmt', 'keys_from_file'): if getattr(cfg, opt): diff --git a/test/cmdtest_d/autosign.py b/test/cmdtest_d/autosign.py index 0368bd7a..312f2515 100755 --- a/test/cmdtest_d/autosign.py +++ b/test/cmdtest_d/autosign.py @@ -646,6 +646,8 @@ class CmdTestAutosign(CmdTestAutosignBase): ) cmd_group = ( + ('test_led', 'testing for LED support'), + ('list_led', 'listing LED-supported boards'), ('start_daemons', 'starting daemons'), ('copy_tx_files', 'copying transaction files'), ('gen_key', 'generating key'), @@ -1015,6 +1017,14 @@ class CmdTestAutosign(CmdTestAutosignBase): self.remove_device() return t + def test_led(self, *, op='test_led', expect_str='LED signaling'): + t = self.spawn('mmgen-autosign', ['--quiet', '--no-insert-check', op]) + t.expect(expect_str) + return t + + def list_led(self): + return self.test_led(op='list_led', expect_str='Boards with') + class CmdTestAutosignBTC(CmdTestAutosign): 'autosigning BTC transactions' coins = ['btc']