hsmd: Tell hsmd which chain we are working on

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2019-07-31 13:10:20 +02:00 committed by Rusty Russell
parent 15e73e3dc3
commit c5ac6c7b1f
3 changed files with 7 additions and 2 deletions

View File

@ -9,6 +9,7 @@ msgdata,hsmstatus_client_bad_request,msg,u8,len
# Start the HSM.
msgtype,hsm_init,11
msgdata,hsm_init,bip32_key_version,bip32_key_version,
msgdata,hsm_init,chain_hash,bitcoin_blkid,
msgdata,hsm_init,dev_force_privkey,?privkey,
msgdata,hsm_init,dev_force_bip32_seed,?secret,
msgdata,hsm_init,dev_force_channel_secrets,?secrets,

1 # Clients should not give a bad request but not the HSM's decision to crash.
9 msgtype,hsm_init,11
10 msgdata,hsm_init,bip32_key_version,bip32_key_version,
11 msgdata,hsm_init,dev_force_privkey,?privkey, msgdata,hsm_init,chain_hash,bitcoin_blkid,
12 msgdata,hsm_init,dev_force_privkey,?privkey,
13 msgdata,hsm_init,dev_force_bip32_seed,?secret,
14 msgdata,hsm_init,dev_force_channel_secrets,?secrets,
15 msgdata,hsm_init,dev_force_channel_secrets_shaseed,?sha256,

View File

@ -574,6 +574,7 @@ static struct io_plan *init_hsm(struct io_conn *conn,
struct secret *seed;
struct secrets *secrets;
struct sha256 *shaseed;
struct bitcoin_blkid chain_hash;
/* This must be lightningd. */
assert(is_lightningd(c));
@ -582,7 +583,7 @@ 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,
if (!fromwire_hsm_init(NULL, msg_in, &bip32_key_version, &chain_hash,
&privkey, &seed, &secrets, &shaseed))
return bad_req(conn, c, msg_in);

View File

@ -80,6 +80,8 @@ void hsm_init(struct lightningd *ld)
{
u8 *msg;
int fds[2];
struct bitcoin_blkid chainhash;
chainhash = get_chainparams(ld)->genesis_blockhash;
/* We actually send requests synchronously: only status is async. */
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) != 0)
@ -94,7 +96,8 @@ 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,
&chainhash,
#if DEVELOPER
ld->dev_force_privkey,
ld->dev_force_bip32_seed,