Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hsmtool.c - Added new method to enable creation of hsm_file from cmd-line args #7102

Merged
merged 3 commits into from
Nov 15, 2024

Conversation

bstin
Copy link
Contributor

@bstin bstin commented Feb 22, 2024

Creating a hsm_file with hsmtool is currently an interactive process in terminal where user is expected to make choices for language, typing in seed phrase, etc. This works well, but is difficult to utilize for automated installs (ie. Docker, unattended-installs, etc).

This adds a new method: generatehsmbyargs that allows the user to input all required args on command-line and generate the hsm_file without terminal interaction.

Also the documentation was lightning-hsmtool.8.md updated to include new method.

All existing functionality was preserved, this only added a new method.

@rustyrussell rustyrussell added this to the v24.05 milestone Mar 20, 2024
@rustyrussell
Copy link
Contributor

Sorry about the delay reviewing!

I prefer to extend generatehsm to take the cmdline args if they are present? That ensures that the language list stays consistent, for example.

@niftynei
Copy link
Contributor

@bstin any update on this?

@vincenzopalazzo
Copy link
Contributor

I prefer to extend generatehsm to take the cmdline args if they are present? That ensures that the language list stays consistent, for example.

For compatibility with another mobile wallet where people can import this list of words, I would like to have just English as an option, using different languages can cause lack with other wallets

@rustyrussell rustyrussell modified the milestones: v24.05, v24.08 Jun 9, 2024
@rustyrussell rustyrussell modified the milestones: v24.08, v24.11 Aug 10, 2024
@rustyrussell
Copy link
Contributor

I rewrote this to extend the generatehsm command line instead.

@rustyrussell rustyrussell force-pushed the mypatch-1 branch 3 times, most recently from d3c106f to 40e2f1e Compare November 12, 2024 04:31
Comment on lines +1386 to +1394
l1.stop()

# We can do the entire thing non-interactive!
os.remove(hsm_path)
subprocess.check_output(["tools/hsmtool",
"generatehsm", hsm_path,
"en",
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"])
assert open(hsm_path, "rb").read().hex() == "5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was more happy to have a separate test, but anyway 😄

Copy link
Contributor

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 40e2f1e

Copy link
Contributor

@niftynei niftynei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

tools/hsmtool.c Outdated
@@ -43,7 +43,7 @@ static void show_usage(const char *progname)
"<path/to/hsm_secret>\n");
printf(" - guesstoremote <P2WPKH address> <node id> <tries> "
"<path/to/hsm_secret>\n");
printf(" - generatehsm <path/to/new/hsm_secret>\n");
printf(" - generatehsm <path/to/new/hsm_secret> [<language_id> <word list> [<password>]");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missing last ] on documentation and additional \n

should be:
[<language_id> <word list> [<password>]]\n

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edit: pushed up fix for this!

rustyrussell and others added 3 commits November 13, 2024 17:52
Based on the patch by bstin <barry.github@capsmx.com>, which added a separate command,
this simply extends "generatehsm" to allow more options.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: hsmtool: generatehsm can run non-interactive, taking options on the cmdline.
@rustyrussell
Copy link
Contributor

Rebased...

@rustyrussell rustyrussell merged commit e66653f into ElementsProject:master Nov 15, 2024
19 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants