|
|
@ -75,6 +75,8 @@ static struct bip32_key_version bip32_key_version; |
|
|
|
#if DEVELOPER |
|
|
|
/* If they specify --dev-force-privkey it ends up in here. */ |
|
|
|
static struct privkey *dev_force_privkey; |
|
|
|
/* If they specify --dev-force-bip32-seed it ends up in here. */ |
|
|
|
static struct secret *dev_force_bip32_seed; |
|
|
|
#endif |
|
|
|
|
|
|
|
/*~ We keep track of clients, but there's not much to keep. */ |
|
|
@ -403,6 +405,18 @@ static void populate_secretstuff(void) |
|
|
|
bip32_key_version.bip32_privkey_version, |
|
|
|
0, &master_extkey) != WALLY_OK); |
|
|
|
|
|
|
|
#if DEVELOPER |
|
|
|
/* In DEVELOPER mode, we can override with --dev-force-bip32-seed */ |
|
|
|
if (dev_force_bip32_seed) { |
|
|
|
if (bip32_key_from_seed(dev_force_bip32_seed->data, |
|
|
|
sizeof(dev_force_bip32_seed->data), |
|
|
|
bip32_key_version.bip32_privkey_version, |
|
|
|
0, &master_extkey) != WALLY_OK) |
|
|
|
status_failed(STATUS_FAIL_INTERNAL_ERROR, |
|
|
|
"Can't derive bip32 master key"); |
|
|
|
} |
|
|
|
#endif /* DEVELOPER */ |
|
|
|
|
|
|
|
/* BIP 32:
|
|
|
|
* |
|
|
|
* The default wallet layout |
|
|
@ -557,6 +571,7 @@ static struct io_plan *init_hsm(struct io_conn *conn, |
|
|
|
struct node_id node_id; |
|
|
|
struct pubkey key; |
|
|
|
struct privkey *privkey; |
|
|
|
struct secret *seed; |
|
|
|
|
|
|
|
/* This must be lightningd. */ |
|
|
|
assert(is_lightningd(c)); |
|
|
@ -565,11 +580,13 @@ static struct io_plan *init_hsm(struct io_conn *conn, |
|
|
|
* definitions in hsm_client_wire.csv. The format of those files is |
|
|
|
* an extension of the simple comma-separated format output by the |
|
|
|
* BOLT tools/extract-formats.py tool. */ |
|
|
|
if (!fromwire_hsm_init(NULL, msg_in, &bip32_key_version, &privkey)) |
|
|
|
if (!fromwire_hsm_init(NULL, msg_in, &bip32_key_version, |
|
|
|
&privkey, &seed)) |
|
|
|
return bad_req(conn, c, msg_in); |
|
|
|
|
|
|
|
#if DEVELOPER |
|
|
|
dev_force_privkey = privkey; |
|
|
|
dev_force_bip32_seed = seed; |
|
|
|
#endif |
|
|
|
maybe_create_new_hsm(); |
|
|
|
load_hsm(); |
|
|
@ -1622,6 +1639,7 @@ static struct io_plan *handle_memleak(struct io_conn *conn, |
|
|
|
memleak_scan_region(memtable, status_conn, tal_bytelen(status_conn)); |
|
|
|
|
|
|
|
memleak_scan_region(memtable, dev_force_privkey, 0); |
|
|
|
memleak_scan_region(memtable, dev_force_bip32_seed, 0); |
|
|
|
|
|
|
|
found_leak = dump_memleak(memtable); |
|
|
|
reply = towire_hsm_dev_memleak_reply(NULL, found_leak); |
|
|
|