Browse Source

hsmd: Tell hsmd which chain we are working on

Signed-off-by: Christian Decker <decker.christian@gmail.com>
pull/2938/head
Christian Decker 5 years ago
committed by Rusty Russell
parent
commit
c5ac6c7b1f
  1. 1
      hsmd/hsm_wire.csv
  2. 3
      hsmd/hsmd.c
  3. 5
      lightningd/hsm_control.c

1
hsmd/hsm_wire.csv

@ -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,

Can't render this file because it has a wrong number of fields in line 2.

3
hsmd/hsmd.c

@ -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);

5
lightningd/hsm_control.c

@ -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,

Loading…
Cancel
Save