From bbed5e3411a32e2aa2ef04c7b0548fe0f4ef9121 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 29 Aug 2017 13:42:04 +0930 Subject: [PATCH] Rename subdaemons, move them into top level. We leave the *build* results in lightningd/ for ease of in-place testing though. Signed-off-by: Rusty Russell --- .gitignore | 9 +- INSTALL.md | 4 +- Makefile | 18 +++- {lightningd/channel => channeld}/Makefile | 38 +++++---- {lightningd/channel => channeld}/channel.c | 10 +-- .../channel => channeld}/channel_wire.csv | 0 .../channel => channeld}/channeld_htlc.h | 2 + {lightningd/channel => channeld}/commit_tx.c | 2 +- {lightningd/channel => channeld}/commit_tx.h | 2 +- .../channel => channeld}/full_channel.c | 4 +- .../channel => channeld}/full_channel.h | 2 +- {lightningd/closing => closingd}/Makefile | 36 ++++---- {lightningd/closing => closingd}/closing.c | 2 +- .../closing => closingd}/closing_wire.csv | 0 common/Makefile | 3 + external/.gitignore | 8 ++ {lightningd/gossip => gossipd}/Makefile | 44 +++++----- {lightningd/gossip => gossipd}/broadcast.c | 2 +- {lightningd/gossip => gossipd}/broadcast.h | 0 {lightningd/gossip => gossipd}/gossip.c | 6 +- .../gossip => gossipd}/gossip_wire.csv | 0 {lightningd/gossip => gossipd}/routing.c | 0 {lightningd/gossip => gossipd}/routing.h | 2 +- {lightningd/handshake => handshaked}/Makefile | 36 ++++---- .../handshake => handshaked}/handshake.c | 4 +- .../handshake_wire.csv | 0 .../handshake => handshaked}/test/.gitignore | 0 .../handshake => handshaked}/test/Makefile | 0 .../test/run-handshake.c | 0 hsmd/Makefile | 82 +++++++++++++++++++ {lightningd/hsm => hsmd}/client.c | 4 +- {lightningd/hsm => hsmd}/client.h | 0 {lightningd/hsm => hsmd}/hsm.c | 6 +- {lightningd/hsm => hsmd}/hsm_client_wire_csv | 0 {lightningd/hsm => hsmd}/hsm_wire.csv | 0 lightningd/.gitignore | 14 ++-- lightningd/Makefile | 22 ++--- lightningd/dev_ping.c | 12 +-- lightningd/gossip_control.c | 4 +- lightningd/gossip_msg.h | 2 +- lightningd/hsm/Makefile | 80 ------------------ lightningd/hsm_control.c | 4 +- lightningd/lightningd.c | 15 ++-- lightningd/new_connection.c | 6 +- lightningd/pay.c | 2 +- lightningd/peer_control.c | 26 +++--- lightningd/peer_htlcs.c | 6 +- lightningd/subd.h | 2 +- lightningd/test/run-channel.c | 4 +- lightningd/test/run-commit_tx.c | 2 +- {lightningd/onchain => onchaind}/Makefile | 54 ++++++------ {lightningd/onchain => onchaind}/onchain.c | 4 +- .../onchain => onchaind}/onchain_types.h | 0 .../onchain => onchaind}/onchain_wire.c | 2 +- .../onchain => onchaind}/onchain_wire.csv | 2 +- .../onchain => onchaind}/onchain_wire.h | 0 {lightningd/opening => openingd}/Makefile | 36 ++++---- {lightningd/opening => openingd}/opening.c | 2 +- .../opening => openingd}/opening_wire.csv | 0 tests/test_lightningd.py | 4 +- wallet/walletrpc.c | 2 +- wire/Makefile | 1 + 62 files changed, 330 insertions(+), 304 deletions(-) rename {lightningd/channel => channeld}/Makefile (67%) rename {lightningd/channel => channeld}/channel.c (99%) rename {lightningd/channel => channeld}/channel_wire.csv (100%) rename {lightningd/channel => channeld}/channeld_htlc.h (97%) rename {lightningd/channel => channeld}/commit_tx.c (99%) rename {lightningd/channel => channeld}/commit_tx.h (98%) rename {lightningd/channel => channeld}/full_channel.c (99%) rename {lightningd/channel => channeld}/full_channel.h (99%) rename {lightningd/closing => closingd}/Makefile (63%) rename {lightningd/closing => closingd}/closing.c (99%) rename {lightningd/closing => closingd}/closing_wire.csv (100%) create mode 100644 external/.gitignore rename {lightningd/gossip => gossipd}/Makefile (52%) rename {lightningd/gossip => gossipd}/broadcast.c (97%) rename {lightningd/gossip => gossipd}/broadcast.h (100%) rename {lightningd/gossip => gossipd}/gossip.c (99%) rename {lightningd/gossip => gossipd}/gossip_wire.csv (100%) rename {lightningd/gossip => gossipd}/routing.c (100%) rename {lightningd/gossip => gossipd}/routing.h (99%) rename {lightningd/handshake => handshaked}/Makefile (59%) rename {lightningd/handshake => handshaked}/handshake.c (99%) rename {lightningd/handshake => handshaked}/handshake_wire.csv (100%) rename {lightningd/handshake => handshaked}/test/.gitignore (100%) rename {lightningd/handshake => handshaked}/test/Makefile (100%) rename {lightningd/handshake => handshaked}/test/run-handshake.c (100%) create mode 100644 hsmd/Makefile rename {lightningd/hsm => hsmd}/client.c (85%) rename {lightningd/hsm => hsmd}/client.h (100%) rename {lightningd/hsm => hsmd}/hsm.c (99%) rename {lightningd/hsm => hsmd}/hsm_client_wire_csv (100%) rename {lightningd/hsm => hsmd}/hsm_wire.csv (100%) delete mode 100644 lightningd/hsm/Makefile rename {lightningd/onchain => onchaind}/Makefile (54%) rename {lightningd/onchain => onchaind}/onchain.c (99%) rename {lightningd/onchain => onchaind}/onchain_types.h (100%) rename {lightningd/onchain => onchaind}/onchain_wire.c (92%) rename {lightningd/onchain => onchaind}/onchain_wire.csv (98%) rename {lightningd/onchain => onchaind}/onchain_wire.h (100%) rename {lightningd/opening => openingd}/Makefile (66%) rename {lightningd/opening => openingd}/opening.c (99%) rename {lightningd/opening => openingd}/opening_wire.csv (100%) diff --git a/.gitignore b/.gitignore index 7f272cdd6b9e..5ed18104f971 100644 --- a/.gitignore +++ b/.gitignore @@ -9,14 +9,8 @@ TAGS ccan/tools/configurator/configurator ccan/ccan/cdump/tools/cdump-enumstr -libsecp256k1.a -libsecp256k1.la -libsodium.a -libsodium.la -libwallycore.a -libwallycore.la gen_* -lightning-cli/lightning-cli +cli/lightning-cli tools/check-bolt coverage ccan/config.h @@ -34,4 +28,3 @@ daemon/test/run-maxfee test/test_protocol test/test_sphinx test/test_irc -lightningd/lightningd_closing diff --git a/INSTALL.md b/INSTALL.md index 6f71bcedd459..de677a7fc79f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -49,8 +49,8 @@ make Running lightning: ``` bitcoind & -./lightningd/lightningd & -./daemon/lightning-cli help +./lightningd & +./cli/lightning-cli help ``` **Note**: You may need to include `testnet=1` in `bitcoin.conf` diff --git a/Makefile b/Makefile index 53d6c25e3118..084b7cdf1f1f 100644 --- a/Makefile +++ b/Makefile @@ -122,7 +122,7 @@ CCAN_HEADERS := \ $(CCANDIR)/ccan/timer/timer.h \ $(CCANDIR)/ccan/typesafe_cb/typesafe_cb.h -GEN_HEADERS := gen_version.h +ALL_GEN_HEADERS += gen_version.h CDUMP_OBJS := ccan-cdump.o ccan-strmap.o @@ -143,6 +143,13 @@ include bitcoin/Makefile include common/Makefile include wire/Makefile include wallet/Makefile +include hsmd/Makefile +include handshaked/Makefile +include gossipd/Makefile +include openingd/Makefile +include channeld/Makefile +include closingd/Makefile +include onchaind/Makefile include lightningd/Makefile include cli/Makefile include test/Makefile @@ -154,7 +161,7 @@ CHANGED_FROM_GIT = [ x"`git log $@ | head -n1`" != x"`git log $< | head -n1`" -o check: $(MAKE) pytest -pytest: cli/lightning-cli lightningd-all +pytest: $(ALL_PROGRAMS) PYTHONPATH=contrib/pylightning python3 tests/test_lightningd.py -f # Keep includes in alpha order. @@ -233,8 +240,11 @@ $(ALL_PROGRAMS) $(ALL_TEST_PROGRAMS): # Everything depends on the CCAN headers. $(CCAN_OBJS) $(CDUMP_OBJS): $(CCAN_HEADERS) -# Except for CCAN, we treat everything else as dependent on external/ bitcoin/ common/ wire/ and generated version headers. -$(ALL_OBJS): $(BITCOIN_HEADERS) $(COMMON_HEADERS) $(CCAN_HEADERS) $(WIRE_HEADERS) $(GEN_HEADERS) $(EXTERNAL_HEADERS) +# Except for CCAN, we treat everything else as dependent on external/ bitcoin/ common/ wire/ and all generated headers. +$(ALL_OBJS): $(BITCOIN_HEADERS) $(COMMON_HEADERS) $(CCAN_HEADERS) $(WIRE_HEADERS) $(ALL_GEN_HEADERS) $(EXTERNAL_HEADERS) + +# We generate headers in two ways, so regen when either changes. +$(ALL_GEN_HEADERS): ccan/ccan/cdump/tools/cdump-enumstr $(WIRE_GEN) update-ccan: mv ccan ccan.old diff --git a/lightningd/channel/Makefile b/channeld/Makefile similarity index 67% rename from lightningd/channel/Makefile rename to channeld/Makefile index bccaa4fdf5f6..26276d842c98 100644 --- a/lightningd/channel/Makefile +++ b/channeld/Makefile @@ -1,32 +1,34 @@ #! /usr/bin/make # Designed to be run one level up -lightningd/channel-wrongdir: +channeld-wrongdir: $(MAKE) -C ../.. lightningd/channel-all -default: lightningd/channel-all +default: channeld-all -lightningd/channel-all: lightningd/lightningd_channel +channeld-all: lightningd/lightning_channeld # lightningd/channel needs these: LIGHTNINGD_CHANNEL_HEADERS_GEN := \ - lightningd/channel/gen_channel_wire.h + channeld/gen_channel_wire.h LIGHTNINGD_CHANNEL_HEADERS_NOGEN := \ - lightningd/channel/channeld_htlc.h \ - lightningd/channel/commit_tx.h \ - lightningd/channel/full_channel.h + channeld/channeld_htlc.h \ + channeld/commit_tx.h \ + channeld/full_channel.h LIGHTNINGD_CHANNEL_HEADERS := $(LIGHTNINGD_CHANNEL_HEADERS_GEN) $(LIGHTNINGD_CHANNEL_HEADERS_NOGEN) -LIGHTNINGD_CHANNEL_SRC := lightningd/channel/channel.c \ - lightningd/channel/commit_tx.c \ - lightningd/channel/full_channel.c \ +LIGHTNINGD_CHANNEL_SRC := channeld/channel.c \ + channeld/commit_tx.c \ + channeld/full_channel.c \ $(LIGHTNINGD_CHANNEL_HEADERS_GEN:.h=.c) LIGHTNINGD_CHANNEL_OBJS := $(LIGHTNINGD_CHANNEL_SRC:.c=.o) # Make sure these depend on everything. ALL_OBJS += $(LIGHTNINGD_CHANNEL_OBJS) +ALL_PROGRAMS += lightningd/lightning_channeld +ALL_GEN_HEADERS += $(LIGHTNINGD_CHANNEL_HEADERS_GEN) # Common source we use. CHANNELD_COMMON_OBJS := \ @@ -61,9 +63,9 @@ LIGHTNINGD_CHANNEL_CONTROL_HEADERS := $(LIGHTNINGD_CHANNEL_HEADERS_GEN) LIGHTNINGD_CHANNEL_CONTROL_SRC := $(LIGHTNINGD_CHANNEL_HEADERS_GEN:.h=.c) LIGHTNINGD_CHANNEL_CONTROL_OBJS := $(LIGHTNINGD_CHANNEL_CONTROL_SRC:.c=.o) -LIGHTNINGD_CHANNEL_GEN_SRC := $(filter lightningd/channel/gen_%, $(LIGHTNINGD_CHANNEL_SRC) $(LIGHTNINGD_CHANNEL_CONTROL_SRC)) +LIGHTNINGD_CHANNEL_GEN_SRC := $(filter channeld/gen_%, $(LIGHTNINGD_CHANNEL_SRC) $(LIGHTNINGD_CHANNEL_CONTROL_SRC)) -LIGHTNINGD_CHANNEL_SRC_NOGEN := $(filter-out lightningd/channel/gen_%, $(LIGHTNINGD_CHANNEL_SRC)) +LIGHTNINGD_CHANNEL_SRC_NOGEN := $(filter-out channeld/gen_%, $(LIGHTNINGD_CHANNEL_SRC)) # Add to headers which any object might need. LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_CHANNEL_HEADERS_GEN) @@ -71,15 +73,15 @@ LIGHTNINGD_HEADERS_NOGEN += $(LIGHTNINGD_CHANNEL_HEADERS_NOGEN) $(LIGHTNINGD_CHANNEL_OBJS): $(LIGHTNINGD_HEADERS) -lightningd/channel/gen_channel_wire.h: $(WIRE_GEN) lightningd/channel/channel_wire.csv - $(WIRE_GEN) --header $@ channel_wire_type < lightningd/channel/channel_wire.csv > $@ +channeld/gen_channel_wire.h: $(WIRE_GEN) channeld/channel_wire.csv + $(WIRE_GEN) --header $@ channel_wire_type < channeld/channel_wire.csv > $@ -lightningd/channel/gen_channel_wire.c: $(WIRE_GEN) lightningd/channel/channel_wire.csv - $(WIRE_GEN) ${@:.c=.h} channel_wire_type < lightningd/channel/channel_wire.csv > $@ +channeld/gen_channel_wire.c: $(WIRE_GEN) channeld/channel_wire.csv + $(WIRE_GEN) ${@:.c=.h} channel_wire_type < channeld/channel_wire.csv > $@ LIGHTNINGD_CHANNEL_OBJS := $(LIGHTNINGD_CHANNEL_SRC:.c=.o) $(LIGHTNINGD_CHANNEL_GEN_SRC:.c=.o) -lightningd/lightningd_channel: $(LIGHTNINGD_CHANNEL_OBJS) $(WIRE_ONION_OBJS) $(CHANNELD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) +lightningd/lightning_channeld: $(LIGHTNINGD_CHANNEL_OBJS) $(WIRE_ONION_OBJS) $(CHANNELD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) check-source: $(LIGHTNINGD_CHANNEL_SRC_NOGEN:%=check-src-include-order/%) check-source-bolt: $(LIGHTNINGD_CHANNEL_SRC:%=bolt-check/%) $(LIGHTNINGD_CHANNEL_HEADERS:%=bolt-check/%) @@ -91,4 +93,4 @@ clean: lightningd/channel-clean lightningd/channel-clean: $(RM) $(LIGHTNINGD_CHANNEL_OBJS) gen_* --include lightningd/channel/test/Makefile +-include channeld/test/Makefile diff --git a/lightningd/channel/channel.c b/channeld/channel.c similarity index 99% rename from lightningd/channel/channel.c rename to channeld/channel.c index 405ec0f2a0e8..b4c061d34d4b 100644 --- a/lightningd/channel/channel.c +++ b/channeld/channel.c @@ -11,6 +11,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -27,12 +30,9 @@ #include #include #include +#include +#include #include -#include -#include -#include -#include -#include #include #include #include diff --git a/lightningd/channel/channel_wire.csv b/channeld/channel_wire.csv similarity index 100% rename from lightningd/channel/channel_wire.csv rename to channeld/channel_wire.csv diff --git a/lightningd/channel/channeld_htlc.h b/channeld/channeld_htlc.h similarity index 97% rename from lightningd/channel/channeld_htlc.h rename to channeld/channeld_htlc.h index 1c8f7993fc33..e7a5b0496c30 100644 --- a/lightningd/channel/channeld_htlc.h +++ b/channeld/channeld_htlc.h @@ -1,7 +1,9 @@ #ifndef LIGHTNING_LIGHTNINGD_CHANNEL_CHANNELD_HTLC_H #define LIGHTNING_LIGHTNINGD_CHANNEL_CHANNELD_HTLC_H #include "config.h" +#include #include +#include #include #include diff --git a/lightningd/channel/commit_tx.c b/channeld/commit_tx.c similarity index 99% rename from lightningd/channel/commit_tx.c rename to channeld/commit_tx.c index d83ca8540677..9cd6d4592dc9 100644 --- a/lightningd/channel/commit_tx.c +++ b/channeld/commit_tx.c @@ -1,11 +1,11 @@ #include #include #include +#include #include #include #include #include -#include #ifndef SUPERVERBOSE #define SUPERVERBOSE(...) diff --git a/lightningd/channel/commit_tx.h b/channeld/commit_tx.h similarity index 98% rename from lightningd/channel/commit_tx.h rename to channeld/commit_tx.h index cf84271a039c..24ac406ccae1 100644 --- a/lightningd/channel/commit_tx.h +++ b/channeld/commit_tx.h @@ -2,9 +2,9 @@ #define LIGHTNING_LIGHTNINGD_CHANNEL_COMMIT_TX_H #include "config.h" #include +#include #include #include -#include struct keyset; struct sha256_double; diff --git a/lightningd/channel/full_channel.c b/channeld/full_channel.c similarity index 99% rename from lightningd/channel/full_channel.c rename to channeld/full_channel.c index c750e796911b..677f074d4bfe 100644 --- a/lightningd/channel/full_channel.c +++ b/channeld/full_channel.c @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #include #include @@ -15,8 +17,6 @@ #include #include #include -#include -#include #include struct channel *new_channel(const tal_t *ctx, diff --git a/lightningd/channel/full_channel.h b/channeld/full_channel.h similarity index 99% rename from lightningd/channel/full_channel.h rename to channeld/full_channel.h index 6e9f061930f8..cec52da0e215 100644 --- a/lightningd/channel/full_channel.h +++ b/channeld/full_channel.h @@ -2,9 +2,9 @@ #ifndef LIGHTNING_LIGHTNINGD_CHANNEL_FULL_CHANNEL_H #define LIGHTNING_LIGHTNINGD_CHANNEL_FULL_CHANNEL_H #include "config.h" +#include #include #include -#include /** * new_channel: Given initial fees and funding, what is initial state? diff --git a/lightningd/closing/Makefile b/closingd/Makefile similarity index 63% rename from lightningd/closing/Makefile rename to closingd/Makefile index 2dd610bdd7eb..3631c9f139b3 100644 --- a/lightningd/closing/Makefile +++ b/closingd/Makefile @@ -1,36 +1,38 @@ #! /usr/bin/make # Designed to be run one level up -lightningd/closing-wrongdir: - $(MAKE) -C ../.. lightningd/closing-all +closingd-wrongdir: + $(MAKE) -C ../.. closingd-all -default: lightningd/closing-all +default: closingd-all -lightningd/closing-all: lightningd/lightningd_closing +closingd-all: lightningd/lightning_closingd -# lightningd/closing needs these: +# closingd needs these: LIGHTNINGD_CLOSING_HEADERS_GEN := \ - lightningd/closing/gen_closing_wire.h + closingd/gen_closing_wire.h LIGHTNINGD_CLOSING_HEADERS_NOGEN := LIGHTNINGD_CLOSING_HEADERS := $(LIGHTNINGD_CLOSING_HEADERS_GEN) $(LIGHTNINGD_CLOSING_HEADERS_NOGEN) -LIGHTNINGD_CLOSING_SRC := lightningd/closing/closing.c \ +LIGHTNINGD_CLOSING_SRC := closingd/closing.c \ $(LIGHTNINGD_CLOSING_HEADERS:.h=.c) LIGHTNINGD_CLOSING_OBJS := $(LIGHTNINGD_CLOSING_SRC:.c=.o) # Make sure these depend on everything. ALL_OBJS += $(LIGHTNINGD_CLOSING_OBJS) +ALL_PROGRAMS += lightningd/lightning_closingd +ALL_GEN_HEADERS += $(LIGHTNINGD_CLOSING_HEADERS_GEN) # Control daemon uses this: LIGHTNINGD_CLOSING_CONTROL_HEADERS := $(LIGHTNINGD_CLOSING_HEADERS) LIGHTNINGD_CLOSING_CONTROL_SRC := $(LIGHTNINGD_CLOSING_HEADERS:.h=.c) LIGHTNINGD_CLOSING_CONTROL_OBJS := $(LIGHTNINGD_CLOSING_CONTROL_SRC:.c=.o) -LIGHTNINGD_CLOSING_GEN_SRC := $(filter lightningd/closing/gen_%, $(LIGHTNINGD_CLOSING_SRC) $(LIGHTNINGD_CLOSING_CONTROL_SRC)) +LIGHTNINGD_CLOSING_GEN_SRC := $(filter closingd/gen_%, $(LIGHTNINGD_CLOSING_SRC) $(LIGHTNINGD_CLOSING_CONTROL_SRC)) -LIGHTNINGD_CLOSING_SRC_NOGEN := $(filter-out lightningd/closing/gen_%, $(LIGHTNINGD_CLOSING_SRC)) +LIGHTNINGD_CLOSING_SRC_NOGEN := $(filter-out closingd/gen_%, $(LIGHTNINGD_CLOSING_SRC)) # Add to headers which any object might need. LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_CLOSING_HEADERS_GEN) @@ -55,24 +57,24 @@ CLOSINGD_COMMON_OBJS := \ common/utils.o \ common/version.o -lightningd/closing/gen_closing_wire.h: $(WIRE_GEN) lightningd/closing/closing_wire.csv - $(WIRE_GEN) --header $@ closing_wire_type < lightningd/closing/closing_wire.csv > $@ +closingd/gen_closing_wire.h: $(WIRE_GEN) closingd/closing_wire.csv + $(WIRE_GEN) --header $@ closing_wire_type < closingd/closing_wire.csv > $@ -lightningd/closing/gen_closing_wire.c: $(WIRE_GEN) lightningd/closing/closing_wire.csv - $(WIRE_GEN) ${@:.c=.h} closing_wire_type < lightningd/closing/closing_wire.csv > $@ +closingd/gen_closing_wire.c: $(WIRE_GEN) closingd/closing_wire.csv + $(WIRE_GEN) ${@:.c=.h} closing_wire_type < closingd/closing_wire.csv > $@ LIGHTNINGD_CLOSING_OBJS := $(LIGHTNINGD_CLOSING_SRC:.c=.o) $(LIGHTNINGD_CLOSING_GEN_SRC:.c=.o) -lightningd/lightningd_closing: $(LIGHTNINGD_CLOSING_OBJS) $(WIRE_ONION_OBJS) $(CLOSINGD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) +lightningd/lightning_closingd: $(LIGHTNINGD_CLOSING_OBJS) $(WIRE_ONION_OBJS) $(CLOSINGD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) check-source: $(LIGHTNINGD_CLOSING_SRC_NOGEN:%=check-src-include-order/%) check-source-bolt: $(LIGHTNINGD_CLOSING_SRC:%=bolt-check/%) $(LIGHTNINGD_CLOSING_HEADERS:%=bolt-check/%) check-whitespace: $(LIGHTNINGD_CLOSING_SRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_CLOSING_HEADERS_NOGEN:%=check-whitespace/%) -clean: lightningd/closing-clean +clean: closingd-clean -lightningd/closing-clean: +closingd-clean: $(RM) $(LIGHTNINGD_CLOSING_OBJS) gen_* --include lightningd/closing/test/Makefile +-include closingd/test/Makefile diff --git a/lightningd/closing/closing.c b/closingd/closing.c similarity index 99% rename from lightningd/closing/closing.c rename to closingd/closing.c index 1b9e736d1b46..06114db79ab4 100644 --- a/lightningd/closing/closing.c +++ b/closingd/closing.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -10,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/lightningd/closing/closing_wire.csv b/closingd/closing_wire.csv similarity index 100% rename from lightningd/closing/closing_wire.csv rename to closingd/closing_wire.csv diff --git a/common/Makefile b/common/Makefile index 9b1d059de594..7e7464876013 100644 --- a/common/Makefile +++ b/common/Makefile @@ -41,6 +41,9 @@ COMMON_OBJS := $(COMMON_SRC:.c=.o) # Common objects depends on bitcoin/ external/ and ccan $(COMMON_OBJS): $(CCAN_HEADERS) $(BITCOIN_HEADERS) $(EXTERNAL_HEADERS) $(COMMON_HEADERS_GEN) +ALL_GEN_HEADERS += $(COMMON_HEADERS_GEN) +ALL_OBJS += $(COMMON_OBJS) + common/gen_htlc_state_names.h: common/htlc_state.h ccan/ccan/cdump/tools/cdump-enumstr ccan/ccan/cdump/tools/cdump-enumstr common/htlc_state.h > $@ diff --git a/external/.gitignore b/external/.gitignore new file mode 100644 index 000000000000..fbd137f4b2fa --- /dev/null +++ b/external/.gitignore @@ -0,0 +1,8 @@ +libbase58.a +libjsmn.a +libsecp256k1.a +libsecp256k1.la +libsodium.a +libsodium.la +libwallycore.a +libwallycore.la diff --git a/lightningd/gossip/Makefile b/gossipd/Makefile similarity index 52% rename from lightningd/gossip/Makefile rename to gossipd/Makefile index 4e875158a222..92b39093a9fe 100644 --- a/lightningd/gossip/Makefile +++ b/gossipd/Makefile @@ -1,30 +1,32 @@ #! /usr/bin/make # Designed to be run one level up -lightningd/gossip-wrongdir: - $(MAKE) -C .. lightningd/gossip-all +gossipd-wrongdir: + $(MAKE) -C .. gossipd-all -default: lightningd/gossip-all +default: gossipd-all # Control daemon uses this: -LIGHTNINGD_GOSSIP_CONTROL_HEADERS := lightningd/gossip/gen_gossip_wire.h -LIGHTNINGD_GOSSIP_CONTROL_SRC := lightningd/gossip/gen_gossip_wire.c +LIGHTNINGD_GOSSIP_CONTROL_HEADERS := gossipd/gen_gossip_wire.h +LIGHTNINGD_GOSSIP_CONTROL_SRC := gossipd/gen_gossip_wire.c LIGHTNINGD_GOSSIP_CONTROL_OBJS := $(LIGHTNINGD_GOSSIP_CONTROL_SRC:.c=.o) -# lightningd/gossip needs these: -LIGHTNINGD_GOSSIP_HEADERS := lightningd/gossip/gen_gossip_wire.h \ - lightningd/gossip/routing.h \ - lightningd/gossip/broadcast.h -LIGHTNINGD_GOSSIP_SRC := lightningd/gossip/gossip.c \ +# gossipd needs these: +LIGHTNINGD_GOSSIP_HEADERS := gossipd/gen_gossip_wire.h \ + gossipd/routing.h \ + gossipd/broadcast.h +LIGHTNINGD_GOSSIP_SRC := gossipd/gossip.c \ $(LIGHTNINGD_GOSSIP_HEADERS:.h=.c) LIGHTNINGD_GOSSIP_OBJS := $(LIGHTNINGD_GOSSIP_SRC:.c=.o) # Make sure these depend on everything. ALL_OBJS += $(LIGHTNINGD_GOSSIP_OBJS) +ALL_PROGRAMS += lightningd/lightning_gossipd +ALL_GEN_HEADERS += $(LIGHTNINGD_GOSSIP_CONTROL_HEADERS) # For checking -LIGHTNINGD_GOSSIP_ALLSRC_NOGEN := $(filter-out lightningd/gossip/gen_%, $(LIGHTNINGD_GOSSIP_CLIENT_SRC) $(LIGHTNINGD_GOSSIP_SRC)) -LIGHTNINGD_GOSSIP_ALLHEADERS_NOGEN := $(filter-out lightningd/gossip/gen_%, $(LIGHTNINGD_GOSSIP_CLIENT_HEADERS) $(LIGHTNINGD_GOSSIP_HEADERS)) +LIGHTNINGD_GOSSIP_ALLSRC_NOGEN := $(filter-out gossipd/gen_%, $(LIGHTNINGD_GOSSIP_CLIENT_SRC) $(LIGHTNINGD_GOSSIP_SRC)) +LIGHTNINGD_GOSSIP_ALLHEADERS_NOGEN := $(filter-out gossipd/gen_%, $(LIGHTNINGD_GOSSIP_CLIENT_HEADERS) $(LIGHTNINGD_GOSSIP_HEADERS)) # Add to headers which any object might need. LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_GOSSIP_HEADERS) @@ -50,23 +52,23 @@ $(LIGHTNINGD_GOSSIP_OBJS) $(LIGHTNINGD_GOSSIP_CLIENT_OBJS): $(LIGHTNINGD_HEADERS $(LIGHTNINGD_GOSSIP_CONTROL_OBJS) : $(LIGHTNINGD_GOSSIP_CONTROL_HEADERS) -lightningd/gossip-all: lightningd/lightningd_gossip $(LIGHTNINGD_GOSSIP_CLIENT_OBJS) +gossipd-all: lightningd/lightning_gossipd $(LIGHTNINGD_GOSSIP_CLIENT_OBJS) -lightningd/lightningd_gossip: $(LIGHTNINGD_GOSSIP_OBJS) $(GOSSIPD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) +lightningd/lightning_gossipd: $(LIGHTNINGD_GOSSIP_OBJS) $(GOSSIPD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) -lightningd/gossip/gen_gossip_wire.h: $(WIRE_GEN) lightningd/gossip/gossip_wire.csv - $(WIRE_GEN) --header $@ gossip_wire_type < lightningd/gossip/gossip_wire.csv > $@ +gossipd/gen_gossip_wire.h: $(WIRE_GEN) gossipd/gossip_wire.csv + $(WIRE_GEN) --header $@ gossip_wire_type < gossipd/gossip_wire.csv > $@ -lightningd/gossip/gen_gossip_wire.c: $(WIRE_GEN) lightningd/gossip/gossip_wire.csv - $(WIRE_GEN) ${@:.c=.h} gossip_wire_type < lightningd/gossip/gossip_wire.csv > $@ +gossipd/gen_gossip_wire.c: $(WIRE_GEN) gossipd/gossip_wire.csv + $(WIRE_GEN) ${@:.c=.h} gossip_wire_type < gossipd/gossip_wire.csv > $@ check-source: $(LIGHTNINGD_GOSSIP_ALLSRC_NOGEN:%=check-src-include-order/%) $(LIGHTNINGD_GOSSIP_ALLHEADERS_NOGEN:%=check-hdr-include-order/%) check-source-bolt: $(LIGHTNINGD_GOSSIP_SRC:%=bolt-check/%) $(LIGHTNINGD_GOSSIP_HEADERS:%=bolt-check/%) check-whitespace: $(LIGHTNINGD_GOSSIP_ALLSRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_GOSSIP_ALLHEADERS_NOGEN:%=check-whitespace/%) -clean: lightningd/gossip-clean +clean: gossipd-clean -lightningd/gossip-clean: +gossipd-clean: $(RM) $(LIGHTNINGD_GOSSIP_OBJS) gen_* --include lightningd/gossip/test/Makefile +-include gossipd/test/Makefile diff --git a/lightningd/gossip/broadcast.c b/gossipd/broadcast.c similarity index 97% rename from lightningd/gossip/broadcast.c rename to gossipd/broadcast.c index 63cc2d97c54b..c5d118243219 100644 --- a/lightningd/gossip/broadcast.c +++ b/gossipd/broadcast.c @@ -1,4 +1,4 @@ -#include +#include struct broadcast_state *new_broadcast_state(tal_t *ctx) { diff --git a/lightningd/gossip/broadcast.h b/gossipd/broadcast.h similarity index 100% rename from lightningd/gossip/broadcast.h rename to gossipd/broadcast.h diff --git a/lightningd/gossip/gossip.c b/gossipd/gossip.c similarity index 99% rename from lightningd/gossip/gossip.c rename to gossipd/gossip.c index c84a4ac7c0de..0e30b131887f 100644 --- a/lightningd/gossip/gossip.c +++ b/gossipd/gossip.c @@ -21,10 +21,10 @@ #include #include #include +#include +#include +#include #include -#include -#include -#include #include #include #include diff --git a/lightningd/gossip/gossip_wire.csv b/gossipd/gossip_wire.csv similarity index 100% rename from lightningd/gossip/gossip_wire.csv rename to gossipd/gossip_wire.csv diff --git a/lightningd/gossip/routing.c b/gossipd/routing.c similarity index 100% rename from lightningd/gossip/routing.c rename to gossipd/routing.c diff --git a/lightningd/gossip/routing.h b/gossipd/routing.h similarity index 99% rename from lightningd/gossip/routing.h rename to gossipd/routing.h index 33ef23f71899..c3dddecae200 100644 --- a/lightningd/gossip/routing.h +++ b/gossipd/routing.h @@ -3,7 +3,7 @@ #include "config.h" #include #include -#include +#include #include #define ROUTING_MAX_HOPS 20 diff --git a/lightningd/handshake/Makefile b/handshaked/Makefile similarity index 59% rename from lightningd/handshake/Makefile rename to handshaked/Makefile index 5b01178f0680..411dd1089ad9 100644 --- a/lightningd/handshake/Makefile +++ b/handshaked/Makefile @@ -1,31 +1,33 @@ #! /usr/bin/make # Designed to be run one level up -lightningd/handshake-wrongdir: - $(MAKE) -C .. lightningd/handshake-all +handshaked-wrongdir: + $(MAKE) -C .. handshaked-all -default: lightningd/handshake-all +default: handshaked-all -lightningd/handshake-all: lightningd/lightningd_handshake +handshaked-all: lightningd/lightning_handshaked -# lightningd/handshake needs these: +# handshaked needs these: LIGHTNINGD_HANDSHAKE_HEADERS := \ - lightningd/handshake/gen_handshake_wire.h -LIGHTNINGD_HANDSHAKE_SRC := lightningd/handshake/handshake.c \ + handshaked/gen_handshake_wire.h +LIGHTNINGD_HANDSHAKE_SRC := handshaked/handshake.c \ $(LIGHTNINGD_HANDSHAKE_HEADERS:.h=.c) LIGHTNINGD_HANDSHAKE_OBJS := $(LIGHTNINGD_HANDSHAKE_SRC:.c=.o) # Make sure these depend on everything. ALL_OBJS += $(LIGHTNINGD_HANDSHAKE_OBJS) +ALL_PROGRAMS += lightningd/lightning_handshaked +ALL_GEN_HEADERS += $(LIGHTNINGD_HANDSHAKE_HEADERS) # Control daemon uses this: LIGHTNINGD_HANDSHAKE_CONTROL_HEADERS := $(LIGHTNINGD_HANDSHAKE_HEADERS) LIGHTNINGD_HANDSHAKE_CONTROL_SRC := $(LIGHTNINGD_HANDSHAKE_HEADERS:.h=.c) LIGHTNINGD_HANDSHAKE_CONTROL_OBJS := $(LIGHTNINGD_HANDSHAKE_CONTROL_SRC:.c=.o) -LIGHTNINGD_HANDSHAKE_GEN_SRC := $(filter lightningd/handshake/gen_%, $(LIGHTNINGD_HANDSHAKE_SRC) $(LIGHTNINGD_HANDSHAKE_CONTROL_SRC)) +LIGHTNINGD_HANDSHAKE_GEN_SRC := $(filter handshaked/gen_%, $(LIGHTNINGD_HANDSHAKE_SRC) $(LIGHTNINGD_HANDSHAKE_CONTROL_SRC)) -LIGHTNINGD_HANDSHAKE_SRC_NOGEN := $(filter-out lightningd/handshake/gen_%, $(LIGHTNINGD_HANDSHAKE_SRC)) +LIGHTNINGD_HANDSHAKE_SRC_NOGEN := $(filter-out handshaked/gen_%, $(LIGHTNINGD_HANDSHAKE_SRC)) # Add to headers which any object might need. LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_HANDSHAKE_HEADERS) @@ -45,24 +47,24 @@ HANDSHAKED_COMMON_OBJS := \ common/utils.o \ common/version.o -lightningd/handshake/gen_handshake_wire.h: $(WIRE_GEN) lightningd/handshake/handshake_wire.csv - $(WIRE_GEN) --header $@ handshake_wire_type < lightningd/handshake/handshake_wire.csv > $@ +handshaked/gen_handshake_wire.h: $(WIRE_GEN) handshaked/handshake_wire.csv + $(WIRE_GEN) --header $@ handshake_wire_type < handshaked/handshake_wire.csv > $@ -lightningd/handshake/gen_handshake_wire.c: $(WIRE_GEN) lightningd/handshake/handshake_wire.csv - $(WIRE_GEN) ${@:.c=.h} handshake_wire_type < lightningd/handshake/handshake_wire.csv > $@ +handshaked/gen_handshake_wire.c: $(WIRE_GEN) handshaked/handshake_wire.csv + $(WIRE_GEN) ${@:.c=.h} handshake_wire_type < handshaked/handshake_wire.csv > $@ LIGHTNINGD_HANDSHAKE_OBJS := $(LIGHTNINGD_HANDSHAKE_SRC:.c=.o) $(LIGHTNINGD_HANDSHAKE_GEN_SRC:.c=.o) -lightningd/lightningd_handshake: $(LIGHTNINGD_OLD_LIB_OBJS) $(LIGHTNINGD_LIB_OBJS) $(LIGHTNINGD_HANDSHAKE_OBJS) $(HANDSHAKED_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) +lightningd/lightning_handshaked: $(LIGHTNINGD_OLD_LIB_OBJS) $(LIGHTNINGD_LIB_OBJS) $(LIGHTNINGD_HANDSHAKE_OBJS) $(HANDSHAKED_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) check-source: $(LIGHTNINGD_HANDSHAKE_SRC_NOGEN:%=check-src-include-order/%) check-source-bolt: $(LIGHTNINGD_HANDSHAKE_SRC:%=bolt-check/%) $(LIGHTNINGD_HANDSHAKE_HEADERS:%=bolt-check/%) check-whitespace: $(LIGHTNINGD_HANDSHAKE_SRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_HANDSHAKE_HEADERS_NOGEN:%=check-whitespace/%) -clean: lightningd/handshake-clean +clean: handshaked-clean -lightningd/handshake-clean: +handshaked-clean: $(RM) $(LIGHTNINGD_HANDSHAKE_OBJS) gen_* --include lightningd/handshake/test/Makefile +-include handshaked/test/Makefile diff --git a/lightningd/handshake/handshake.c b/handshaked/handshake.c similarity index 99% rename from lightningd/handshake/handshake.c rename to handshaked/handshake.c index 6d8f20491b92..43e5bd917d19 100644 --- a/lightningd/handshake/handshake.c +++ b/handshaked/handshake.c @@ -13,8 +13,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/lightningd/handshake/handshake_wire.csv b/handshaked/handshake_wire.csv similarity index 100% rename from lightningd/handshake/handshake_wire.csv rename to handshaked/handshake_wire.csv diff --git a/lightningd/handshake/test/.gitignore b/handshaked/test/.gitignore similarity index 100% rename from lightningd/handshake/test/.gitignore rename to handshaked/test/.gitignore diff --git a/lightningd/handshake/test/Makefile b/handshaked/test/Makefile similarity index 100% rename from lightningd/handshake/test/Makefile rename to handshaked/test/Makefile diff --git a/lightningd/handshake/test/run-handshake.c b/handshaked/test/run-handshake.c similarity index 100% rename from lightningd/handshake/test/run-handshake.c rename to handshaked/test/run-handshake.c diff --git a/hsmd/Makefile b/hsmd/Makefile new file mode 100644 index 000000000000..d74b0574b093 --- /dev/null +++ b/hsmd/Makefile @@ -0,0 +1,82 @@ +#! /usr/bin/make + +# Designed to be run one level up +hsmd-wrongdir: + $(MAKE) -C .. lightningd/hsm-all + +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) + +# Control daemon uses this: +LIGHTNINGD_HSM_CONTROL_HEADERS := hsmd/gen_hsm_wire.h +LIGHTNINGD_HSM_CONTROL_SRC := hsmd/gen_hsm_wire.c +LIGHTNINGD_HSM_CONTROL_OBJS := $(LIGHTNINGD_HSM_CONTROL_SRC:.c=.o) + +# lightningd/hsm needs these: +LIGHTNINGD_HSM_HEADERS := hsmd/gen_hsm_client_wire.h \ + hsmd/gen_hsm_wire.h +LIGHTNINGD_HSM_SRC := hsmd/hsm.c \ + $(LIGHTNINGD_HSM_HEADERS:.h=.c) +LIGHTNINGD_HSM_OBJS := $(LIGHTNINGD_HSM_SRC:.c=.o) + +# Common source we use. +HSMD_COMMON_OBJS := \ + common/bip32.o \ + common/daemon_conn.o \ + common/funding_tx.o \ + common/key_derive.o \ + common/msg_queue.o \ + common/permute_tx.o \ + common/status.o \ + common/utils.o \ + common/utxo.o \ + common/version.o \ + 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_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS): $(LIGHTNINGD_HEADERS) + +$(LIGHTNINGD_HSM_CONTROL_OBJS) : $(LIGHTNINGD_HSM_CONTROL_HEADERS) + +# Make sure these depend on everything. +ALL_OBJS += $(LIGHTNINGD_HSM_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) +ALL_PROGRAMS += lightningd/lightning_hsmd +ALL_GEN_HEADERS += $(LIGHTNINGD_HSM_HEADERS) + +hsmd-all: lightningd/lightning_hsmd $(LIGHTNINGD_HSM_CLIENT_OBJS) + +lightningd/lightning_hsmd: $(LIGHTNINGD_HSM_OBJS) $(LIGHTNINGD_LIB_OBJS) $(HSMD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) + +hsmd/gen_hsm_client_wire.h: $(WIRE_GEN) hsmd/hsm_client_wire_csv + $(WIRE_GEN) --header $@ hsm_client_wire_type < hsmd/hsm_client_wire_csv > $@ + +hsmd/gen_hsm_client_wire.c: $(WIRE_GEN) hsmd/hsm_client_wire_csv + $(WIRE_GEN) ${@:.c=.h} hsm_client_wire_type< hsmd/hsm_client_wire_csv > $@ + +hsmd/gen_hsm_wire.h: $(WIRE_GEN) hsmd/hsm_wire.csv + $(WIRE_GEN) --header $@ hsm_wire_type < hsmd/hsm_wire.csv > $@ + +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-whitespace: $(LIGHTNINGD_HSM_ALLSRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_HSM_ALLHEADERS_NOGEN:%=check-whitespace/%) + +clean: lightningd/hsm-clean + +lightningd/hsm-clean: + $(RM) $(LIGHTNINGD_HSM_OBJS) gen_* + +-include hsmd/test/Makefile diff --git a/lightningd/hsm/client.c b/hsmd/client.c similarity index 85% rename from lightningd/hsm/client.c rename to hsmd/client.c index 6656fd5fcb16..981329f243ca 100644 --- a/lightningd/hsm/client.c +++ b/hsmd/client.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include static int hsm_fd = -1; diff --git a/lightningd/hsm/client.h b/hsmd/client.h similarity index 100% rename from lightningd/hsm/client.h rename to hsmd/client.h diff --git a/lightningd/hsm/hsm.c b/hsmd/hsm.c similarity index 99% rename from lightningd/hsm/hsm.c rename to hsmd/hsm.c index 35a8aa3040ed..243ebf64c923 100644 --- a/lightningd/hsm/hsm.c +++ b/hsmd/hsm.c @@ -22,10 +22,10 @@ #include #include #include +#include +#include +#include #include -#include -#include -#include #include #include #include diff --git a/lightningd/hsm/hsm_client_wire_csv b/hsmd/hsm_client_wire_csv similarity index 100% rename from lightningd/hsm/hsm_client_wire_csv rename to hsmd/hsm_client_wire_csv diff --git a/lightningd/hsm/hsm_wire.csv b/hsmd/hsm_wire.csv similarity index 100% rename from lightningd/hsm/hsm_wire.csv rename to hsmd/hsm_wire.csv diff --git a/lightningd/.gitignore b/lightningd/.gitignore index d362528ba02e..700129d63f7a 100644 --- a/lightningd/.gitignore +++ b/lightningd/.gitignore @@ -1,7 +1,9 @@ lightningd -lightningd_channel -lightningd_connect -lightningd_gossip -lightningd_handshake -lightningd_hsm -lightningd_opening +lightning_channeld +lightning_connectd +lightning_gossipd +lightning_handshaked +lightning_hsmd +lightning_openingd +lightning_closingd +lightning_onchaind diff --git a/lightningd/Makefile b/lightningd/Makefile index 46280be9f34e..354f984daa81 100644 --- a/lightningd/Makefile +++ b/lightningd/Makefile @@ -4,11 +4,11 @@ lightningd-wrongdir: $(MAKE) -C .. lightningd-all -LIGHTNINGD_BINS := lightningd/lightningd lightningd/lightningd_hsm lightningd/lightningd_handshake lightningd/lightningd_gossip lightningd/lightningd_opening lightningd/lightningd_channel lightningd/lightningd_closing lightningd/lightningd_onchain +LIGHTNINGD_PROGRAM := lightningd/lightningd -ALL_PROGRAMS += $(LIGHTNINGD_BINS) +ALL_PROGRAMS += $(LIGHTNINGD_PROGRAM) -lightningd-all: $(LIGHTNINGD_BINS) +lightningd-all: $(LIGHTNINGD_PROGRAM) default: lightningd-all @@ -76,19 +76,11 @@ LIGHTNINGD_HEADERS_NOGEN = \ LIGHTNINGD_HEADERS_GEN = \ lightningd/gen_peer_state_names.h +ALL_GEN_HEADERS += $(LIGHTNINGD_HEADERS_GEN) + # All together in one convenient var LIGHTNINGD_HEADERS = $(LIGHTNINGD_HEADERS_NOGEN) $(LIGHTNINGD_HEADERS_GEN) $(EXTERNAL_HEADERS) $(WIRE_HEADERS) $(BITCOIN_HEADERS) $(COMMON_HEADERS) $(WALLET_LIB_HEADERS) -# These included makefiles add their headers to the LIGHTNINGD_HEADERS -# variable so the include must preceed any actual use of the variable. -include lightningd/hsm/Makefile -include lightningd/handshake/Makefile -include lightningd/gossip/Makefile -include lightningd/opening/Makefile -include lightningd/channel/Makefile -include lightningd/closing/Makefile -include lightningd/onchain/Makefile - $(LIGHTNINGD_OBJS): $(LIGHTNINGD_HEADERS) lightningd/gen_peer_state_names.h: lightningd/peer_state.h ccan/ccan/cdump/tools/cdump-enumstr @@ -104,11 +96,11 @@ 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) $(CCAN_OBJS) $(LIGHTNINGD_HSM_CONTROL_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/lightningd: $(LIGHTNINGD_OBJS) $(LIGHTNINGD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(WIRE_ONION_OBJS) $(LIGHTNINGD_HSM_CONTROL_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) clean: lightningd-clean lightningd-clean: - $(RM) $(LIGHTNINGD_OBJS) $(LIGHTNINGD_JSMN_OBJS) $(LIGHTNINGD_BINS) + $(RM) $(LIGHTNINGD_OBJS) $(LIGHTNINGD_JSMN_OBJS) $(LIGHTNINGD_PROGRAM) include lightningd/test/Makefile diff --git a/lightningd/dev_ping.c b/lightningd/dev_ping.c index 37a65ca6eeac..fc1c6e6ce659 100644 --- a/lightningd/dev_ping.c +++ b/lightningd/dev_ping.c @@ -1,7 +1,7 @@ +#include #include #include -#include -#include +#include #include #include #include @@ -16,7 +16,7 @@ static bool ping_reply(struct subd *subd, const u8 *msg, const int *fds, bool ok; log_debug(subd->ld->log, "Got ping reply!"); - if (streq(subd->name, "lightningd_channel")) + if (streq(subd->name, "lightning_channeld")) ok = fromwire_channel_ping_reply(msg, NULL, &totlen); else ok = fromwire_gossip_ping_reply(msg, NULL, &totlen); @@ -59,8 +59,8 @@ static void json_dev_ping(struct command *cmd, /* FIXME: These checks are horrible, use a peer flag to say it's * ready to forward! */ - if (peer->owner && !streq(peer->owner->name, "lightningd_channel") - && !streq(peer->owner->name, "lightningd_gossip")) { + if (peer->owner && !streq(peer->owner->name, "lightning_channeld") + && !streq(peer->owner->name, "lightning_gossipd")) { command_fail(cmd, "Peer in %s", peer->owner ? peer->owner->name : "unattached"); return; @@ -80,7 +80,7 @@ static void json_dev_ping(struct command *cmd, return; } - if (streq(peer->owner->name, "lightningd_channel")) + if (streq(peer->owner->name, "lightning_channeld")) msg = towire_channel_ping(cmd, pongbytes, len); else msg = towire_gossip_ping(cmd, peer->unique_id, pongbytes, len); diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index 30e8c3ad6d9f..d05b9e1d3edf 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -7,8 +7,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -144,7 +144,7 @@ void gossip_init(struct lightningd *ld) { tal_t *tmpctx = tal_tmpctx(ld); u8 *init; - ld->gossip = new_subd(ld, ld, "lightningd_gossip", NULL, + ld->gossip = new_subd(ld, ld, "lightning_gossipd", NULL, gossip_wire_type_name, gossip_msg, gossip_finished, NULL); if (!ld->gossip) diff --git a/lightningd/gossip_msg.h b/lightningd/gossip_msg.h index a61db8811a7b..ee46b70a0ac0 100644 --- a/lightningd/gossip_msg.h +++ b/lightningd/gossip_msg.h @@ -2,7 +2,7 @@ #define LIGHTNING_LIGHTNINGD_GOSSIP_MSG_H #include "config.h" #include -#include +#include struct gossip_getnodes_entry { struct pubkey nodeid; diff --git a/lightningd/hsm/Makefile b/lightningd/hsm/Makefile deleted file mode 100644 index a40d8840736c..000000000000 --- a/lightningd/hsm/Makefile +++ /dev/null @@ -1,80 +0,0 @@ -#! /usr/bin/make - -# Designed to be run one level up -lightningd/hsm-wrongdir: - $(MAKE) -C .. lightningd/hsm-all - -default: lightningd/hsm-all - -# Clients use this: -LIGHTNINGD_HSM_CLIENT_HEADERS := lightningd/hsm/client.h -LIGHTNINGD_HSM_CLIENT_SRC := lightningd/hsm/client.c lightningd/hsm/gen_hsm_client_wire.c -LIGHTNINGD_HSM_CLIENT_OBJS := $(LIGHTNINGD_HSM_CLIENT_SRC:.c=.o) - -# Control daemon uses this: -LIGHTNINGD_HSM_CONTROL_HEADERS := lightningd/hsm/gen_hsm_wire.h -LIGHTNINGD_HSM_CONTROL_SRC := lightningd/hsm/gen_hsm_wire.c -LIGHTNINGD_HSM_CONTROL_OBJS := $(LIGHTNINGD_HSM_CONTROL_SRC:.c=.o) - -# lightningd/hsm needs these: -LIGHTNINGD_HSM_HEADERS := lightningd/hsm/gen_hsm_client_wire.h \ - lightningd/hsm/gen_hsm_wire.h -LIGHTNINGD_HSM_SRC := lightningd/hsm/hsm.c \ - $(LIGHTNINGD_HSM_HEADERS:.h=.c) -LIGHTNINGD_HSM_OBJS := $(LIGHTNINGD_HSM_SRC:.c=.o) - -# Common source we use. -HSMD_COMMON_OBJS := \ - common/bip32.o \ - common/daemon_conn.o \ - common/funding_tx.o \ - common/key_derive.o \ - common/msg_queue.o \ - common/permute_tx.o \ - common/status.o \ - common/utils.o \ - common/utxo.o \ - common/version.o \ - common/withdraw_tx.o - -# For checking -LIGHTNINGD_HSM_ALLSRC_NOGEN := $(filter-out lightningd/hsm/gen_%, $(LIGHTNINGD_HSM_CLIENT_SRC) $(LIGHTNINGD_HSM_SRC)) -LIGHTNINGD_HSM_ALLHEADERS_NOGEN := $(filter-out lightningd/hsm/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_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS): $(LIGHTNINGD_HEADERS) - -$(LIGHTNINGD_HSM_CONTROL_OBJS) : $(LIGHTNINGD_HSM_CONTROL_HEADERS) - -# Make sure these depend on everything. -ALL_OBJS += $(LIGHTNINGD_HSM_OBJS) - -lightningd/hsm-all: lightningd/lightningd_hsm $(LIGHTNINGD_HSM_CLIENT_OBJS) - -lightningd/lightningd_hsm: $(LIGHTNINGD_HSM_OBJS) $(LIGHTNINGD_OLD_LIB_OBJS) $(LIGHTNINGD_LIB_OBJS) $(HSMD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) - -lightningd/hsm/gen_hsm_client_wire.h: $(WIRE_GEN) lightningd/hsm/hsm_client_wire_csv - $(WIRE_GEN) --header $@ hsm_client_wire_type < lightningd/hsm/hsm_client_wire_csv > $@ - -lightningd/hsm/gen_hsm_client_wire.c: $(WIRE_GEN) lightningd/hsm/hsm_client_wire_csv - $(WIRE_GEN) ${@:.c=.h} hsm_client_wire_type< lightningd/hsm/hsm_client_wire_csv > $@ - -lightningd/hsm/gen_hsm_wire.h: $(WIRE_GEN) lightningd/hsm/hsm_wire.csv - $(WIRE_GEN) --header $@ hsm_wire_type < lightningd/hsm/hsm_wire.csv > $@ - -lightningd/hsm/gen_hsm_wire.c: $(WIRE_GEN) lightningd/hsm/hsm_wire.csv - $(WIRE_GEN) ${@:.c=.h} hsm_wire_type < lightningd/hsm/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-whitespace: $(LIGHTNINGD_HSM_ALLSRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_HSM_ALLHEADERS_NOGEN:%=check-whitespace/%) - -clean: lightningd/hsm-clean - -lightningd/hsm-clean: - $(RM) $(LIGHTNINGD_HSM_OBJS) gen_* - --include lightningd/hsm/test/Makefile diff --git a/lightningd/hsm_control.c b/lightningd/hsm_control.c index 80bdca0b3ca0..88b585d13e9c 100644 --- a/lightningd/hsm_control.c +++ b/lightningd/hsm_control.c @@ -7,8 +7,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -36,7 +36,7 @@ void hsm_init(struct lightningd *ld, bool newdir) u8 *msg; bool create; - ld->hsm_fd = subd_raw(ld, "lightningd_hsm"); + ld->hsm_fd = subd_raw(ld, "lightning_hsmd"); if (ld->hsm_fd < 0) err(1, "Could not subd hsm"); diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 8ce0618f263f..d322f7f21b5d 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -22,8 +22,8 @@ #include #include #include -#include #include +#include #include #include @@ -100,12 +100,13 @@ static struct lightningd *new_lightningd(const tal_t *ctx) static const char *daemons[] = { "lightningd", - "lightningd_channel", - "lightningd_closing", - "lightningd_gossip", - "lightningd_handshake", - "lightningd_hsm", - "lightningd_opening" + "lightning_channeld", + "lightning_closingd", + "lightning_gossipd", + "lightning_handshaked", + "lightning_hsmd", + "lightning_onchaind", + "lightning_openingd" }; /* Check we can run them, and check their versions */ diff --git a/lightningd/new_connection.c b/lightningd/new_connection.c index e41e8406ad5c..b94d9a420490 100644 --- a/lightningd/new_connection.c +++ b/lightningd/new_connection.c @@ -4,8 +4,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -221,7 +221,7 @@ static struct io_plan *hsm_then_handshake(struct io_conn *conn, /* Give handshake daemon the hsm fd. */ handshaked = new_subd(ld, ld, - "lightningd_handshake", NULL, + "lightning_handshaked", NULL, handshake_wire_type_name, NULL, NULL, take(&hsmfd), take(&connfd), NULL); diff --git a/lightningd/pay.c b/lightningd/pay.c index a8e7ed689bb6..0f845d6a76ab 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -2,9 +2,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index e9e10b727e94..e145478cb070 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include #include @@ -17,24 +19,22 @@ #include #include #include +#include +#include #include #include #include -#include -#include #include #include -#include -#include #include #include #include #include -#include -#include -#include #include #include +#include +#include +#include #include #include #include @@ -1224,7 +1224,7 @@ static enum watch_result funding_spent(struct peer *peer, peer_fail_permanent_str(peer, "Funding transaction spent"); peer->owner = new_subd(peer->ld, peer->ld, - "lightningd_onchain", peer, + "lightning_onchaind", peer, onchain_wire_type_name, onchain_msg, peer_onchain_finished, @@ -1783,7 +1783,7 @@ static void peer_start_closingd(struct peer *peer, } peer->owner = new_subd(peer->ld, peer->ld, - "lightningd_closing", peer, + "lightning_closingd", peer, closing_wire_type_name, closing_msg, peer_owner_finished, @@ -1970,7 +1970,7 @@ static bool peer_start_channeld(struct peer *peer, fatal("Could not read fd from HSM: %s", strerror(errno)); peer->owner = new_subd(peer->ld, peer->ld, - "lightningd_channel", peer, + "lightning_channeld", peer, channel_wire_type_name, channel_msg, peer_owner_finished, @@ -2282,7 +2282,7 @@ static void channel_config(struct lightningd *ld, */ ours->max_accepted_htlcs = 483; - /* This is filled in by lightningd_opening, for consistency. */ + /* This is filled in by lightning_openingd, for consistency. */ ours->channel_reserve_satoshis = 0; }; @@ -2309,7 +2309,7 @@ void peer_fundee_open(struct peer *peer, const u8 *from_peer, } peer_set_condition(peer, GOSSIPD, OPENINGD); - peer->owner = new_subd(ld, ld, "lightningd_opening", peer, + peer->owner = new_subd(ld, ld, "lightning_openingd", peer, opening_wire_type_name, NULL, peer_owner_finished, take(&peer_fd), take(&gossip_fd), @@ -2393,7 +2393,7 @@ static bool gossip_peer_released(struct subd *gossip, peer_set_condition(fc->peer, GOSSIPD, OPENINGD); opening = new_subd(fc->peer->ld, ld, - "lightningd_opening", fc->peer, + "lightning_openingd", fc->peer, opening_wire_type_name, NULL, peer_owner_finished, take(&fds[0]), take(&fds[1]), NULL); diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index 1ef63411b826..28f1a2f27b43 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -3,22 +3,22 @@ #include #include #include +#include #include #include #include #include +#include #include -#include -#include #include #include #include #include -#include #include #include #include #include +#include #include static bool state_update_ok(struct peer *peer, diff --git a/lightningd/subd.h b/lightningd/subd.h index e1b4fcf69d1f..77a27a9dc6e1 100644 --- a/lightningd/subd.h +++ b/lightningd/subd.h @@ -16,7 +16,7 @@ struct io_conn; /* One of our subds. */ struct subd { - /* Name, like John, or "lightningd_hsm" */ + /* Name, like John, or "lightning_hsmd" */ const char *name; /* The Big Cheese. */ struct lightningd *ld; diff --git a/lightningd/test/run-channel.c b/lightningd/test/run-channel.c index 1f27308da042..a6cdf16e6975 100644 --- a/lightningd/test/run-channel.c +++ b/lightningd/test/run-channel.c @@ -6,9 +6,9 @@ #include "../../common/key_derive.c" #include "../../common/keyset.c" #include "../../common/initial_channel.c" -#include "../channel/full_channel.c" +#include "../../channeld/full_channel.c" #include "../../common/initial_commit_tx.c" -#include "../channel/commit_tx.c" +#include "../../channeld/commit_tx.c" #include "../../common/htlc_tx.c" #include #include diff --git a/lightningd/test/run-commit_tx.c b/lightningd/test/run-commit_tx.c index 01dc28839814..48ef02590f02 100644 --- a/lightningd/test/run-commit_tx.c +++ b/lightningd/test/run-commit_tx.c @@ -6,7 +6,7 @@ static bool print_superverbose; #define SUPERVERBOSE(...) \ do { if (print_superverbose) printf(__VA_ARGS__); } while(0) #define PRINT_ACTUAL_FEE -#include "../channel/commit_tx.c" +#include "../../channeld/commit_tx.c" #include "../../common/initial_commit_tx.c" #include "../../common/htlc_tx.c" #include diff --git a/lightningd/onchain/Makefile b/onchaind/Makefile similarity index 54% rename from lightningd/onchain/Makefile rename to onchaind/Makefile index c3ead50c0e96..48ab7266b6a9 100644 --- a/lightningd/onchain/Makefile +++ b/onchaind/Makefile @@ -1,43 +1,43 @@ #! /usr/bin/make # Designed to be run one level up -lightningd/onchain-wrongdir: - $(MAKE) -C ../.. lightningd/onchain-all +onchaind-wrongdir: + $(MAKE) -C ../.. onchaind-all -default: lightningd/onchain-all +default: onchaind-all -lightningd/onchain-all: lightningd/lightningd_onchain +onchaind-all: lightningd/lightning_onchaind -lightningd/onchain/gen_onchain_types_names.h: lightningd/onchain/onchain_types.h ccan/ccan/cdump/tools/cdump-enumstr - ccan/ccan/cdump/tools/cdump-enumstr lightningd/onchain/onchain_types.h > $@ +onchaind/gen_onchain_types_names.h: onchaind/onchain_types.h ccan/ccan/cdump/tools/cdump-enumstr + ccan/ccan/cdump/tools/cdump-enumstr onchaind/onchain_types.h > $@ -# lightningd/onchain needs these: +# onchaind needs these: LIGHTNINGD_ONCHAIN_HEADERS_GEN := \ - lightningd/onchain/gen_onchain_wire.h \ - lightningd/onchain/gen_onchain_types_names.h + onchaind/gen_onchain_wire.h \ + onchaind/gen_onchain_types_names.h LIGHTNINGD_ONCHAIN_HEADERS_NOGEN := \ - lightningd/onchain/onchain_types.h \ - lightningd/onchain/onchain_wire.h + onchaind/onchain_types.h \ + onchaind/onchain_wire.h LIGHTNINGD_ONCHAIN_HEADERS := $(LIGHTNINGD_ONCHAIN_HEADERS_GEN) $(LIGHTNINGD_ONCHAIN_HEADERS_NOGEN) -LIGHTNINGD_ONCHAIN_SRC := lightningd/onchain/onchain.c \ - lightningd/onchain/gen_onchain_wire.c \ - lightningd/onchain/onchain_wire.c +LIGHTNINGD_ONCHAIN_SRC := onchaind/onchain.c \ + onchaind/gen_onchain_wire.c \ + onchaind/onchain_wire.c LIGHTNINGD_ONCHAIN_OBJS := $(LIGHTNINGD_ONCHAIN_SRC:.c=.o) # Control daemon uses this: LIGHTNINGD_ONCHAIN_CONTROL_HEADERS := \ - lightningd/onchain/gen_onchain_wire.h \ - lightningd/onchain/onchain_wire.h + onchaind/gen_onchain_wire.h \ + onchaind/onchain_wire.h LIGHTNINGD_ONCHAIN_CONTROL_SRC := $(LIGHTNINGD_ONCHAIN_CONTROL_HEADERS:.h=.c) LIGHTNINGD_ONCHAIN_CONTROL_OBJS := $(LIGHTNINGD_ONCHAIN_CONTROL_SRC:.c=.o) -LIGHTNINGD_ONCHAIN_GEN_SRC := $(filter lightningd/onchain/gen_%, $(LIGHTNINGD_ONCHAIN_SRC) $(LIGHTNINGD_ONCHAIN_CONTROL_SRC)) +LIGHTNINGD_ONCHAIN_GEN_SRC := $(filter onchaind/gen_%, $(LIGHTNINGD_ONCHAIN_SRC) $(LIGHTNINGD_ONCHAIN_CONTROL_SRC)) -LIGHTNINGD_ONCHAIN_SRC_NOGEN := $(filter-out lightningd/onchain/gen_%, $(LIGHTNINGD_ONCHAIN_SRC)) +LIGHTNINGD_ONCHAIN_SRC_NOGEN := $(filter-out onchaind/gen_%, $(LIGHTNINGD_ONCHAIN_SRC)) # Add to headers which any object might need. LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_ONCHAIN_HEADERS_GEN) @@ -63,27 +63,29 @@ ONCHAIND_COMMON_OBJS := \ common/utils.o \ common/version.o -lightningd/onchain/gen_onchain_wire.h: $(WIRE_GEN) lightningd/onchain/onchain_wire.csv - $(WIRE_GEN) --header $@ onchain_wire_type < lightningd/onchain/onchain_wire.csv > $@ +onchaind/gen_onchain_wire.h: $(WIRE_GEN) onchaind/onchain_wire.csv + $(WIRE_GEN) --header $@ onchain_wire_type < onchaind/onchain_wire.csv > $@ -lightningd/onchain/gen_onchain_wire.c: $(WIRE_GEN) lightningd/onchain/onchain_wire.csv - $(WIRE_GEN) ${@:.c=.h} onchain_wire_type < lightningd/onchain/onchain_wire.csv > $@ +onchaind/gen_onchain_wire.c: $(WIRE_GEN) onchaind/onchain_wire.csv + $(WIRE_GEN) ${@:.c=.h} onchain_wire_type < onchaind/onchain_wire.csv > $@ LIGHTNINGD_ONCHAIN_OBJS := $(LIGHTNINGD_ONCHAIN_SRC:.c=.o) $(LIGHTNINGD_ONCHAIN_GEN_SRC:.c=.o) # Make sure these depend on everything. ALL_OBJS += $(LIGHTNINGD_ONCHAIN_OBJS) +ALL_PROGRAMS += lightningd/lightning_onchaind +ALL_GEN_HEADERS += $(LIGHTNINGD_ONCHAIN_HEADERS_GEN) -lightningd/lightningd_onchain: $(LIGHTNINGD_ONCHAIN_OBJS) $(WIRE_ONION_OBJS) $(ONCHAIND_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) +lightningd/lightning_onchaind: $(LIGHTNINGD_ONCHAIN_OBJS) $(WIRE_ONION_OBJS) $(ONCHAIND_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) check-source: $(LIGHTNINGD_ONCHAIN_SRC_NOGEN:%=check-src-include-order/%) check-source-bolt: $(LIGHTNINGD_ONCHAIN_SRC:%=bolt-check/%) $(LIGHTNINGD_ONCHAIN_HEADERS:%=bolt-check/%) check-whitespace: $(LIGHTNINGD_ONCHAIN_SRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_ONCHAIN_HEADERS_NOGEN:%=check-whitespace/%) -clean: lightningd/onchain-clean +clean: onchaind-clean -lightningd/onchain-clean: +onchaind-clean: $(RM) $(LIGHTNINGD_ONCHAIN_OBJS) gen_* --include lightningd/onchain/test/Makefile +-include onchaind/test/Makefile diff --git a/lightningd/onchain/onchain.c b/onchaind/onchain.c similarity index 99% rename from lightningd/onchain/onchain.c rename to onchaind/onchain.c index 5c031ce80a1c..6a88636bb11d 100644 --- a/lightningd/onchain/onchain.c +++ b/onchaind/onchain.c @@ -15,9 +15,9 @@ #include #include #include -#include -#include #include +#include +#include #include #include #include diff --git a/lightningd/onchain/onchain_types.h b/onchaind/onchain_types.h similarity index 100% rename from lightningd/onchain/onchain_types.h rename to onchaind/onchain_types.h diff --git a/lightningd/onchain/onchain_wire.c b/onchaind/onchain_wire.c similarity index 92% rename from lightningd/onchain/onchain_wire.c rename to onchaind/onchain_wire.c index 02ec01e0905e..3f653b115c14 100644 --- a/lightningd/onchain/onchain_wire.c +++ b/onchaind/onchain_wire.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include void towire_htlc_stub(u8 **pptr, const struct htlc_stub *htlc_stub) diff --git a/lightningd/onchain/onchain_wire.csv b/onchaind/onchain_wire.csv similarity index 98% rename from lightningd/onchain/onchain_wire.csv rename to onchaind/onchain_wire.csv index 6a9a438a7f17..e786bae9ac7c 100644 --- a/lightningd/onchain/onchain_wire.csv +++ b/onchaind/onchain_wire.csv @@ -35,7 +35,7 @@ onchain_init,,num_htlc_sigs,u16 onchain_init,,htlc_signature,num_htlc_sigs*secp256k1_ecdsa_signature onchain_init,,num_htlcs,u64 -#include +#include # This is all the HTLCs: one per message onchain_htlc,2 onchain_htlc,,htlc,struct htlc_stub diff --git a/lightningd/onchain/onchain_wire.h b/onchaind/onchain_wire.h similarity index 100% rename from lightningd/onchain/onchain_wire.h rename to onchaind/onchain_wire.h diff --git a/lightningd/opening/Makefile b/openingd/Makefile similarity index 66% rename from lightningd/opening/Makefile rename to openingd/Makefile index b88906d5277a..458f9b1f882c 100644 --- a/lightningd/opening/Makefile +++ b/openingd/Makefile @@ -1,22 +1,22 @@ #! /usr/bin/make # Designed to be run one level up -lightningd/opening-wrongdir: - $(MAKE) -C ../.. lightningd/opening-all +opening-wrongdir: + $(MAKE) -C ../.. opening-all -default: lightningd/opening-all +default: opening-all -lightningd/opening-all: lightningd/lightningd_opening +opening-all: lightningd/lightning_openingd -# lightningd/opening needs these: +# opening needs these: LIGHTNINGD_OPENING_HEADERS_GEN := \ - lightningd/opening/gen_opening_wire.h + openingd/gen_opening_wire.h LIGHTNINGD_OPENING_HEADERS_NOGEN := LIGHTNINGD_OPENING_HEADERS := $(LIGHTNINGD_OPENING_HEADERS_GEN) $(LIGHTNINGD_OPENING_HEADERS_NOGEN) -LIGHTNINGD_OPENING_SRC := lightningd/opening/opening.c \ +LIGHTNINGD_OPENING_SRC := openingd/opening.c \ $(LIGHTNINGD_OPENING_HEADERS:.h=.c) LIGHTNINGD_OPENING_OBJS := $(LIGHTNINGD_OPENING_SRC:.c=.o) @@ -25,9 +25,9 @@ LIGHTNINGD_OPENING_CONTROL_HEADERS := $(LIGHTNINGD_OPENING_HEADERS) LIGHTNINGD_OPENING_CONTROL_SRC := $(LIGHTNINGD_OPENING_HEADERS:.h=.c) LIGHTNINGD_OPENING_CONTROL_OBJS := $(LIGHTNINGD_OPENING_CONTROL_SRC:.c=.o) -LIGHTNINGD_OPENING_GEN_SRC := $(filter lightningd/opening/gen_%, $(LIGHTNINGD_OPENING_SRC) $(LIGHTNINGD_OPENING_CONTROL_SRC)) +LIGHTNINGD_OPENING_GEN_SRC := $(filter openingd/gen_%, $(LIGHTNINGD_OPENING_SRC) $(LIGHTNINGD_OPENING_CONTROL_SRC)) -LIGHTNINGD_OPENING_SRC_NOGEN := $(filter-out lightningd/opening/gen_%, $(LIGHTNINGD_OPENING_SRC)) +LIGHTNINGD_OPENING_SRC_NOGEN := $(filter-out openingd/gen_%, $(LIGHTNINGD_OPENING_SRC)) # Add to headers which any object might need. LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_OPENING_HEADERS_GEN) @@ -62,27 +62,29 @@ OPENINGD_COMMON_OBJS := \ $(LIGHTNINGD_OPENING_OBJS): $(LIGHTNINGD_HEADERS) -lightningd/opening/gen_opening_wire.h: $(WIRE_GEN) lightningd/opening/opening_wire.csv - $(WIRE_GEN) --header $@ opening_wire_type < lightningd/opening/opening_wire.csv > $@ +openingd/gen_opening_wire.h: $(WIRE_GEN) openingd/opening_wire.csv + $(WIRE_GEN) --header $@ opening_wire_type < openingd/opening_wire.csv > $@ -lightningd/opening/gen_opening_wire.c: $(WIRE_GEN) lightningd/opening/opening_wire.csv - $(WIRE_GEN) ${@:.c=.h} opening_wire_type < lightningd/opening/opening_wire.csv > $@ +openingd/gen_opening_wire.c: $(WIRE_GEN) openingd/opening_wire.csv + $(WIRE_GEN) ${@:.c=.h} opening_wire_type < openingd/opening_wire.csv > $@ LIGHTNINGD_OPENING_OBJS := $(LIGHTNINGD_OPENING_SRC:.c=.o) $(LIGHTNINGD_OPENING_GEN_SRC:.c=.o) # Make sure these depend on everything. ALL_OBJS += $(LIGHTNINGD_OPENING_OBJS) +ALL_PROGRAMS += lightningd/lightning_openingd +ALL_GEN_HEADERS += $(LIGHTNINGD_OPENING_HEADERS_GEN) -lightningd/lightningd_opening: $(LIGHTNINGD_OPENING_OBJS) $(OPENINGD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) +lightningd/lightning_openingd: $(LIGHTNINGD_OPENING_OBJS) $(OPENINGD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS) check-source: $(LIGHTNINGD_OPENING_SRC_NOGEN:%=check-src-include-order/%) check-source-bolt: $(LIGHTNINGD_OPENING_SRC:%=bolt-check/%) $(LIGHTNINGD_OPENING_HEADERS:%=bolt-check/%) check-whitespace: $(LIGHTNINGD_OPENING_SRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_OPENING_HEADERS_NOGEN:%=check-whitespace/%) -clean: lightningd/opening-clean +clean: opening-clean -lightningd/opening-clean: +opening-clean: $(RM) $(LIGHTNINGD_OPENING_OBJS) gen_* --include lightningd/opening/test/Makefile +-include openingd/test/Makefile diff --git a/lightningd/opening/opening.c b/openingd/opening.c similarity index 99% rename from lightningd/opening/opening.c rename to openingd/opening.c index 98aa237e1a76..375375a3db4e 100644 --- a/lightningd/opening/opening.c +++ b/openingd/opening.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lightningd/opening/opening_wire.csv b/openingd/opening_wire.csv similarity index 100% rename from lightningd/opening/opening_wire.csv rename to openingd/opening_wire.csv diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index 9262eb55d968..53414ef3ff1b 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -238,8 +238,8 @@ def test_connect(self): assert 'state: UNINITIALIZED -> GOSSIPD' in p1['log'] # Both should still be owned by gossip - assert p1['owner'] == 'lightningd_gossip' - assert p2['owner'] == 'lightningd_gossip' + assert p1['owner'] == 'lightning_gossipd' + assert p2['owner'] == 'lightning_gossipd' def test_balance(self): l1,l2 = self.connect() diff --git a/wallet/walletrpc.c b/wallet/walletrpc.c index 5694cf767405..f3425b6cac09 100644 --- a/wallet/walletrpc.c +++ b/wallet/walletrpc.c @@ -7,9 +7,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/wire/Makefile b/wire/Makefile index 9779e5fa0882..6f64ae909921 100644 --- a/wire/Makefile +++ b/wire/Makefile @@ -22,6 +22,7 @@ WIRE_OBJS := $(WIRE_SRC:.c=.o) $(WIRE_GEN_SRC:.c=.o) WIRE_ONION_OBJS := $(WIRE_GEN_ONION_SRC:.c=.o) ALL_OBJS += $(WIRE_OBJS) $(WIRE_ONION_OBJS) +ALL_GEN_HEADERS += $(WIRE_GEN_HEADERS) # They may not have the bolts. BOLT_EXTRACT=$(BOLTDIR)/tools/extract-formats.py