mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-10 00:24:19 +01:00
tools/hsmtool: Add getcodexsecret to get the hsm_secret in bip93
This commit is contained in:
@@ -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 $< $@
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <ccan/tal/path/path.h>
|
||||
#include <ccan/tal/str/str.h>
|
||||
#include <common/bech32.h>
|
||||
#include <common/codex32.h>
|
||||
#include <common/configdir.h>
|
||||
#include <common/derive_basepoints.h>
|
||||
#include <common/descriptor_checksum.h>
|
||||
@@ -44,6 +45,7 @@ static void show_usage(const char *progname)
|
||||
printf(" - checkhsm <path/to/new/hsm_secret>\n");
|
||||
printf(" - dumponchaindescriptors <path/to/hsm_secret> [network]\n");
|
||||
printf(" - makerune <path/to/hsm_secret>\n");
|
||||
printf(" - getcodexsecret <path/to/hsm_secret> <id> <threshold>\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]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user