autogenerate-rpc-examples.py: fixed recover examples via `lightning-hsmtool getsecret`
What changed, and why it matters
This commit updates a test script that automatically generates documentation examples for backup and recovery commands. It changes how the script retrieves a secret value for examples, switching from a developer tool command to a different command and from a raw hex secret to a 12-word mnemonic phrase. There is no indication this affects real user funds, live nodes, or production code paths.
No security action required. Review as normal test/documentation maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change is confined to tests/autogenerate-rpc-examples.py, a helper used to produce RPC documentation examples. The function get_hsm_secret is renamed to get_hsm_mmnemonic and now calls lightning-hsmtool getsecret instead of tools/hsmtool getcodexsecret, returning only a 12-word mnemonic. The recover RPC examples are updated to use that mnemonic as the hsmsecret parameter for two test nodes. No runtime node logic, wallet handling, or protocol code is modified.
Changed components
tests/autogenerate-rpc-examples.pyInspect captured patch +9 / −11
diff --git a/tests/autogenerate-rpc-examples.py b/tests/autogenerate-rpc-examples.py
index cb8f9f07..ad73d353 100644
--- a/tests/autogenerate-rpc-examples.py
+++ b/tests/autogenerate-rpc-examples.py
@@ -1311,22 +1311,20 @@ def generate_backup_recovery_examples(node_factory, l4, l5, l6, regenerate_block
update_example(node=l5, method='emergencyrecover', params={}, response=emergencyrecover_res2)
# Recover
- def get_hsm_secret(n):
- """Returns codex32 and hex"""
+ def get_hsm_mmnemonic(n):
+ """Returns 12 word mmnemonic"""
try:
hsmfile = os.path.join(n.daemon.lightning_dir, TEST_NETWORK, "hsm_secret")
- codex32 = subprocess.check_output(["tools/hsmtool", "getcodexsecret", hsmfile, "leet"]).decode('utf-8').strip()
- with open(hsmfile, "rb") as f:
- hexhsm = f.read().hex()
- return codex32, hexhsm
+ mmnemonic = subprocess.check_output(["lightning-hsmtool", "getsecret", hsmfile, "leet"]).decode('utf-8').strip()
+ return mmnemonic
except Exception as e:
- logger.error(f'Error in getting hsm secret: {e}')
+ logger.error(f'Error in getting mmnemonic: {e}')
raise
- _, l6hex = get_hsm_secret(l6)
- l13codex32, _ = get_hsm_secret(l13)
- update_example(node=l6, method='recover', params={'hsmsecret': l6hex})
- update_example(node=l13, method='recover', params={'hsmsecret': l13codex32})
+ l6mmnemonic = get_hsm_mmnemonic(l6)
+ l13mmnemonic = get_hsm_mmnemonic(l13)
+ update_example(node=l6, method='recover', params={'hsmsecret': l6mmnemonic})
+ update_example(node=l13, method='recover', params={'hsmsecret': l13mmnemonic})
logger.info('Backup and Recovery Done!')
except Exception as e:
logger.error(f'Error in generating backup and recovery examples: {e}')
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.