Makefile: Install tools/hsmtool as lightning-hsmtool.

Changelog-Added: We now install `lightning-hsmtool` for your `hsm_secret` needs.

See: https://github.com/ElementsProject/lightning/issues/3717#issuecomment-644844594

It seems reasonable to add this to the standard install, and to document it properly as well, hopefully we can fill in the documentation better later on.
This commit is contained in:
ZmnSCPxj jxPCSnmZ
2020-06-29 14:28:46 +08:00
committed by Rusty Russell
parent 7b899da801
commit 5d720536e2
12 changed files with 185 additions and 12 deletions

View File

@@ -16,11 +16,14 @@ tools/check-bolt: tools/check-bolt.o $(CCAN_OBJS) $(TOOLS_COMMON_OBJS)
tools/hsmtool: tools/hsmtool.o $(CCAN_OBJS) $(TOOLS_COMMON_OBJS) $(BITCOIN_OBJS) common/amount.o common/bech32.o common/bigsize.o common/derive_basepoints.o common/node_id.o common/type_to_string.o wire/fromwire.o wire/towire.o
tools/lightning-hsmtool: tools/hsmtool
cp $< $@
clean: tools-clean
tools-clean:
$(RM) tools/check-bolt tools/*.o
$(RM) tools/headerversions
$(RM) $(TOOLS_OBJ) $(TOOLS)
$(RM) $(TOOLS_OBJ) $(TOOLS) tools/lightning-hsmtool
include tools/test/Makefile

View File

@@ -23,9 +23,9 @@
#define ERROR_LIBWALLY 4
#define ERROR_KEYDERIV 5
static void show_usage(void)
static void show_usage(const char *progname)
{
printf("./hsmtool <method> [arguments]\n");
printf("%s <method> [arguments]\n", progname);
printf("methods:\n");
printf(" - decrypt <path/to/hsm_secret> <password>\n");
printf(" - encrypt <path/to/hsm_secret> <password>\n");
@@ -377,24 +377,24 @@ int main(int argc, char *argv[])
method = argc > 1 ? argv[1] : NULL;
if (!method)
show_usage();
show_usage(argv[0]);
if (streq(method, "decrypt")) {
if (argc < 4)
show_usage();
show_usage(argv[0]);
return decrypt_hsm(argv[2], argv[3]);
}
if (streq(method, "encrypt")) {
if (argc < 4)
show_usage();
show_usage(argv[0]);
return encrypt_hsm(argv[2], argv[3]);
}
if (streq(method, "dumpcommitments")) {
/* node_id channel_id depth hsm_secret ?password? */
if (argc < 7)
show_usage();
show_usage(argv[0]);
struct node_id node_id;
if (!node_id_from_hexstr(argv[2], strlen(argv[2]), &node_id))
err(ERROR_USAGE, "Bad node id");
@@ -405,7 +405,7 @@ int main(int argc, char *argv[])
if (streq(method, "guesstoremote")) {
/* address node_id depth hsm_secret ?password? */
if (argc < 7)
show_usage();
show_usage(argv[0]);
struct node_id node_id;
if (!node_id_from_hexstr(argv[3], strlen(argv[3]), &node_id))
errx(ERROR_USAGE, "Bad node id");
@@ -413,5 +413,5 @@ int main(int argc, char *argv[])
argv[5], argv[6]);
}
show_usage();
show_usage(argv[0]);
}