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:
parent
da91e70d3e
commit
55f0515d20
|
@ -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,
|
static int dumponchaindescriptors(const char *hsm_secret_path, const char *old_passwd UNUSED,
|
||||||
const bool is_testnet)
|
const u32 version)
|
||||||
{
|
{
|
||||||
struct secret hsm_secret;
|
struct secret hsm_secret;
|
||||||
u8 bip32_seed[BIP32_ENTROPY_LEN_256];
|
u8 bip32_seed[BIP32_ENTROPY_LEN_256];
|
||||||
u32 salt = 0;
|
u32 salt = 0;
|
||||||
u32 version = is_testnet ?
|
|
||||||
BIP32_VER_TEST_PRIVATE : BIP32_VER_MAIN_PRIVATE;
|
|
||||||
struct ext_key master_extkey;
|
struct ext_key master_extkey;
|
||||||
char *enc_xpub, *descriptor;
|
char *enc_xpub, *descriptor;
|
||||||
struct descriptor_checksum checksum;
|
struct descriptor_checksum checksum;
|
||||||
|
@ -715,7 +713,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (streq(method, "dumponchaindescriptors")) {
|
if (streq(method, "dumponchaindescriptors")) {
|
||||||
char *net = NULL;
|
char *net = NULL;
|
||||||
bool is_testnet;
|
u32 version;
|
||||||
|
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
show_usage(argv[0]);
|
show_usage(argv[0]);
|
||||||
|
@ -723,16 +721,16 @@ int main(int argc, char *argv[])
|
||||||
if (argc > 3)
|
if (argc > 3)
|
||||||
net = argv[3];
|
net = argv[3];
|
||||||
|
|
||||||
if (net && streq(net, "testnet"))
|
if (net && (streq(net, "testnet") || streq(net, "signet")))
|
||||||
is_testnet = true;
|
version = BIP32_VER_TEST_PRIVATE;
|
||||||
else if (net && !streq(net, "bitcoin"))
|
else if (net && !streq(net, "bitcoin"))
|
||||||
errx(ERROR_USAGE, "Network '%s' not supported."
|
errx(ERROR_USAGE, "Network '%s' not supported."
|
||||||
" Supported networks: bitcoin (default),"
|
" Supported networks: bitcoin (default),"
|
||||||
" testnet", net);
|
" testnet and signet", net);
|
||||||
else
|
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")) {
|
if (streq(method, "checkhsm")) {
|
||||||
|
|
Loading…
Reference in New Issue