Browse Source

hsmd: remove hsmd/client.c

It was only used by handshake.c.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
json-streaming
Rusty Russell 6 years ago
committed by Christian Decker
parent
commit
8f1f1784b3
  1. 1
      channeld/Makefile
  2. 1
      closingd/Makefile
  3. 1
      connectd/Makefile
  4. 17
      connectd/connectd.c
  5. 1
      connectd/handshake.c
  6. 2
      connectd/handshake.h
  7. 1
      gossipd/Makefile
  8. 2
      gossipd/gossipd.c
  9. 28
      hsmd/Makefile
  10. 29
      hsmd/client.c
  11. 17
      hsmd/client.h
  12. 1
      hsmd/hsmd.c
  13. 5
      lightningd/Makefile
  14. 3
      onchaind/Makefile
  15. 1
      openingd/Makefile

1
channeld/Makefile

@ -72,6 +72,7 @@ CHANNELD_COMMON_OBJS := \
common/wire_error.o \
common/wireaddr.o \
gossipd/gen_gossip_wire.o \
hsmd/gen_hsm_client_wire.o \
lightningd/gossip_msg.o \
wire/fromwire.o \
wire/towire.o

1
closingd/Makefile

@ -72,6 +72,7 @@ CLOSINGD_COMMON_OBJS := \
common/wire_error.o \
common/wireaddr.o \
gossipd/gen_gossip_wire.o \
hsmd/gen_hsm_client_wire.o \
lightningd/gossip_msg.o
closingd/gen_closing_wire.h: $(WIRE_GEN) closingd/closing_wire.csv

1
connectd/Makefile

@ -61,7 +61,6 @@ CONNECTD_COMMON_OBJS := \
common/wireaddr.o \
common/wire_error.o \
gossipd/gen_gossip_wire.o \
hsmd/client.o \
hsmd/gen_hsm_client_wire.o \
lightningd/gossip_msg.o \
wire/gen_onion_wire.o

17
connectd/connectd.c

@ -39,7 +39,6 @@
#include <connectd/tor_autoservice.h>
#include <errno.h>
#include <gossipd/gen_gossip_wire.h>
#include <hsmd/client.h>
#include <hsmd/gen_hsm_client_wire.h>
#include <inttypes.h>
#include <lightningd/gossip_msg.h>
@ -1286,6 +1285,21 @@ static struct io_plan *recv_req(struct io_conn *conn, struct daemon_conn *master
t, tal_hex(tmpctx, master->msg_in));
}
/* Helper for handshake.c */
bool hsm_do_ecdh(struct secret *ss, const struct pubkey *point)
{
u8 *req = towire_hsm_ecdh_req(tmpctx, point), *resp;
if (!wire_sync_write(HSM_FD, req))
return false;
resp = wire_sync_read(req, HSM_FD);
if (!resp)
return false;
if (!fromwire_hsm_ecdh_resp(resp, ss))
return false;
return true;
}
#ifndef TESTING
static void master_gone(struct io_conn *unused UNUSED, struct daemon_conn *dc UNUSED)
{
@ -1312,7 +1326,6 @@ int main(int argc, char *argv[])
daemon_conn_init(daemon, &daemon->master, STDIN_FILENO, recv_req,
master_gone);
status_setup_async(&daemon->master);
hsm_setup(HSM_FD);
/* When conn closes, everything is freed. */
tal_steal(daemon->master.conn, daemon);

1
connectd/handshake.c

@ -13,7 +13,6 @@
#include <common/wireaddr.h>
#include <connectd/handshake.h>
#include <errno.h>
#include <hsmd/client.h>
#include <secp256k1.h>
#include <secp256k1_ecdh.h>
#include <sodium/crypto_aead_chacha20poly1305.h>

2
connectd/handshake.h

@ -51,4 +51,6 @@ struct io_plan *responder_handshake_(struct io_conn *conn,
void *cbarg),
void *cbarg);
/* helper which is defined in connect.c */
bool hsm_do_ecdh(struct secret *ss, const struct pubkey *point);
#endif /* LIGHTNING_CONNECTD_HANDSHAKE_H */

1
gossipd/Makefile

@ -61,7 +61,6 @@ GOSSIPD_COMMON_OBJS := \
common/wireaddr.o \
common/wire_error.o \
connectd/gen_connect_gossip_wire.o \
hsmd/client.o \
hsmd/gen_hsm_client_wire.o \
lightningd/gossip_msg.o \
wire/gen_onion_wire.o

2
gossipd/gossipd.c

