Skip to content

Commit

Permalink
hsmd: remove hsmd/client.c
Browse files Browse the repository at this point in the history
It was only used by handshake.c.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Sep 20, 2018
1 parent f8df069 commit 8f1f178
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 76 deletions.
1 change: 1 addition & 0 deletions channeld/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions closingd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion connectd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 15 additions & 2 deletions connectd/connectd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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)
{
Expand All @@ -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);
Expand Down
1 change: 0 additions & 1 deletion connectd/handshake.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 2 additions & 0 deletions connectd/handshake.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 change: 0 additions & 1 deletion gossipd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions gossipd/gossipd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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);

Expand Down
28 changes: 9 additions & 19 deletions hsmd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)

Expand All @@ -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/%)

Expand Down
29 changes: 0 additions & 29 deletions hsmd/client.c

This file was deleted.

17 changes: 0 additions & 17 deletions hsmd/client.h

This file was deleted.

1 change: 0 additions & 1 deletion hsmd/hsmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 3 additions & 2 deletions lightningd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion onchaind/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 > $@
Expand Down
1 change: 1 addition & 0 deletions openingd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8f1f178

Please sign in to comment.