diff --git a/hsmd/hsm.c b/hsmd/hsm.c index 22a4f9bb2..96e02f4df 100644 --- a/hsmd/hsm.c +++ b/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; diff --git a/hsmd/hsm_client_wire_csv b/hsmd/hsm_client_wire_csv index ce47fa51c..4fdec449c 100644 --- a/hsmd/hsm_client_wire_csv +++ b/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. diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index 2b55ed1ab..6c14977ca 100644 --- a/lightningd/channel_control.c +++ b/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)); diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index 5137f55b5..d6b4d15a4 100644 --- a/lightningd/gossip_control.c +++ b/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));