@ -36,7 +36,6 @@
#include <gossipd/broadcast.h>
#include <gossipd/gen_gossip_wire.h>
#include <gossipd/routing.h>
#include <hsmd/client.h>
#include <hsmd/gen_hsm_client_wire.h>
#include <inttypes.h>
#include <lightningd/gossip_msg.h>
@ -2258,7 +2257,6 @@ int main(int argc, char *argv[])
daemon_conn_init(daemon, &daemon->master, STDIN_FILENO, recv_req,
master_gone);
status_setup_async(&daemon->master);
hsm_setup(HSM_FD);
daemon_conn_init(daemon, &daemon->connectd, CONNECTD_FD, connectd_req,
NULL);

28
hsmd/Makefile

@ -6,16 +6,9 @@ hsmd-wrongdir:
default: hsmd-all
# Clients use this:
LIGHTNINGD_HSM_CLIENT_HEADERS := hsmd/client.h
LIGHTNINGD_HSM_CLIENT_SRC := hsmd/client.c hsmd/gen_hsm_client_wire.c
LIGHTNINGD_HSM_CLIENT_OBJS := $(LIGHTNINGD_HSM_CLIENT_SRC:.c=.o)
# lightningd/hsm needs these:
LIGHTNINGD_HSM_HEADERS := hsmd/gen_hsm_client_wire.h
LIGHTNINGD_HSM_SRC := hsmd/hsmd.c \
$(LIGHTNINGD_HSM_HEADERS:.h=.c)
hsmd/gen_hsm_client_wire.c
LIGHTNINGD_HSM_HEADERS := hsmd/gen_hsm_client_wire.h
LIGHTNINGD_HSM_OBJS := $(LIGHTNINGD_HSM_SRC:.c=.o)
# Common source we use.
@ -40,20 +33,17 @@ HSMD_COMMON_OBJS := \
common/withdraw_tx.o
# For checking
LIGHTNINGD_HSM_ALLSRC_NOGEN := $(filter-out hsmd/gen_%, $(LIGHTNINGD_HSM_CLIENT_SRC) $(LIGHTNINGD_HSM_SRC))
LIGHTNINGD_HSM_ALLHEADERS_NOGEN := $(filter-out hsmd/gen_%, $(LIGHTNINGD_HSM_CLIENT_HEADERS) $(LIGHTNINGD_HSM_HEADERS))
# Add to headers which any object might need.
LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_HSM_HEADERS) $(LIGHTNINGD_HSM_CLIENT_HEADERS)
LIGHTNINGD_HSM_ALLSRC_NOGEN := $(filter-out hsmd/gen_%, $(LIGHTNINGD_HSM_SRC) $(LIGHTNINGD_HSM_SRC))
LIGHTNINGD_HSM_ALLHEADERS_NOGEN := $(filter-out hsmd/gen_%, $(LIGHTNINGD_HSM_HEADERS))
$(LIGHTNINGD_HSM_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS): $(LIGHTNINGD_HEADERS)
$(LIGHTNINGD_HSM_OBJS): $(LIGHTNINGD_HEADERS)
# Make sure these depend on everything.
ALL_OBJS += $(LIGHTNINGD_HSM_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS)
ALL_OBJS += $(LIGHTNINGD_HSM_OBJS)
ALL_PROGRAMS += lightningd/lightning_hsmd
ALL_GEN_HEADERS += $(LIGHTNINGD_HSM_HEADERS)
ALL_GEN_HEADERS += hsmd/gen_hsm_client_wire.h
hsmd-all: lightningd/lightning_hsmd $(LIGHTNINGD_HSM_CLIENT_OBJS)
hsmd-all: lightningd/lightning_hsmd
lightningd/lightning_hsmd: $(LIGHTNINGD_HSM_OBJS) $(LIGHTNINGD_LIB_OBJS) $(HSMD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS)
@ -70,7 +60,7 @@ hsmd/gen_hsm_wire.c: $(WIRE_GEN) hsmd/hsm_wire.csv
$(WIRE_GEN) ${@:.c=.h} hsm_wire_type < hsmd/hsm_wire.csv > $@
check-source: $(LIGHTNINGD_HSM_ALLSRC_NOGEN:%=check-src-include-order/%) $(LIGHTNINGD_HSM_ALLHEADERS_NOGEN:%=check-hdr-include-order/%)
check-source-bolt: $(LIGHTNINGD_HSM_SRC:%=bolt-check/%) $(LIGHTNINGD_HSM_HEADERS:%=bolt-check/%)
check-source-bolt: $(LIGHTNINGD_HSM_SRC:%=bolt-check/%)
check-whitespace: $(LIGHTNINGD_HSM_ALLSRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_HSM_ALLHEADERS_NOGEN:%=check-whitespace/%)

29
hsmd/client.c

