hsmtool: Add support for Signet network

This commit addresses a limitation in our CLI argument
checking for the hsmtool. With this update, we introduce
support for the Signet network.

In addition, it introduce a code semplification by directly passing the
BIP32 version instead of using network testnet flag. This change
improves code readability and minimaze code changes
to support other networks.

Link: https://github.com/ElementsProject/lightning/issues/6371
Reported-by: @grubles
Changelog-Fixes: hsmtool: Add support for Signet network
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
Vincenzo Palazzo 2023-06-30 21:56:16 +02:00
parent da91e70d3e
commit 55f0515d20
1 changed files with 7 additions and 9 deletions

View File

@ -529,13 +529,11 @@ static int generate_hsm(const char *hsm_secret_path)
}
static int dumponchaindescriptors(const char *hsm_secret_path, const char *old_passwd UNUSED,
const bool is_testnet)
const u32 version)
{
struct secret hsm_secret;
u8 bip32_seed[BIP32_ENTROPY_LEN_256];
u32 salt = 0;
u32 version = is_testnet ?
BIP32_VER_TEST_PRIVATE : BIP32_VER_MAIN_PRIVATE;
struct ext_key master_extkey;
char *enc_xpub, *descriptor;
struct descriptor_checksum checksum;
@ -715,7 +713,7 @@ int main(int argc, char *argv[])
if (streq(method, "dumponchaindescriptors")) {
char *net = NULL;
bool is_testnet;
u32 version;
if (argc < 3)
show_usage(argv[0]);
@ -723,16 +721,16 @@ int main(int argc, char *argv[])
if (argc > 3)
net = argv[3];
if (net && streq(net, "testnet"))
is_testnet = true;
if (net && (streq(net, "testnet") || streq(net, "signet")))
version = BIP32_VER_TEST_PRIVATE;
else if (net && !streq(net, "bitcoin"))
errx(ERROR_USAGE, "Network '%s' not supported."
" Supported networks: bitcoin (default),"
" testnet", net);
" testnet and signet", net);
else
is_testnet = false;
version = BIP32_VER_MAIN_PRIVATE;
return dumponchaindescriptors(argv[2], NULL, is_testnet);
return dumponchaindescriptors(argv[2], NULL, version);
}
if (streq(method, "checkhsm")) {