diff --git a/tools/Makefile b/tools/Makefile index 52384caf0..aa6510eb0 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -18,7 +18,7 @@ tools/headerversions: $(FORCE) tools/headerversions.o libccan.a tools/headerversions.o: ccan/config.h tools/check-bolt: tools/check-bolt.o $(TOOLS_COMMON_OBJS) -tools/hsmtool: tools/hsmtool.o $(TOOLS_COMMON_OBJS) $(BITCOIN_OBJS) common/amount.o common/autodata.o common/bech32.o common/bigsize.o common/configdir.o common/configvar.o common/derive_basepoints.o common/descriptor_checksum.o common/hsm_encryption.o common/node_id.o common/type_to_string.o common/version.o wire/fromwire.o wire/towire.o +tools/hsmtool: tools/hsmtool.o $(TOOLS_COMMON_OBJS) $(BITCOIN_OBJS) common/amount.o common/autodata.o common/bech32.o common/bigsize.o common/codex32.o common/configdir.o common/configvar.o common/derive_basepoints.o common/descriptor_checksum.o common/hsm_encryption.o common/node_id.o common/type_to_string.o common/version.o wire/fromwire.o wire/towire.o tools/lightning-hsmtool: tools/hsmtool cp $< $@ diff --git a/tools/hsmtool.c b/tools/hsmtool.c index 7575eab2d..b4e1395db 100644 --- a/tools/hsmtool.c +++ b/tools/hsmtool.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,7 @@ static void show_usage(const char *progname) printf(" - checkhsm \n"); printf(" - dumponchaindescriptors [network]\n"); printf(" - makerune \n"); + printf(" - getcodexsecret \n"); exit(0); } @@ -244,6 +246,17 @@ static int decrypt_hsm(const char *hsm_secret_path) return 0; } +static int make_codexsecret(const char *hsm_secret_path, + const char *id, + const u32 threshold) +{ + struct secret hsm_secret; + get_hsm_secret(&hsm_secret, hsm_secret_path); + printf("Codex32 Secret of your hsm_secret is: %s\n", + codex32_secret_encode(tmpctx, id, threshold, hsm_secret.data, 32)); + return 0; +} + static int encrypt_hsm(const char *hsm_secret_path) { int fd; @@ -745,5 +758,10 @@ int main(int argc, char *argv[]) return make_rune(argv[2]); } + if(streq(method, "getcodexsecret")) { + if (argc < 3) + show_usage(argv[0]); + return make_codexsecret(argv[2], argv[3], atol(argv[4])); + } show_usage(argv[0]); }