mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
developer: add --dev-force-channel-secrets.
We don't have this on a per-channel basis (yet), but it's sufficient for testing now. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
neil saitug
parent
5879f6b4e0
commit
1e6eabf018
@@ -97,9 +97,11 @@ void hsm_init(struct lightningd *ld)
|
||||
&ld->topology->bitcoind->chainparams->bip32_key_version,
|
||||
#if DEVELOPER
|
||||
ld->dev_force_privkey,
|
||||
ld->dev_force_bip32_seed
|
||||
ld->dev_force_bip32_seed,
|
||||
ld->dev_force_channel_secrets,
|
||||
ld->dev_force_channel_secrets_shaseed
|
||||
#else
|
||||
NULL, NULL
|
||||
NULL, NULL, NULL, NULL
|
||||
#endif
|
||||
)))
|
||||
err(1, "Writing init msg to hsm");
|
||||
|
||||
@@ -120,6 +120,8 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
||||
ld->dev_gossip_time = 0;
|
||||
ld->dev_force_privkey = NULL;
|
||||
ld->dev_force_bip32_seed = NULL;
|
||||
ld->dev_force_channel_secrets = NULL;
|
||||
ld->dev_force_channel_secrets_shaseed = NULL;
|
||||
#endif
|
||||
|
||||
/*~ These are CCAN lists: an embedded double-linked list. It's not
|
||||
|
||||
@@ -211,6 +211,10 @@ struct lightningd {
|
||||
|
||||
/* This is the forced bip32 seed for the node. */
|
||||
struct secret *dev_force_bip32_seed;
|
||||
|
||||
/* These are the forced channel secrets for the node. */
|
||||
struct secrets *dev_force_channel_secrets;
|
||||
struct sha256 *dev_force_channel_secrets_shaseed;
|
||||
#endif /* DEVELOPER */
|
||||
|
||||
/* tor support */
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <ccan/tal/path/path.h>
|
||||
#include <ccan/tal/str/str.h>
|
||||
#include <common/configdir.h>
|
||||
#include <common/derive_basepoints.h>
|
||||
#include <common/json_command.h>
|
||||
#include <common/jsonrpc_errors.h>
|
||||
#include <common/memleak.h>
|
||||
@@ -460,6 +461,42 @@ static char *opt_force_bip32_seed(const char *optarg, struct lightningd *ld)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *opt_force_channel_secrets(const char *optarg,
|
||||
struct lightningd *ld)
|
||||
{
|
||||
char **strs;
|
||||
tal_free(ld->dev_force_channel_secrets);
|
||||
tal_free(ld->dev_force_channel_secrets_shaseed);
|
||||
ld->dev_force_channel_secrets = tal(ld, struct secrets);
|
||||
ld->dev_force_channel_secrets_shaseed = tal(ld, struct sha256);
|
||||
|
||||
strs = tal_strsplit(tmpctx, optarg, "/", STR_EMPTY_OK);
|
||||
if (tal_count(strs) != 7) /* Last is NULL */
|
||||
return "Expected 6 hex secrets separated by /";
|
||||
|
||||
if (!hex_decode(strs[0], strlen(strs[0]),
|
||||
&ld->dev_force_channel_secrets->funding_privkey,
|
||||
sizeof(ld->dev_force_channel_secrets->funding_privkey))
|
||||
|| !hex_decode(strs[1], strlen(strs[1]),
|
||||
&ld->dev_force_channel_secrets->revocation_basepoint_secret,
|
||||
sizeof(ld->dev_force_channel_secrets->revocation_basepoint_secret))
|
||||
|| !hex_decode(strs[2], strlen(strs[2]),
|
||||
&ld->dev_force_channel_secrets->payment_basepoint_secret,
|
||||
sizeof(ld->dev_force_channel_secrets->payment_basepoint_secret))
|
||||
|| !hex_decode(strs[3], strlen(strs[3]),
|
||||
&ld->dev_force_channel_secrets->delayed_payment_basepoint_secret,
|
||||
sizeof(ld->dev_force_channel_secrets->delayed_payment_basepoint_secret))
|
||||
|| !hex_decode(strs[4], strlen(strs[4]),
|
||||
&ld->dev_force_channel_secrets->htlc_basepoint_secret,
|
||||
sizeof(ld->dev_force_channel_secrets->htlc_basepoint_secret))
|
||||
|| !hex_decode(strs[5], strlen(strs[5]),
|
||||
ld->dev_force_channel_secrets_shaseed,
|
||||
sizeof(*ld->dev_force_channel_secrets_shaseed)))
|
||||
return "Expected 6 hex secrets separated by /";
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void dev_register_opts(struct lightningd *ld)
|
||||
{
|
||||
opt_register_noarg("--dev-no-reconnect", opt_set_invbool,
|
||||
@@ -500,6 +537,8 @@ static void dev_register_opts(struct lightningd *ld)
|
||||
"Force HSM to use this as node private key");
|
||||
opt_register_arg("--dev-force-bip32-seed", opt_force_bip32_seed, NULL, ld,
|
||||
"Force HSM to use this as bip32 seed");
|
||||
opt_register_arg("--dev-force-channel-secrets", opt_force_channel_secrets, NULL, ld,
|
||||
"Force HSM to use these for all per-channel secrets");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user