Browse Source

hsmd: take dbid for client.

We need this later, to generate its seed.  When we switch to lnd's key system,
we'll only need this, and not peerid.

Note also that the peerid is not just for messages any more, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
f9e5dc7ee8
  1. 11
      hsmd/hsm.c
  2. 4
      hsmd/hsm_client_wire_csv
  3. 4
      lightningd/channel_control.c
  4. 2
      lightningd/gossip_control.c

11
hsmd/hsm.c

@ -52,6 +52,7 @@ struct client {
struct daemon_conn *master;
struct pubkey id;
u64 dbid;
struct io_plan *(*handle)(struct io_conn *, struct daemon_conn *);
/* What is this client allowed to ask for? */
@ -90,6 +91,7 @@ static void node_key(struct privkey *node_privkey, struct pubkey *node_id)
static struct client *new_client(struct daemon_conn *master,
const struct pubkey *id,
u64 dbid,
const u64 capabilities,
struct io_plan *(*handle)(struct io_conn *,
struct daemon_conn *),
@ -102,6 +104,7 @@ static struct client *new_client(struct daemon_conn *master,
} else {
memset(&c->id, 0, sizeof(c->id));
}
c->dbid = dbid;
c->handle = handle;
c->master = master;
@ -529,16 +532,16 @@ static void init_hsm(struct daemon_conn *master, const u8 *msg)
static void pass_client_hsmfd(struct daemon_conn *master, const u8 *msg)
{
int fds[2];
u64 capabilities;
u64 dbid, capabilities;
struct pubkey id;
if (!fromwire_hsm_client_hsmfd(msg, &id, &capabilities))
if (!fromwire_hsm_client_hsmfd(msg, &id, &dbid, &capabilities))
master_badmsg(WIRE_HSM_CLIENT_HSMFD, msg);
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) != 0)
status_failed(STATUS_FAIL_INTERNAL_ERROR, "creating fds: %s", strerror(errno));
new_client(master, &id, capabilities, handle_client, fds[0]);
new_client(master, &id, dbid, capabilities, handle_client, fds[0]);
daemon_conn_send(master,
take(towire_hsm_client_hsmfd_reply(NULL)));
daemon_conn_send_fd(master, fds[1]);
@ -829,7 +832,7 @@ int main(int argc, char *argv[])
subdaemon_setup(argc, argv);
client = new_client(NULL, NULL, HSM_CAP_MASTER | HSM_CAP_SIGN_GOSSIP, handle_client, STDIN_FILENO);
client = new_client(NULL, NULL, 0, HSM_CAP_MASTER | HSM_CAP_SIGN_GOSSIP, handle_client, STDIN_FILENO);
/* We're our own master! */
client->master = &client->dc;

4
hsmd/hsm_client_wire_csv

@ -15,7 +15,9 @@ hsm_init_reply,,bip32,struct ext_key
# Get a new HSM FD, with the specified capabilities
hsm_client_hsmfd,9
hsm_client_hsmfd,,pubkey,struct pubkey # Which identity to report for requests
hsm_client_hsmfd,,pubkey,struct pubkey # Which identity to use for requests
# Database id for this client, if any.
hsm_client_hsmfd,,dbid,u64
hsm_client_hsmfd,,capabilities,u64
# No content, just an fd.

4
lightningd/channel_control.c

@ -193,7 +193,9 @@ bool peer_start_channeld(struct channel *channel,
const struct config *cfg = &ld->config;
bool reached_announce_depth;
msg = towire_hsm_client_hsmfd(tmpctx, &channel->peer->id, HSM_CAP_SIGN_GOSSIP | HSM_CAP_ECDH);
msg = towire_hsm_client_hsmfd(tmpctx, &channel->peer->id,
channel->dbid,
HSM_CAP_SIGN_GOSSIP | HSM_CAP_ECDH);
if (!wire_sync_write(ld->hsm_fd, take(msg)))
fatal("Could not write to HSM: %s", strerror(errno));

2
lightningd/gossip_control.c

@ -211,7 +211,7 @@ void gossip_init(struct lightningd *ld)
allow_localhost = true;
#endif
msg = towire_hsm_client_hsmfd(tmpctx, &ld->id, capabilities);
msg = towire_hsm_client_hsmfd(tmpctx, &ld->id, 0, capabilities);
if (!wire_sync_write(ld->hsm_fd, msg))
fatal("Could not write to HSM: %s", strerror(errno));

Loading…
Cancel
Save