mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-23 15:04:19 +01:00
developer: add --dev-force-privkey to allow setting a specific node key.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
neil saitug
parent
fb6870c139
commit
07adb7efd6
@@ -94,7 +94,13 @@ void hsm_init(struct lightningd *ld)
|
||||
|
||||
ld->hsm_fd = fds[0];
|
||||
if (!wire_sync_write(ld->hsm_fd, towire_hsm_init(tmpctx,
|
||||
&ld->topology->bitcoind->chainparams->bip32_key_version)))
|
||||
&ld->topology->bitcoind->chainparams->bip32_key_version,
|
||||
#if DEVELOPER
|
||||
ld->dev_force_privkey
|
||||
#else
|
||||
NULL
|
||||
#endif
|
||||
)))
|
||||
err(1, "Writing init msg to hsm");
|
||||
|
||||
ld->wallet->bip32_base = tal(ld->wallet, struct ext_key);
|
||||
|
||||
@@ -118,6 +118,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
||||
ld->dev_subdaemon_fail = false;
|
||||
ld->dev_allow_localhost = false;
|
||||
ld->dev_gossip_time = 0;
|
||||
ld->dev_force_privkey = NULL;
|
||||
#endif
|
||||
|
||||
/*~ These are CCAN lists: an embedded double-linked list. It's not
|
||||
|
||||
@@ -205,6 +205,9 @@ struct lightningd {
|
||||
|
||||
/* Things we've marked as not leaking. */
|
||||
const void **notleaks;
|
||||
|
||||
/* This is the forced private key for the node. */
|
||||
struct privkey *dev_force_privkey;
|
||||
#endif /* DEVELOPER */
|
||||
|
||||
/* tor support */
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <ccan/opt/private.h>
|
||||
#include <ccan/read_write_all/read_write_all.h>
|
||||
#include <ccan/short_types/short_types.h>
|
||||
#include <ccan/str/hex/hex.h>
|
||||
#include <ccan/tal/grab_file/grab_file.h>
|
||||
#include <ccan/tal/path/path.h>
|
||||
#include <ccan/tal/str/str.h>
|
||||
@@ -438,6 +439,16 @@ static char *opt_subprocess_debug(const char *optarg, struct lightningd *ld)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *opt_force_privkey(const char *optarg, struct lightningd *ld)
|
||||
{
|
||||
tal_free(ld->dev_force_privkey);
|
||||
ld->dev_force_privkey = tal(ld, struct privkey);
|
||||
if (!hex_decode(optarg, strlen(optarg),
|
||||
ld->dev_force_privkey, sizeof(*ld->dev_force_privkey)))
|
||||
return tal_fmt(NULL, "Unable to parse privkey '%s'", optarg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void dev_register_opts(struct lightningd *ld)
|
||||
{
|
||||
opt_register_noarg("--dev-no-reconnect", opt_set_invbool,
|
||||
@@ -474,6 +485,8 @@ static void dev_register_opts(struct lightningd *ld)
|
||||
opt_register_arg("--dev-gossip-time", opt_set_u32, opt_show_u32,
|
||||
&ld->dev_gossip_time,
|
||||
"UNIX time to override gossipd to use.");
|
||||
opt_register_arg("--dev-force-privkey", opt_force_privkey, NULL, ld,
|
||||
"Force HSM to use this as node private key");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user