@ -1,29 +0,0 @@
#include <hsmd/client.h>
#include <hsmd/gen_hsm_client_wire.h>
#include <wire/wire_sync.h>
static int hsm_fd = -1;
void hsm_setup(int fd)
{
hsm_fd = fd;
}
bool hsm_do_ecdh(struct secret *ss, const struct pubkey *point)
{
u8 *req = towire_hsm_ecdh_req(NULL, point), *resp;
if (!wire_sync_write(hsm_fd, req))
goto fail;
resp = wire_sync_read(req, hsm_fd);
if (!resp)
goto fail;
if (!fromwire_hsm_ecdh_resp(resp, ss))
goto fail;
tal_free(req);
return true;
fail:
tal_free(req);
return false;
}

17
hsmd/client.h

@ -1,17 +0,0 @@
/* API to ask the HSM for things. */
#ifndef LIGHTNING_HSMD_CLIENT_H
#define LIGHTNING_HSMD_CLIENT_H
#include "config.h"
#include <ccan/endian/endian.h>
#include <ccan/short_types/short_types.h>
#include <stdbool.h>
struct pubkey;
struct secret;
/* Setup communication to the HSM */
void hsm_setup(int fd);
/* Do ECDH using this node id secret. */
bool hsm_do_ecdh(struct secret *ss, const struct pubkey *point);
#endif /* LIGHTNING_HSMD_CLIENT_H */

1
hsmd/hsmd.c

@ -31,7 +31,6 @@
#include <errno.h>
#include <fcntl.h>
#include <hsmd/capabilities.h>
#include <hsmd/client.h>
#include <hsmd/gen_hsm_client_wire.h>
#include <inttypes.h>
#include <secp256k1_ecdh.h>

5
lightningd/Makefile

@ -48,7 +48,8 @@ LIGHTNINGD_COMMON_OBJS := \
common/wallet_tx.o \
common/wire_error.o \
common/wireaddr.o \
common/withdraw_tx.o
common/withdraw_tx.o \
hsmd/gen_hsm_client_wire.o
LIGHTNINGD_SRC := \
lightningd/bitcoind.c \
@ -120,7 +121,7 @@ check-makefile: check-lightningd-makefile
check-lightningd-makefile:
@for f in lightningd/*.h lightningd/*/*.h; do if ! echo $(LIGHTNINGD_HEADERS_NOGEN) $(LIGHTNINGD_HEADERS_GEN) "" | grep -q "$$f "; then echo $$f not mentioned in LIGHTNINGD_HEADERS_NOGEN or LIGHTNINGD_HEADERS_GEN >&2; exit 1; fi; done
lightningd/lightningd: $(LIGHTNINGD_OBJS) $(LIGHTNINGD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(WIRE_ONION_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) $(LIGHTNINGD_HANDSHAKE_CONTROL_OBJS) $(LIGHTNINGD_GOSSIP_CONTROL_OBJS) $(LIGHTNINGD_OPENING_CONTROL_OBJS) $(LIGHTNINGD_CHANNEL_CONTROL_OBJS) $(LIGHTNINGD_CLOSING_CONTROL_OBJS) $(LIGHTNINGD_ONCHAIN_CONTROL_OBJS) $(WALLET_LIB_OBJS) $(LIGHTNINGD_CONNECT_CONTROL_OBJS)
lightningd/lightningd: $(LIGHTNINGD_OBJS) $(LIGHTNINGD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(WIRE_ONION_OBJS) $(LIGHTNINGD_HANDSHAKE_CONTROL_OBJS) $(LIGHTNINGD_GOSSIP_CONTROL_OBJS) $(LIGHTNINGD_OPENING_CONTROL_OBJS) $(LIGHTNINGD_CHANNEL_CONTROL_OBJS) $(LIGHTNINGD_CLOSING_CONTROL_OBJS) $(LIGHTNINGD_ONCHAIN_CONTROL_OBJS) $(WALLET_LIB_OBJS) $(LIGHTNINGD_CONNECT_CONTROL_OBJS)
clean: lightningd-clean

3
onchaind/Makefile

@ -68,7 +68,8 @@ ONCHAIND_COMMON_OBJS := \
common/type_to_string.o \
common/utils.o \
common/utxo.o \
common/version.o
common/version.o \
hsmd/gen_hsm_client_wire.o
onchaind/gen_onchain_wire.h: $(WIRE_GEN) onchaind/onchain_wire.csv
$(WIRE_GEN) --header $@ onchain_wire_type < onchaind/onchain_wire.csv > $@

1
openingd/Makefile

@ -70,6 +70,7 @@ OPENINGD_COMMON_OBJS := \
common/wire_error.o \
common/wireaddr.o \
gossipd/gen_gossip_wire.o \
hsmd/gen_hsm_client_wire.o \
lightningd/gossip_msg.o
$(LIGHTNINGD_OPENING_OBJS): $(LIGHTNINGD_HEADERS)

Loading…
Cancel
Save