mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +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
@@ -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