Browse Source

hsm: Remove special case of hsmfd_ecdh, replaced with client and cap

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
parent
commit
6ce264d3a2
  1. 25
      hsmd/hsm.c
  2. 8
      hsmd/hsm_wire.csv
  3. 6
      lightningd/gossip_control.c

25
hsmd/hsm.c

@ -498,27 +498,6 @@ static void pass_client_hsmfd(struct daemon_conn *master, const u8 *msg)
daemon_conn_send_fd(master, fds[1]);
}
static void pass_hsmfd_ecdh(struct daemon_conn *master, const u8 *msg)
{
int fds[2];
struct pubkey id;
if (!fromwire_hsmctl_hsmfd_ecdh(msg, NULL))
master_badmsg(WIRE_HSMCTL_HSMFD_ECDH, msg);
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) != 0)
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"creating fds: %s", strerror(errno));
/* This is gossipd, so we use our own id */
node_key(NULL, &id);
new_client(master, &id, HSM_CAP_ECDH, handle_ecdh, fds[0]);
daemon_conn_send(master,
take(towire_hsmctl_hsmfd_ecdh_fd_reply(master)));
daemon_conn_send_fd(master, fds[1]);
}
/* Reply to an incoming request for an HSMFD for a channeld. */
static void pass_hsmfd_channeld(struct daemon_conn *master, const u8 *msg)
{
@ -745,9 +724,6 @@ static struct io_plan *control_received_req(struct io_conn *conn,
case WIRE_HSMCTL_CLIENT_HSMFD:
pass_client_hsmfd(master, master->msg_in);
return daemon_conn_read_next(conn, master);
case WIRE_HSMCTL_HSMFD_ECDH:
pass_hsmfd_ecdh(master, master->msg_in);
return daemon_conn_read_next(conn, master);
case WIRE_HSMCTL_HSMFD_CHANNELD:
pass_hsmfd_channeld(master, master->msg_in);
return daemon_conn_read_next(conn, master);
@ -769,7 +745,6 @@ static struct io_plan *control_received_req(struct io_conn *conn,
case WIRE_HSMCTL_INIT_REPLY:
case WIRE_HSMCTL_CLIENT_HSMFD_REPLY:
case WIRE_HSMCTL_HSMFD_ECDH_FD_REPLY:
case WIRE_HSMCTL_HSMFD_CHANNELD_REPLY:
case WIRE_HSMCTL_SIGN_FUNDING_REPLY:
case WIRE_HSMCTL_SIGN_WITHDRAWAL_REPLY:

8
hsmd/hsm_wire.csv

@ -22,12 +22,6 @@ hsmctl_client_hsmfd,,capabilities,u64
# No content, just an fd.
hsmctl_client_hsmfd_reply,109
# ECDH returns an fd (for gossipd to do handshake)
hsmctl_hsmfd_ecdh,3
# No contents, just an fd.
hsmctl_hsmfd_ecdh_fd_reply,103
# Return signature for a funding tx.
#include <common/utxo.h>
# FIXME: This should also take their commit sig & details, to verify.
@ -44,7 +38,7 @@ hsmctl_sign_funding_reply,104
hsmctl_sign_funding_reply,,num_sigs,u16
hsmctl_sign_funding_reply,,sig,num_sigs*secp256k1_ecdsa_signature
# Request a client socket for a `channeld`, allows signing announcements
# Request a client socket for a `channeld`, allows signing announcements
hsmctl_hsmfd_channeld,5
hsmctl_hsmfd_channeld,,id,struct pubkey

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

6
lightningd/gossip_control.c

@ -10,6 +10,7 @@
#include <common/utils.h>
#include <errno.h>
#include <gossipd/gen_gossip_wire.h>
#include <hsmd/capabilities.h>
#include <hsmd/gen_hsm_wire.h>
#include <inttypes.h>
#include <lightningd/gossip_msg.h>
@ -101,13 +102,14 @@ void gossip_init(struct lightningd *ld)
tal_t *tmpctx = tal_tmpctx(ld);
u8 *msg;
int hsmfd;
u64 capabilities = HSM_CAP_ECDH | HSM_CAP_SIGN_GOSSIP;
msg = towire_hsmctl_hsmfd_ecdh(tmpctx);
msg = towire_hsmctl_client_hsmfd(tmpctx, &ld->id, capabilities);
if (!wire_sync_write(ld->hsm_fd, msg))
fatal("Could not write to HSM: %s", strerror(errno));
msg = hsm_sync_read(tmpctx, ld);
if (!fromwire_hsmctl_hsmfd_ecdh_fd_reply(msg, NULL))
if (!fromwire_hsmctl_client_hsmfd_reply(msg, NULL))
fatal("Malformed hsmfd response: %s", tal_hex(msg, msg));
hsmfd = fdpass_recv(ld->hsm_fd);

Loading…
Cancel
Save