diff --git a/Makefile b/Makefile index 0d2731121..6a11343b7 100644 --- a/Makefile +++ b/Makefile @@ -263,6 +263,12 @@ SHA256STAMP = echo '$(2) SHA256STAMP:$(1)'`cat $^ | sha256sum | cut -c1-64` >> $ %_wiregen.c: %_wire.csv $(WIRE_GEN_DEPS) @if $(call SHA256STAMP_CHANGED,exp-$(EXPERIMENTAL_FEATURES)-); then $(call VERBOSE,"wiregen $@",tools/generate-wire.py --page impl $($@_args) ${@:.c=.h} `basename $< .csv` < $< > $@ && $(call SHA256STAMP,exp-$(EXPERIMENTAL_FEATURES)-,//)); fi +%_printgen.h: %_wire.csv $(WIRE_GEN_DEPS) + @if $(call SHA256STAMP_CHANGED,exp-$(EXPERIMENTAL_FEATURES)-); then $(call VERBOSE,"printgen $@",tools/generate-wire.py -s -P --page header $($@_args) $@ `basename $< .csv` < $< > $@ && $(call SHA256STAMP,exp-$(EXPERIMENTAL_FEATURES)-,//)); fi + +%_printgen.c: %_wire.csv $(WIRE_GEN_DEPS) + @if $(call SHA256STAMP_CHANGED,exp-$(EXPERIMENTAL_FEATURES)-); then $(call VERBOSE,"printgen $@",tools/generate-wire.py -s -P --page impl $($@_args) ${@:.c=.h} `basename $< .csv` < $< > $@ && $(call SHA256STAMP,exp-$(EXPERIMENTAL_FEATURES)-,//)); fi + include external/Makefile include bitcoin/Makefile include common/Makefile @@ -485,7 +491,7 @@ clean: $(RM) $(CCAN_OBJS) $(CDUMP_OBJS) $(ALL_OBJS) $(RM) $(ALL_PROGRAMS) $(ALL_PROGRAMS:=.o) $(RM) $(ALL_TEST_PROGRAMS) $(ALL_TEST_PROGRAMS:=.o) - $(RM) gen_*.h ccan/tools/configurator/configurator + $(RM) gen_*.h */gen_* ccan/tools/configurator/configurator $(RM) ccan/ccan/cdump/tools/cdump-enumstr.o find . -name '*gcda' -delete find . -name '*gcno' -delete diff --git a/channeld/Makefile b/channeld/Makefile index 2dd43b5ff..1ea83a1e3 100644 --- a/channeld/Makefile +++ b/channeld/Makefile @@ -127,6 +127,6 @@ check-whitespace: $(LIGHTNINGD_CHANNEL_SRC_NOGEN:%=check-whitespace/%) $(LIGHTNI clean: lightningd/channel-clean lightningd/channel-clean: - $(RM) $(LIGHTNINGD_CHANNEL_OBJS) channeld/gen_* + $(RM) $(LIGHTNINGD_CHANNEL_OBJS) -include channeld/test/Makefile diff --git a/channeld/channeld.c b/channeld/channeld.c index 6e846939b..07f48f898 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -62,8 +62,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -1736,8 +1736,8 @@ static void handle_peer_shutdown(struct peer *peer, const u8 *shutdown) static bool channeld_handle_custommsg(const u8 *msg) { #if DEVELOPER - enum wire_type type = fromwire_peektype(msg); - if (type % 2 == 1 && !wire_type_is_defined(type)) { + enum peer_wire type = fromwire_peektype(msg); + if (type % 2 == 1 && !peer_wire_is_defined(type)) { /* The message is not part of the messages we know how to * handle. Assuming this is a custommsg, we just forward it to the * master. */ @@ -1755,7 +1755,7 @@ static bool channeld_handle_custommsg(const u8 *msg) /* Peer sends onion msg. */ static void handle_onion_message(struct peer *peer, const u8 *msg) { - enum onion_type badreason; + enum onion_wire badreason; struct onionpacket op; struct secret ss, *blinding_ss; struct pubkey *blinding_in; @@ -1775,7 +1775,7 @@ static void handle_onion_message(struct peer *peer, const u8 *msg) badreason = parse_onionpacket(onion, TOTAL_PACKET_SIZE, &op); if (badreason != 0) { status_debug("onion msg: can't parse onionpacket: %s", - onion_type_name(badreason)); + onion_wire_name(badreason)); return; } @@ -2031,7 +2031,7 @@ static void handle_unexpected_reestablish(struct peer *peer, const u8 *msg) static void peer_in(struct peer *peer, const u8 *msg) { - enum wire_type type = fromwire_peektype(msg); + enum peer_wire type = fromwire_peektype(msg); /* Only count soft errors if the channel has locked-in already; * otherwise we can't cancel a channel before it has opened. @@ -2065,7 +2065,7 @@ static void peer_in(struct peer *peer, const u8 *msg) peer_failed(peer->pps, &peer->channel_id, "%s (%u) before funding locked", - wire_type_name(type), type); + peer_wire_name(type), type); } } @@ -2136,7 +2136,7 @@ static void peer_in(struct peer *peer, const u8 *msg) peer_failed(peer->pps, &peer->channel_id, "Peer sent unknown message %u (%s)", - type, wire_type_name(type)); + type, peer_wire_name(type)); } static void resend_revoke(struct peer *peer) @@ -2475,7 +2475,7 @@ static bool capture_premature_msg(const u8 ***shit_lnd_says, const u8 *msg) return false; status_debug("Stashing early %s msg!", - wire_type_name(fromwire_peektype(msg))); + peer_wire_name(fromwire_peektype(msg))); tal_arr_expand(shit_lnd_says, tal_steal(*shit_lnd_says, msg)); return true; @@ -2583,7 +2583,7 @@ static void peer_reconnect(struct peer *peer, peer_failed(peer->pps, &peer->channel_id, "bad reestablish msg: %s %s", - wire_type_name(fromwire_peektype(msg)), + peer_wire_name(fromwire_peektype(msg)), tal_hex(msg, msg)); } @@ -3162,7 +3162,7 @@ static void req_in(struct peer *peer, const u8 *msg) } /* Now handle common messages. */ - switch ((enum common_wire_type)t) { + switch ((enum common_wire)t) { #if DEVELOPER case WIRE_CUSTOMMSG_OUT: channeld_send_custommsg(peer, msg); diff --git a/channeld/channeld_htlc.h b/channeld/channeld_htlc.h index 2a14d5e37..5913a500e 100644 --- a/channeld/channeld_htlc.h +++ b/channeld/channeld_htlc.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include struct htlc { /* What's the status. */ diff --git a/closingd/Makefile b/closingd/Makefile index 5ceb5fce7..ea1697d09 100644 --- a/closingd/Makefile +++ b/closingd/Makefile @@ -96,6 +96,6 @@ check-whitespace: $(LIGHTNINGD_CLOSING_SRC_NOGEN:%=check-whitespace/%) $(LIGHTNI clean: closingd-clean closingd-clean: - $(RM) $(LIGHTNINGD_CLOSING_OBJS) closingd/gen_* + $(RM) $(LIGHTNINGD_CLOSING_OBJS) -include closingd/test/Makefile diff --git a/closingd/closingd.c b/closingd/closingd.c index 8a2b60a51..093401376 100644 --- a/closingd/closingd.c +++ b/closingd/closingd.c @@ -203,7 +203,7 @@ static void do_reconnect(struct per_peer_state *pps, &next_commitment_point)) { peer_failed(pps, channel_id, "bad reestablish msg: %s %s", - wire_type_name(fromwire_peektype(channel_reestablish)), + peer_wire_name(fromwire_peektype(channel_reestablish)), tal_hex(tmpctx, channel_reestablish)); } status_debug("Got reestablish commit=%"PRIu64" revoke=%"PRIu64, diff --git a/common/decode_array.c b/common/decode_array.c index a5c41717b..37e482618 100644 --- a/common/decode_array.c +++ b/common/decode_array.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include diff --git a/common/dev_disconnect.c b/common/dev_disconnect.c index 8a3b98a19..13cfa3c79 100644 --- a/common/dev_disconnect.c +++ b/common/dev_disconnect.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #if DEVELOPER /* We move the fd if and only if we do a disconnect. */ @@ -71,7 +71,7 @@ enum dev_disconnect dev_disconnect(int pkt_type) if (!dev_disconnect_count) next_dev_disconnect(); - if (!streq(wire_type_name(pkt_type), dev_disconnect_line+1)) + if (!streq(peer_wire_name(pkt_type), dev_disconnect_line+1)) return DEV_DISCONNECT_NORMAL; if (--dev_disconnect_count != 0) { diff --git a/common/gossip_rcvd_filter.c b/common/gossip_rcvd_filter.c index 329f46341..94f8ed4b7 100644 --- a/common/gossip_rcvd_filter.c +++ b/common/gossip_rcvd_filter.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include static u64 msg_key(const u8 *msg) { diff --git a/common/gossip_store.c b/common/gossip_store.c index 800fd1fb8..89a1c69d0 100644 --- a/common/gossip_store.c +++ b/common/gossip_store.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include void gossip_setup_timestamp_filter(struct per_peer_state *pps, u32 first_timestamp, diff --git a/common/gossmap.c b/common/gossmap.c index 652c2033c..1f51ebd61 100644 --- a/common/gossmap.c +++ b/common/gossmap.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include /* We need this global to decode indexes for hash functions */ static struct gossmap *map; diff --git a/common/htlc_wire.c b/common/htlc_wire.c index 8064f3c82..c7ed2c4b1 100644 --- a/common/htlc_wire.c +++ b/common/htlc_wire.c @@ -215,7 +215,7 @@ void fromwire_fulfilled_htlc(const u8 **cursor, size_t *max, struct failed_htlc *fromwire_failed_htlc(const tal_t *ctx, const u8 **cursor, size_t *max) { struct failed_htlc *failed = tal(ctx, struct failed_htlc); - enum onion_type badonion; + enum onion_wire badonion; failed->id = fromwire_u64(cursor, max); badonion = fromwire_u16(cursor, max); diff --git a/common/htlc_wire.h b/common/htlc_wire.h index 6424bf897..743a743fb 100644 --- a/common/htlc_wire.h +++ b/common/htlc_wire.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include struct bitcoin_tx; struct shachain; @@ -54,7 +54,7 @@ struct failed_htlc { struct sha256 *sha256_of_onion; /* WIRE_INVALID_ONION_VERSION, WIRE_INVALID_ONION_KEY or * WIRE_INVALID_ONION_HMAC (ie. must have BADONION) */ - enum onion_type badonion; + enum onion_wire badonion; /* Otherwise, this is the onion ready to send to them. */ const struct onionreply *onion; diff --git a/common/onion.c b/common/onion.c index 4db8c207c..bd82eea7b 100644 --- a/common/onion.c +++ b/common/onion.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include /* BOLT #4: * diff --git a/common/ping.c b/common/ping.c index 0cc0f0931..5aed86670 100644 --- a/common/ping.c +++ b/common/ping.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include bool check_ping_make_pong(const tal_t *ctx, const u8 *ping, u8 **pong) { diff --git a/common/read_peer_msg.c b/common/read_peer_msg.c index 2427ba36b..44794dd20 100644 --- a/common/read_peer_msg.c +++ b/common/read_peer_msg.c @@ -194,7 +194,7 @@ bool handle_peer_gossip_or_error(struct per_peer_state *pps, /* They're talking about a different channel? */ if (is_wrong_channel(msg, channel_id, &actual)) { status_debug("Rejecting %s for unknown channel_id %s", - wire_type_name(fromwire_peektype(msg)), + peer_wire_name(fromwire_peektype(msg)), type_to_string(tmpctx, struct channel_id, &actual)); sync_crypto_write(pps, take(towire_errorfmt(NULL, &actual, diff --git a/common/sphinx.c b/common/sphinx.c index 31a7d6235..91248d46e 100644 --- a/common/sphinx.c +++ b/common/sphinx.c @@ -144,7 +144,7 @@ u8 *serialize_onionpacket( return dst; } -enum onion_type parse_onionpacket(const u8 *src, +enum onion_wire parse_onionpacket(const u8 *src, const size_t srclen, struct onionpacket *dest) { diff --git a/common/sphinx.h b/common/sphinx.h index e3a54f2a5..18f924a7f 100644 --- a/common/sphinx.h +++ b/common/sphinx.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include struct node_id; @@ -164,7 +164,7 @@ u8 *serialize_onionpacket( * @srclen: length of the @src (must be TOTAL_PACKET_SIZE) * @dest: the destination into which we should parse the packet */ -enum onion_type parse_onionpacket(const u8 *src, +enum onion_wire parse_onionpacket(const u8 *src, const size_t srclen, struct onionpacket *dest); diff --git a/common/status.c b/common/status.c index 1715a84ef..a2d40175b 100644 --- a/common/status.c +++ b/common/status.c @@ -101,7 +101,7 @@ static void status_peer_io_short(enum log_level iodir, { status_peer_debug(peer, "%s %s", iodir == LOG_IO_OUT ? "peer_out" : "peer_in", - wire_type_name(fromwire_peektype(p))); + peer_wire_name(fromwire_peektype(p))); } void status_peer_io(enum log_level iodir, diff --git a/common/test/Makefile b/common/test/Makefile index c30036686..1a33495f3 100644 --- a/common/test/Makefile +++ b/common/test/Makefile @@ -13,7 +13,7 @@ ALL_TEST_PROGRAMS += $(COMMON_TEST_PROGRAMS) ALL_OBJS += $(COMMON_TEST_PROGRAMS:=.o) # Sphinx test wants to decode TLVs. -common/test/run-sphinx: wire/gen_onion_wire.o wire/towire.o wire/fromwire.o +common/test/run-sphinx: wire/onion_wiregen.o wire/towire.o wire/fromwire.o common/test/run-param \ common/test/run-json: \ @@ -25,7 +25,7 @@ common/test/run-json: \ common/wireaddr.o \ common/type_to_string.o \ wire/fromwire.o \ - wire/gen_onion_wire.o \ + wire/onion_wiregen.o \ wire/towire.o update-mocks: $(COMMON_TEST_SRC:%=update-mocks/%) diff --git a/common/wire_error.c b/common/wire_error.c index 43cf8e6d5..537c51f02 100644 --- a/common/wire_error.c +++ b/common/wire_error.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include u8 *towire_errorfmtv(const tal_t *ctx, const struct channel_id *channel, diff --git a/connectd/Makefile b/connectd/Makefile index f6f9ef93e..f3b5e9f06 100644 --- a/connectd/Makefile +++ b/connectd/Makefile @@ -75,7 +75,7 @@ CONNECTD_COMMON_OBJS := \ common/wire_error.o \ gossipd/gossipd_wiregen.o \ lightningd/gossip_msg.o \ - wire/gen_onion_wire.o + wire/onion_wiregen.o $(LIGHTNINGD_CONNECT_OBJS): $(LIGHTNINGD_HEADERS) $(LIGHTNINGD_CONNECT_HEADERS) diff --git a/connectd/connectd.c b/connectd/connectd.c index e87493940..1fcd9414d 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -67,8 +67,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/devtools/Makefile b/devtools/Makefile index 9539ccfb1..b62044dfe 100644 --- a/devtools/Makefile +++ b/devtools/Makefile @@ -1,5 +1,3 @@ -DEVTOOLS_SRC := devtools/gen_print_wire.c devtools/gen_print_onion_wire.c devtools/print_wire.c -DEVTOOLS_OBJS := $(DEVTOOLS_SRC:.c=.o) DEVTOOLS := devtools/bolt11-cli devtools/decodemsg devtools/onion devtools/dump-gossipstore devtools/gossipwith devtools/create-gossipstore devtools/mkcommit devtools/mkfunding devtools/mkclose devtools/mkgossip devtools/mkencoded devtools/mkquery devtools/lightning-checkmessage devtools/topology devtools/route ifeq ($(HAVE_SQLITE3),1) DEVTOOLS += devtools/checkchannels @@ -40,45 +38,31 @@ DEVTOOLS_COMMON_OBJS := \ common/utils.o \ common/version.o \ common/wireaddr.o \ - wire/gen_onion_wire.o \ - wire/gen_peer_wire.o + wire/onion_wiregen.o \ + wire/peer_wiregen.o devtools-all: $(DEVTOOLS) -devtools/gen_print_wire.h: $(DEVTOOL_BOLT_DEPS) wire/gen_peer_wire_csv - $(BOLT_GEN) -P -s --page header $@ wire_type < wire/gen_peer_wire_csv > $@ +devtools/bolt11-cli: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/bolt11-cli.o -devtools/gen_print_wire.c: $(DEVTOOL_BOLT_DEPS) wire/gen_peer_wire_csv - $(BOLT_GEN) -P -s --page impl ${@:.c=.h} wire_type < wire/gen_peer_wire_csv > $@ +devtools/decodemsg: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o wire/peer_printgen.o wire/onion_printgen.o devtools/print_wire.o devtools/decodemsg.o -devtools/gen_print_onion_wire.h: $(DEVTOOL_BOLT_DEPS) wire/gen_onion_wire_csv - $(BOLT_GEN) -P -s --page header $@ onion_type < wire/gen_onion_wire_csv > $@ - -devtools/gen_print_onion_wire.c: $(DEVTOOL_BOLT_DEPS) wire/gen_onion_wire_csv - $(BOLT_GEN) -P -s --page impl ${@:.c=.h} onion_type < wire/gen_onion_wire_csv > $@ - -devtools/bolt11-cli: $(DEVTOOLS_OBJS) $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/bolt11-cli.o - -devtools/decodemsg: $(DEVTOOLS_OBJS) $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/decodemsg.o - -devtools/dump-gossipstore: $(DEVTOOLS_OBJS) $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/dump-gossipstore.o gossipd/gossip_store_wiregen.o +devtools/dump-gossipstore: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/dump-gossipstore.o gossipd/gossip_store_wiregen.o devtools/dump-gossipstore.o: gossipd/gossip_store_wiregen.h -devtools/create-gossipstore: $(DEVTOOLS_OBJS) $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/create-gossipstore.o gossipd/gossip_store_wiregen.o +devtools/create-gossipstore: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/create-gossipstore.o gossipd/gossip_store_wiregen.o devtools/create-gossipstore.o: gossipd/gossip_store_wiregen.h devtools/onion.c: ccan/config.h -devtools/onion: $(DEVTOOLS_OBJS) $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) common/onion.o common/onionreply.o wire/fromwire.o wire/towire.o devtools/onion.o common/sphinx.o +devtools/onion: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) common/onion.o common/onionreply.o wire/fromwire.o wire/towire.o devtools/onion.o common/sphinx.o -devtools/blindedpath: $(DEVTOOLS_OBJS) $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) common/blinding.o $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/blindedpath.o common/onion.o common/onionreply.o common/sphinx.o +devtools/blindedpath: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) common/blinding.o $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/blindedpath.o common/onion.o common/onionreply.o common/sphinx.o -devtools/gossipwith: $(DEVTOOLS_OBJS) $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o wire/gen_peer_wire.o devtools/gossipwith.o common/cryptomsg.o common/cryptomsg.o common/crypto_sync.o +devtools/gossipwith: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o wire/peer_wiregen.o devtools/gossipwith.o common/cryptomsg.o common/cryptomsg.o common/crypto_sync.o -$(DEVTOOLS_OBJS) $(DEVTOOLS_TOOL_OBJS): wire/wire.h devtools/gen_print_wire.h devtools/gen_print_onion_wire.h -devtools/gen_print_wire.o: devtools/gen_print_wire.h wire/gen_peer_wire.h devtools/print_wire.h -devtools/gen_print_onion_wire.o: devtools/gen_print_onion_wire.h devtools/print_wire.h +$(DEVTOOLS_OBJS) $(DEVTOOLS_TOOL_OBJS): wire/wire.h devtools/mkcommit: $(DEVTOOLS_COMMON_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) common/derive_basepoints.o common/keyset.o common/key_derive.o common/initial_commit_tx.o common/permute_tx.o wire/fromwire.o wire/towire.o devtools/mkcommit.o channeld/full_channel.o common/initial_channel.o common/htlc_state.o common/pseudorand.o common/htlc_tx.o channeld/commit_tx.o common/htlc_trim.o @@ -102,11 +86,11 @@ devtools/topology: $(DEVTOOLS_COMMON_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fro # Make sure these depend on everything. ALL_PROGRAMS += $(DEVTOOLS) -ALL_OBJS += $(DEVTOOLS_OBJS) $(DEVTOOLS_TOOL_OBJS) +ALL_OBJS += $(DEVTOOLS_TOOL_OBJS) check-source: $(DEVTOOLS_SRC:%=check-src-include-order/%) $(DEVTOOLS_TOOLS_SRC:%=check-src-include-order/%) clean: devtools-clean devtools-clean: - $(RM) $(DEVTOOLS_OBJS) $(DEVTOOLS_TOOL_OBJS) devtools/bolt11-cli devtools/decodemsg devtools/onion devtools/gen_print_wire.[c,h,o] devtools/gen_print_onion_wire.[c,h,o] + $(RM) $(DEVTOOLS_TOOL_OBJS) $(DEVTOOLS) diff --git a/devtools/create-gossipstore.c b/devtools/create-gossipstore.c index c132bc8cc..a5699ad99 100644 --- a/devtools/create-gossipstore.c +++ b/devtools/create-gossipstore.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include struct scidsat { @@ -175,7 +175,7 @@ int main(int argc, char *argv[]) if (verbose) fprintf(stderr, "%s\n", - wire_type_name(fromwire_peektype(inmsg))); + peer_wire_name(fromwire_peektype(inmsg))); switch (fromwire_peektype(inmsg)) { case WIRE_CHANNEL_ANNOUNCEMENT: @@ -242,7 +242,7 @@ int main(int argc, char *argv[]) default: warnx("Unknown message %u (%s)", fromwire_peektype(inmsg), - wire_type_name(fromwire_peektype(inmsg))); + peer_wire_name(fromwire_peektype(inmsg))); tal_free(inmsg); continue; } diff --git a/devtools/decodemsg.c b/devtools/decodemsg.c index 4938ebdb6..3bfd7d682 100644 --- a/devtools/decodemsg.c +++ b/devtools/decodemsg.c @@ -3,10 +3,10 @@ #include #include #include -#include -#include #include #include +#include +#include int main(int argc, char *argv[]) { @@ -37,13 +37,13 @@ int main(int argc, char *argv[]) if (onion) if (tlv_name) - printonion_type_tlv_message(tlv_name, m); + printonion_wire_tlv_message(tlv_name, m); else - printonion_type_message(m); + printonion_wire_message(m); else if (tlv_name) - printwire_type_tlv_message(tlv_name, m); + printpeer_wire_tlv_message(tlv_name, m); else - printwire_type_message(m); + printpeer_wire_message(m); } else { u8 *f = grab_fd(NULL, STDIN_FILENO); size_t off = 0; @@ -64,13 +64,13 @@ int main(int argc, char *argv[]) m = tal_dup_arr(f, u8, f + off, be16_to_cpu(len), 0); if (onion) if (tlv_name) - printonion_type_tlv_message(tlv_name, m); + printonion_wire_tlv_message(tlv_name, m); else - printonion_type_message(m); + printonion_wire_message(m); else if (tlv_name) - printwire_type_tlv_message(tlv_name, m); + printpeer_wire_tlv_message(tlv_name, m); else - printwire_type_message(m); + printpeer_wire_message(m); off += be16_to_cpu(len); tal_free(m); } diff --git a/devtools/dump-gossipstore.c b/devtools/dump-gossipstore.c index 2cb54df70..9d05be4dd 100644 --- a/devtools/dump-gossipstore.c +++ b/devtools/dump-gossipstore.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include int main(int argc, char *argv[]) { diff --git a/devtools/mkgossip.c b/devtools/mkgossip.c index a365ce47d..47fd81d70 100644 --- a/devtools/mkgossip.c +++ b/devtools/mkgossip.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include static bool verbose = false; diff --git a/devtools/mkquery.c b/devtools/mkquery.c index c3b07ef6a..b2f4911d5 100644 --- a/devtools/mkquery.c +++ b/devtools/mkquery.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include static void usage(void) diff --git a/devtools/onion.c b/devtools/onion.c index cad17c62f..f02ac1795 100644 --- a/devtools/onion.c +++ b/devtools/onion.c @@ -124,7 +124,7 @@ static struct route_step *decode_with_privkey(const tal_t *ctx, const u8 *onion, struct privkey seckey; struct route_step *step; struct onionpacket packet; - enum onion_type why_bad; + enum onion_wire why_bad; struct secret shared_secret; if (!hex_decode(hexprivkey, strlen(hexprivkey), &seckey, sizeof(seckey))) errx(1, "Invalid private key hex '%s'", hexprivkey); @@ -132,7 +132,7 @@ static struct route_step *decode_with_privkey(const tal_t *ctx, const u8 *onion, why_bad = parse_onionpacket(onion, TOTAL_PACKET_SIZE, &packet); if (why_bad != 0) - errx(1, "Error parsing message: %s", onion_type_name(why_bad)); + errx(1, "Error parsing message: %s", onion_wire_name(why_bad)); if (!onion_shared_secret(&shared_secret, &packet, &seckey)) errx(1, "Error creating shared secret."); diff --git a/devtools/print_wire.h b/devtools/print_wire.h index 56dfc3c6d..a7300119c 100644 --- a/devtools/print_wire.h +++ b/devtools/print_wire.h @@ -3,8 +3,8 @@ #include #include #include -#include -#include +#include +#include struct tlv_print_record_type { u64 type; diff --git a/gossipd/Makefile b/gossipd/Makefile index 2b328b2e8..96d8a66d3 100644 --- a/gossipd/Makefile +++ b/gossipd/Makefile @@ -79,7 +79,7 @@ GOSSIPD_COMMON_OBJS := \ common/wire_error.o \ connectd/connectd_gossipd_wiregen.o \ lightningd/gossip_msg.o \ - wire/gen_onion_wire.o + wire/onion_wiregen.o $(LIGHTNINGD_GOSSIP_OBJS) $(LIGHTNINGD_GOSSIP_CLIENT_OBJS): $(LIGHTNINGD_HEADERS) $(LIGHTNINGD_GOSSIP_HEADERS) diff --git a/gossipd/gossip_generation.c b/gossipd/gossip_generation.c index c82a415db..c4cea5c89 100644 --- a/gossipd/gossip_generation.c +++ b/gossipd/gossip_generation.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include /* Create a node_announcement with the given signature. It may be NULL in the diff --git a/gossipd/gossip_store.c b/gossipd/gossip_store.c index 944e4d54d..04396e7d3 100644 --- a/gossipd/gossip_store.c +++ b/gossipd/gossip_store.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #define GOSSIP_STORE_FILENAME "gossip_store" diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index 1e5c397c4..0a6932b9d 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -63,7 +63,7 @@ #include #include #include -#include +#include #include #include @@ -439,7 +439,7 @@ static struct io_plan *peer_msg_in(struct io_conn *conn, bool ok; /* These are messages relayed from peer */ - switch ((enum wire_type)fromwire_peektype(msg)) { + switch ((enum peer_wire)fromwire_peektype(msg)) { case WIRE_CHANNEL_ANNOUNCEMENT: err = handle_channel_announcement_msg(peer, msg); goto handled_relay; @@ -493,7 +493,7 @@ static struct io_plan *peer_msg_in(struct io_conn *conn, #endif status_broken("peer %s: relayed unexpected msg of type %s", type_to_string(tmpctx, struct node_id, &peer->id), - wire_type_name(fromwire_peektype(msg))); + peer_wire_name(fromwire_peektype(msg))); return io_close(conn); } diff --git a/gossipd/gossipd_wire.csv b/gossipd/gossipd_wire.csv index 7b71bf527..b91aaf9a7 100644 --- a/gossipd/gossipd_wire.csv +++ b/gossipd/gossipd_wire.csv @@ -1,7 +1,7 @@ #include #include #include -#include +#include # Initialize the gossip daemon. msgtype,gossipd_init,3000 diff --git a/gossipd/queries.c b/gossipd/queries.c index d007199a7..62e557066 100644 --- a/gossipd/queries.c +++ b/gossipd/queries.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include diff --git a/gossipd/routing.c b/gossipd/routing.c index d36251f55..87f25e954 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #ifndef SUPERVERBOSE #define SUPERVERBOSE(...) @@ -536,7 +536,7 @@ static void bad_gossip_order(const u8 *msg, { status_peer_debug(peer ? &peer->id : NULL, "Bad gossip order: %s before announcement %s", - wire_type_name(fromwire_peektype(msg)), + peer_wire_name(fromwire_peektype(msg)), details); } diff --git a/gossipd/routing.h b/gossipd/routing.h index 186a48652..6c0c1b53f 100644 --- a/gossipd/routing.h +++ b/gossipd/routing.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include struct daemon; diff --git a/gossipd/seeker.c b/gossipd/seeker.c index 6428ad029..35656a2a1 100644 --- a/gossipd/seeker.c +++ b/gossipd/seeker.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #define GOSSIP_SEEKER_INTERVAL(seeker) \ DEV_FAST_GOSSIP((seeker)->daemon->rstate->dev_fast_gossip, 5, 60) diff --git a/gossipd/test/Makefile b/gossipd/test/Makefile index fa7938c6c..3396c415a 100644 --- a/gossipd/test/Makefile +++ b/gossipd/test/Makefile @@ -17,7 +17,7 @@ GOSSIPD_TEST_COMMON_OBJS := \ common/pseudorand.o \ common/type_to_string.o \ common/utils.o \ - wire/gen_peer_wire.o \ + wire/peer_wiregen.o \ wire/fromwire.o \ wire/towire.o diff --git a/hsmd/Makefile b/hsmd/Makefile index 2f5f9d0ef..9e020aafa 100644 --- a/hsmd/Makefile +++ b/hsmd/Makefile @@ -63,6 +63,6 @@ check-whitespace: $(LIGHTNINGD_HSM_ALLSRC_NOGEN:%=check-whitespace/%) $(LIGHTNIN clean: lightningd/hsm-clean lightningd/hsm-clean: - $(RM) $(LIGHTNINGD_HSM_OBJS) hsmd/gen_* + $(RM) $(LIGHTNINGD_HSM_OBJS) -include hsmd/test/Makefile diff --git a/hsmd/hsmd.c b/hsmd/hsmd.c index 196458911..63604b89b 100644 --- a/hsmd/hsmd.c +++ b/hsmd/hsmd.c @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include /*~ Each subdaemon is started with stdin connected to lightningd (for status diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index 7ca86112d..fa5488eb3 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include static void update_feerates(struct lightningd *ld, struct channel *channel) @@ -406,7 +406,7 @@ static unsigned channel_msg(struct subd *sd, const u8 *msg, const int *fds) break; } - switch ((enum common_wire_type)t) { + switch ((enum common_wire)t) { #if DEVELOPER case WIRE_CUSTOMMSG_IN: handle_custommsg_in(sd->ld, sd->node_id, msg); diff --git a/lightningd/connect_control.c b/lightningd/connect_control.c index 7969fc282..e2cdd3c56 100644 --- a/lightningd/connect_control.c +++ b/lightningd/connect_control.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include struct connect { diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index fcd56c40e..22ee65ade 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include static void got_txout(struct bitcoind *bitcoind, diff --git a/lightningd/htlc_end.h b/lightningd/htlc_end.h index 0673260fc..554350c7c 100644 --- a/lightningd/htlc_end.h +++ b/lightningd/htlc_end.h @@ -7,7 +7,7 @@ #include #include #include -#include +#include /* We look up HTLCs by channel & id */ struct htlc_key { @@ -37,7 +37,7 @@ struct htlc_in { struct secret *shared_secret; /* If we couldn't decode the onion, this contains the error code.. */ - enum onion_type badonion; + enum onion_wire badonion; /* Otherwise, this contains the failure message to send. */ const struct onionreply *failonion; diff --git a/lightningd/htlc_set.h b/lightningd/htlc_set.h index fa6c070c1..3657df192 100644 --- a/lightningd/htlc_set.h +++ b/lightningd/htlc_set.h @@ -7,7 +7,7 @@ #include #include #include -#include +#include struct htlc_in; struct lightningd; diff --git a/lightningd/invoice.h b/lightningd/invoice.h index e50d87ca2..1ccffda4a 100644 --- a/lightningd/invoice.h +++ b/lightningd/invoice.h @@ -1,7 +1,7 @@ #ifndef LIGHTNING_LIGHTNINGD_INVOICE_H #define LIGHTNING_LIGHTNINGD_INVOICE_H #include "config.h" -#include +#include struct amount_msat; struct htlc_set; diff --git a/lightningd/notification.c b/lightningd/notification.c index 99d794440..377da2c13 100644 --- a/lightningd/notification.c +++ b/lightningd/notification.c @@ -215,7 +215,7 @@ static void forward_event_notification_serialize(struct json_stream *stream, const struct short_channel_id *scid_out, const struct amount_msat *amount_out, enum forward_status state, - enum onion_type failcode, + enum onion_wire failcode, struct timeabs *resolved_time) { /* Here is more neat to initial a forwarding structure than @@ -256,7 +256,7 @@ void notify_forward_event(struct lightningd *ld, const struct short_channel_id *scid_out, const struct amount_msat *amount_out, enum forward_status state, - enum onion_type failcode, + enum onion_wire failcode, struct timeabs *resolved_time) { void (*serialize)(struct json_stream *, @@ -264,7 +264,7 @@ void notify_forward_event(struct lightningd *ld, const struct short_channel_id *, const struct amount_msat *, enum forward_status, - enum onion_type, + enum onion_wire, struct timeabs *) = forward_event_notification_gen.serialize; struct jsonrpc_notification *n diff --git a/lightningd/notification.h b/lightningd/notification.h index 62d6069c4..a0b248e1f 100644 --- a/lightningd/notification.h +++ b/lightningd/notification.h @@ -17,7 +17,7 @@ #include #include #include -#include +#include struct onionreply; @@ -62,7 +62,7 @@ void notify_forward_event(struct lightningd *ld, /* May be NULL. */ const struct amount_msat *amount_out, enum forward_status state, - enum onion_type failcode, + enum onion_wire failcode, struct timeabs *resolved_time); void notify_sendpay_success(struct lightningd *ld, diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index d8420fc14..e98b3ea3e 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include @@ -990,7 +990,7 @@ static unsigned int openingd_msg(struct subd *openingd, break; } - switch ((enum common_wire_type)t) { + switch ((enum common_wire)t) { #if DEVELOPER case WIRE_CUSTOMMSG_IN: handle_custommsg_in(openingd->ld, openingd->node_id, msg); diff --git a/lightningd/pay.c b/lightningd/pay.c index 6d015ca95..319e8840f 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -25,7 +25,7 @@ /* Routing failure object */ struct routing_failure { unsigned int erring_index; - enum onion_type failcode; + enum onion_wire failcode; const struct node_id *erring_node; const struct short_channel_id *erring_channel; int channel_dir; @@ -144,13 +144,13 @@ static struct command_result *sendpay_success(struct command *cmd, static void json_add_routefail_info(struct json_stream *js, unsigned int erring_index, - enum onion_type failcode, + enum onion_wire failcode, const struct node_id *erring_node, const struct short_channel_id *erring_channel, int channel_dir, const u8 *msg) { - const char *failcodename = onion_type_name(failcode); + const char *failcodename = onion_wire_name(failcode); json_add_num(js, "erring_index", erring_index); json_add_num(js, "failcode", failcode); @@ -201,7 +201,7 @@ static const char *sendpay_errmsg_fmt(const tal_t *ctx, errcode_t pay_errcode, else { assert(fail); errmsg = tal_fmt(ctx, "failed: %s (%s)", - onion_type_name(fail->failcode), details); + onion_wire_name(fail->failcode), details); } return errmsg; } @@ -313,7 +313,7 @@ void payment_succeeded(struct lightningd *ld, struct htlc_out *hout, static struct routing_failure* immediate_routing_failure(const tal_t *ctx, const struct lightningd *ld, - enum onion_type failcode, + enum onion_wire failcode, const struct short_channel_id *channel0, const struct node_id *dstid) { @@ -340,7 +340,7 @@ static struct routing_failure* local_routing_failure(const tal_t *ctx, const struct lightningd *ld, const struct htlc_out *hout, - enum onion_type failcode, + enum onion_wire failcode, const struct wallet_payment *payment) { struct routing_failure *routing_failure; @@ -366,7 +366,7 @@ local_routing_failure(const tal_t *ctx, log_debug(hout->key.channel->log, "local_routing_failure: %u (%s)", routing_failure->failcode, - onion_type_name(routing_failure->failcode)); + onion_wire_name(routing_failure->failcode)); return routing_failure; } @@ -380,7 +380,7 @@ remote_routing_failure(const tal_t *ctx, struct log *log, errcode_t *pay_errcode) { - enum onion_type failcode = fromwire_peektype(failuremsg); + enum onion_wire failcode = fromwire_peektype(failuremsg); struct routing_failure *routing_failure; const struct node_id *route_nodes; const struct node_id *erring_node; @@ -538,7 +538,7 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout, /* This gives more details than a generic failure message */ if (localfail) { /* Use temporary_channel_failure if failmsg has it */ - enum onion_type failcode; + enum onion_wire failcode; if (failmsg_needs_update) failcode = fromwire_peektype(failmsg_needs_update); else @@ -583,7 +583,7 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout, fail = NULL; pay_errcode = PAY_UNPARSEABLE_ONION; } else { - enum onion_type failcode; + enum onion_wire failcode; use_failmsg: failcode = fromwire_peektype(failmsg); @@ -593,7 +593,7 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout, "with code 0x%04x (%s)", hout->key.id, origin_index, - failcode, onion_type_name(failcode)); + failcode, onion_wire_name(failcode)); fail = remote_routing_failure(tmpctx, ld, payment, failmsg, origin_index, @@ -636,7 +636,7 @@ static struct command_result *wait_payment(struct lightningd *ld, struct onionreply *failonionreply; bool faildestperm; int failindex; - enum onion_type failcode; + enum onion_wire failcode; struct node_id *failnode; struct short_channel_id *failchannel; u8 *failupdate; @@ -1173,7 +1173,7 @@ static struct command_result *json_sendonion(struct command *cmd, { u8 *onion; struct onionpacket packet; - enum onion_type failcode; + enum onion_wire failcode; struct route_hop *first_hop; struct sha256 *payment_hash; struct lightningd *ld = cmd->ld; diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 8231d06e8..f1497fac9 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -57,8 +57,8 @@ #include #include #include -#include -#include +#include +#include #include struct close_command { @@ -2376,14 +2376,14 @@ static struct command_result *json_sendcustommsg(struct command *cmd, return command_param_failed(); type = fromwire_peektype(msg); - if (wire_type_is_defined(type)) { + if (peer_wire_is_defined(type)) { return command_fail( cmd, JSONRPC2_INVALID_REQUEST, "Cannot send messages of type %d (%s). It is not possible " "to send messages that have a type managed internally " "since that might cause issues with the internal state " "tracking.", - type, wire_type_name(type)); + type, peer_wire_name(type)); } if (type % 2 == 0) { diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index d648c1e9e..4e737bbd4 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #ifndef SUPERVERBOSE @@ -105,7 +105,7 @@ static bool htlc_out_update_state(struct channel *channel, static struct failed_htlc *mk_failed_htlc_badonion(const tal_t *ctx, const struct htlc_in *hin, - enum onion_type badonion) + enum onion_wire badonion) { struct failed_htlc *f = tal(ctx, struct failed_htlc); @@ -224,7 +224,7 @@ static void fail_in_htlc(struct htlc_in *hin, /* Immediately fail HTLC with a BADONION code */ static void local_fail_in_htlc_badonion(struct htlc_in *hin, - enum onion_type badonion) + enum onion_wire badonion) { struct failed_htlc *failed_htlc; assert(!hin->preimage); @@ -555,7 +555,7 @@ static void rcvd_htlc_reply(struct subd *subd, const u8 *msg, const int *fds UNU hout->failmsg = tal_steal(hout, failmsg); if (hout->am_origin) { char *localfail = tal_fmt(msg, "%s: %s", - onion_type_name(fromwire_peektype(failmsg)), + onion_wire_name(fromwire_peektype(failmsg)), failurestr); payment_failed(ld, hout, localfail, NULL); @@ -1119,7 +1119,7 @@ static bool ecdh_maybe_blinding(const struct pubkey *ephemeral_key, static bool peer_accepted_htlc(const tal_t *ctx, struct channel *channel, u64 id, bool replay, - enum onion_type *badonion, + enum onion_wire *badonion, u8 **failmsg) { struct htlc_in *hin; @@ -1185,7 +1185,7 @@ static bool peer_accepted_htlc(const tal_t *ctx, log_debug(channel->log, "Rejecting their htlc %"PRIu64 " since onion is unparsable %s", - id, onion_type_name(*badonion)); + id, onion_wire_name(*badonion)); /* Now we can fail it. */ goto fail; } @@ -1198,7 +1198,7 @@ static bool peer_accepted_htlc(const tal_t *ctx, log_debug(channel->log, "Rejecting their htlc %"PRIu64 " since onion is unprocessable %s ss=%s", - id, onion_type_name(*badonion), + id, onion_wire_name(*badonion), type_to_string(tmpctx, struct secret, hin->shared_secret)); goto fail; } @@ -1433,7 +1433,7 @@ void onchain_failed_our_htlc(const struct channel *channel, if (hout->am_origin) { assert(why != NULL); char *localfail = tal_fmt(channel, "%s: %s", - onion_type_name(WIRE_PERMANENT_CHANNEL_FAILURE), + onion_wire_name(WIRE_PERMANENT_CHANNEL_FAILURE), why); payment_failed(ld, hout, localfail, NULL); tal_free(localfail); @@ -1457,7 +1457,7 @@ static void remove_htlc_in(struct channel *channel, struct htlc_in *hin) log_debug(channel->log, "Removing in HTLC %"PRIu64" state %s %s", hin->key.id, htlc_state_name(hin->hstate), hin->preimage ? "FULFILLED" - : hin->badonion ? onion_type_name(hin->badonion) + : hin->badonion ? onion_wire_name(hin->badonion) : "REMOTEFAIL"); /* If we fulfilled their HTLC, credit us. */ @@ -1503,7 +1503,7 @@ static void remove_htlc_out(struct channel *channel, struct htlc_out *hout) log_debug(channel->log, "Removing out HTLC %"PRIu64" state %s %s", hout->key.id, htlc_state_name(hout->hstate), hout->preimage ? "FULFILLED" - : hout->failmsg ? onion_type_name(fromwire_peektype(hout->failmsg)) + : hout->failmsg ? onion_wire_name(fromwire_peektype(hout->failmsg)) : "REMOTEFAIL"); /* If it's failed, now we can forward since it's completely locked-in */ @@ -1777,7 +1777,7 @@ static bool channel_added_their_htlc(struct channel *channel, struct htlc_in *hin; struct secret shared_secret; struct onionpacket op; - enum onion_type failcode; + enum onion_wire failcode; /* BOLT #2: * @@ -2042,7 +2042,7 @@ void peer_got_revoke(struct channel *channel, const u8 *msg) struct secret per_commitment_secret; struct pubkey next_per_commitment_point; struct changed_htlc *changed; - enum onion_type *badonions; + enum onion_wire *badonions; u8 **failmsgs; size_t i; struct lightningd *ld = channel->peer->ld; @@ -2069,7 +2069,7 @@ void peer_got_revoke(struct channel *channel, const u8 *msg) revokenum, tal_count(changed)); /* Save any immediate failures for after we reply. */ - badonions = tal_arrz(msg, enum onion_type, tal_count(changed)); + badonions = tal_arrz(msg, enum onion_wire, tal_count(changed)); failmsgs = tal_arrz(msg, u8 *, tal_count(changed)); for (i = 0; i < tal_count(changed); i++) { /* If we're doing final accept, we need to forward */ @@ -2456,7 +2456,7 @@ void htlcs_resubmit(struct lightningd *ld, { struct htlc_in *hin; struct htlc_in_map_iter ini; - enum onion_type badonion COMPILER_WANTS_INIT("gcc7.4.0 bad, 8.3 OK"); + enum onion_wire badonion COMPILER_WANTS_INIT("gcc7.4.0 bad, 8.3 OK"); u8 *failmsg; /* Now retry any which were stuck. */ @@ -2555,7 +2555,7 @@ void json_format_forwarding_object(struct json_stream *response, if (cur->failcode != 0) { json_add_num(response, "failcode", cur->failcode); json_add_string(response, "failreason", - onion_type_name(cur->failcode)); + onion_wire_name(cur->failcode)); } #ifdef COMPAT_V070 diff --git a/lightningd/subd.c b/lightningd/subd.c index f28a4a300..97ba3c1c5 100644 --- a/lightningd/subd.c +++ b/lightningd/subd.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include static bool move_fd(int from, int to) @@ -747,7 +747,7 @@ void subd_send_msg(struct subd *sd, const u8 *msg_out) u16 type = fromwire_peektype(msg_out); /* FIXME: We should use unique upper bits for each daemon, then * have generate-wire.py add them, just assert here. */ - assert(!strstarts(common_wire_type_name(type), "INVALID") || + assert(!strstarts(common_wire_name(type), "INVALID") || !strstarts(sd->msgname(type), "INVALID")); msg_enqueue(sd->outq, msg_out); } diff --git a/onchaind/Makefile b/onchaind/Makefile index 2d80af1cf..350ed0a4a 100644 --- a/onchaind/Makefile +++ b/onchaind/Makefile @@ -95,6 +95,6 @@ check-whitespace: $(LIGHTNINGD_ONCHAIN_SRC_NOGEN:%=check-whitespace/%) $(LIGHTNI clean: onchaind-clean onchaind-clean: - $(RM) $(LIGHTNINGD_ONCHAIN_OBJS) onchaind/gen_* + $(RM) $(LIGHTNINGD_ONCHAIN_OBJS) -include onchaind/test/Makefile diff --git a/openingd/Makefile b/openingd/Makefile index 8dfe0a8da..6ee91d50a 100644 --- a/openingd/Makefile +++ b/openingd/Makefile @@ -104,6 +104,6 @@ check-whitespace: $(LIGHTNINGD_OPENING_SRC_NOGEN:%=check-whitespace/%) $(LIGHTNI clean: opening-clean opening-clean: - $(RM) $(LIGHTNINGD_OPENING_OBJS) openingd/gen_* + $(RM) $(LIGHTNINGD_OPENING_OBJS) -include openingd/test/Makefile diff --git a/openingd/openingd.c b/openingd/openingd.c index 49aa60a2d..41c6e65fb 100644 --- a/openingd/openingd.c +++ b/openingd/openingd.c @@ -49,9 +49,9 @@ #include #include #include -#include -#include +#include #include +#include #include #include @@ -485,7 +485,7 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state, * this could be connectd itself, in fact. */ if (is_wrong_channel(msg, &state->channel_id, &actual)) { status_debug("Rejecting %s for unknown channel_id %s", - wire_type_name(fromwire_peektype(msg)), + peer_wire_name(fromwire_peektype(msg)), type_to_string(tmpctx, struct channel_id, &actual)); sync_crypto_write(state->pps, @@ -1324,7 +1324,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) static u8 *handle_peer_in(struct state *state) { u8 *msg = sync_crypto_read(tmpctx, state->pps); - enum wire_type t = fromwire_peektype(msg); + enum peer_wire t = fromwire_peektype(msg); struct channel_id channel_id; if (t == WIRE_OPEN_CHANNEL) @@ -1332,8 +1332,8 @@ static u8 *handle_peer_in(struct state *state) #if DEVELOPER /* Handle custommsgs */ - enum wire_type type = fromwire_peektype(msg); - if (type % 2 == 1 && !wire_type_is_defined(type)) { + enum peer_wire type = fromwire_peektype(msg); + if (type % 2 == 1 && !peer_wire_is_defined(type)) { /* The message is not part of the messages we know how to * handle. Assuming this is a custommsg, we just forward it to the * master. */ @@ -1351,13 +1351,13 @@ static u8 *handle_peer_in(struct state *state) take(towire_errorfmt(NULL, extract_channel_id(msg, &channel_id) ? &channel_id : NULL, "Unexpected message %s: %s", - wire_type_name(t), + peer_wire_name(t), tal_hex(tmpctx, msg)))); /* FIXME: We don't actually want master to try to send an * error, since peer is transient. This is a hack. */ - status_broken("Unexpected message %s", wire_type_name(t)); + status_broken("Unexpected message %s", peer_wire_name(t)); peer_failed_connection_lost(); } @@ -1483,7 +1483,7 @@ static u8 *handle_master_in(struct state *state) } /* Now handle common messages. */ - switch ((enum common_wire_type)t) { + switch ((enum common_wire)t) { #if DEVELOPER case WIRE_CUSTOMMSG_OUT: openingd_send_custommsg(state, msg); diff --git a/plugins/Makefile b/plugins/Makefile index e89d6ee02..3a2c1510a 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -77,7 +77,7 @@ PLUGIN_COMMON_OBJS := \ common/version.o \ common/wireaddr.o \ wire/fromwire.o \ - wire/gen_onion_wire.o \ + wire/onion_wiregen.o \ wire/tlvstream.o \ wire/towire.o @@ -90,7 +90,7 @@ plugins/fundchannel: common/addr.o $(PLUGIN_FUNDCHANNEL_OBJS) $(PLUGIN_LIB_OBJS) plugins/bcli: bitcoin/chainparams.o $(PLUGIN_BCLI_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) -plugins/keysend: bitcoin/chainparams.o wire/tlvstream.o wire/gen_onion_wire.o $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) +plugins/keysend: bitcoin/chainparams.o wire/tlvstream.o wire/onion_wiregen.o $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(PLUGIN_KEYSEND_OBJS): $(PLUGIN_PAY_LIB_HEADER) $(PLUGIN_ALL_OBJS): $(PLUGIN_LIB_HEADER) diff --git a/plugins/keysend.c b/plugins/keysend.c index 8dc5a419b..f21f51c32 100644 --- a/plugins/keysend.c +++ b/plugins/keysend.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #define PREIMAGE_TLV_TYPE 5482373484 #define KEYSEND_FEATUREBIT 55 diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index c198b0480..e1835eefd 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -862,7 +862,7 @@ failure_is_blockheight_disagreement(const struct payment *p, return true; } -static char *describe_failcode(const tal_t *ctx, enum onion_type failcode) +static char *describe_failcode(const tal_t *ctx, enum onion_wire failcode) { char *rv = tal_strdup(ctx, ""); if (failcode & BADONION) { @@ -889,7 +889,7 @@ static struct command_result * handle_final_failure(struct command *cmd, struct payment *p, const struct node_id *final_id, - enum onion_type failcode) + enum onion_wire failcode) { u32 unused; @@ -905,7 +905,7 @@ handle_final_failure(struct command *cmd, paymod_log(p, LOG_DBG, "Final node %s reported %04x (%s) on route %s", type_to_string(tmpctx, struct node_id, final_id), - failcode, onion_type_name(failcode), + failcode, onion_wire_name(failcode), p->routetxt); /* We use an exhaustive switch statement here so you get a compile @@ -998,14 +998,14 @@ handle_intermediate_failure(struct command *cmd, struct payment *p, const struct node_id *errnode, const struct route_hop *errchan, - enum onion_type failcode) + enum onion_wire failcode) { struct payment *root = payment_root(p); paymod_log(p, LOG_DBG, "Intermediate node %s reported %04x (%s) at %s on route %s", type_to_string(tmpctx, struct node_id, errnode), - failcode, onion_type_name(failcode), + failcode, onion_wire_name(failcode), type_to_string(tmpctx, struct short_channel_id, &errchan->channel_id), p->routetxt); diff --git a/plugins/libplugin-pay.h b/plugins/libplugin-pay.h index d1bb3aea2..8c5b5dfe0 100644 --- a/plugins/libplugin-pay.h +++ b/plugins/libplugin-pay.h @@ -4,7 +4,7 @@ #include #include -#include +#include struct legacy_payload { struct short_channel_id scid; @@ -46,7 +46,7 @@ struct payment_result { struct preimage *payment_preimage; u32 code; const char* failcodename; - enum onion_type failcode; + enum onion_wire failcode; const u8 *raw_message; const char *message; u32 *erring_index; diff --git a/tools/test/Makefile b/tools/test/Makefile index 6a2534cca..8e90bcf0a 100644 --- a/tools/test/Makefile +++ b/tools/test/Makefile @@ -39,7 +39,7 @@ tools/test/gen_test.c.tmp.c: $(TOOLS_WIRE_DEPS) tools/test/gen_test.c: tools/test/gen_test.c.tmp.c $(EXTERNAL_HEADERS) tools/test/gen_test.h @MAKE=$(MAKE) tools/update-mocks.sh "$<" $(SUPPRESS_OUTPUT) && mv "$<" "$@" -tools/test/gen_print.h: wire/gen_onion_wire.h $(TOOLS_WIRE_DEPS) +tools/test/gen_print.h: wire/onion_wiregen.h $(TOOLS_WIRE_DEPS) $(BOLT_GEN) -P --page header $@ test_type < tools/test/test_cases > $@ tools/test/gen_print.c: $(TOOLS_WIRE_DEPS) diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 69fb47d27..427cda0ed 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -439,7 +439,7 @@ void notify_forward_event(struct lightningd *ld UNNEEDED, /* May be NULL. */ const struct amount_msat *amount_out UNNEEDED, enum forward_status state UNNEEDED, - enum onion_type failcode UNNEEDED, + enum onion_wire failcode UNNEEDED, struct timeabs *resolved_time UNNEEDED) { fprintf(stderr, "notify_forward_event called!\n"); abort(); } /* Generated stub for onchaind_funding_spent */ @@ -456,9 +456,9 @@ struct onion_payload *onion_decode(const tal_t *ctx UNNEEDED, u64 *failtlvtype UNNEEDED, size_t *failtlvpos UNNEEDED) { fprintf(stderr, "onion_decode called!\n"); abort(); } -/* Generated stub for onion_type_name */ -const char *onion_type_name(int e UNNEEDED) -{ fprintf(stderr, "onion_type_name called!\n"); abort(); } +/* Generated stub for onion_wire_name */ +const char *onion_wire_name(int e UNNEEDED) +{ fprintf(stderr, "onion_wire_name called!\n"); abort(); } /* Generated stub for outpointfilter_add */ void outpointfilter_add(struct outpointfilter *of UNNEEDED, const struct bitcoin_txid *txid UNNEEDED, const u32 outnum UNNEEDED) @@ -544,7 +544,7 @@ struct command_result *param_tok(struct command *cmd UNNEEDED, const char *name const jsmntok_t **out UNNEEDED) { fprintf(stderr, "param_tok called!\n"); abort(); } /* Generated stub for parse_onionpacket */ -enum onion_type parse_onionpacket(const u8 *src UNNEEDED, +enum onion_wire parse_onionpacket(const u8 *src UNNEEDED, const size_t srclen UNNEEDED, struct onionpacket *dest UNNEEDED) { fprintf(stderr, "parse_onionpacket called!\n"); abort(); } @@ -582,6 +582,12 @@ void peer_start_openingd(struct peer *peer UNNEEDED, struct per_peer_state *pps UNNEEDED, const u8 *msg UNNEEDED) { fprintf(stderr, "peer_start_openingd called!\n"); abort(); } +/* Generated stub for peer_wire_is_defined */ +bool peer_wire_is_defined(u16 type UNNEEDED) +{ fprintf(stderr, "peer_wire_is_defined called!\n"); abort(); } +/* Generated stub for peer_wire_name */ +const char *peer_wire_name(int e UNNEEDED) +{ fprintf(stderr, "peer_wire_name called!\n"); abort(); } /* Generated stub for per_peer_state_set_fds */ void per_peer_state_set_fds(struct per_peer_state *pps UNNEEDED, int peer_fd UNNEEDED, int gossip_fd UNNEEDED, int gossip_store_fd UNNEEDED) @@ -763,12 +769,6 @@ struct txowatch *watch_txo(const tal_t *ctx UNNEEDED, size_t input_num UNNEEDED, const struct block *block)) { fprintf(stderr, "watch_txo called!\n"); abort(); } -/* Generated stub for wire_type_is_defined */ -bool wire_type_is_defined(u16 type UNNEEDED) -{ fprintf(stderr, "wire_type_is_defined called!\n"); abort(); } -/* Generated stub for wire_type_name */ -const char *wire_type_name(int e UNNEEDED) -{ fprintf(stderr, "wire_type_name called!\n"); abort(); } /* Generated stub for wrap_onionreply */ struct onionreply *wrap_onionreply(const tal_t *ctx UNNEEDED, const struct secret *shared_secret UNNEEDED, diff --git a/wallet/wallet.c b/wallet/wallet.c index 12c663f52..71e102068 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -2103,7 +2103,7 @@ void wallet_htlc_save_out(struct wallet *wallet, void wallet_htlc_update(struct wallet *wallet, const u64 htlc_dbid, const enum htlc_state new_state, const struct preimage *payment_key, - enum onion_type badonion, + enum onion_wire badonion, const struct onionreply *failonion, const u8 *failmsg, bool *we_filled) @@ -2210,7 +2210,7 @@ static bool wallet_stmt2htlc_in(struct channel *channel, log_broken(channel->log, "Replacing incoming HTLC %"PRIu64" error " "%s with WIRE_TEMPORARY_NODE_FAILURE", - in->key.id, onion_type_name(in->badonion)); + in->key.id, onion_wire_name(in->badonion)); in->badonion = 0; in->failonion = create_onionreply(in, in->shared_secret, @@ -2888,7 +2888,7 @@ void wallet_payment_get_failinfo(const tal_t *ctx, struct onionreply **failonionreply, bool *faildestperm, int *failindex, - enum onion_type *failcode, + enum onion_wire *failcode, struct node_id **failnode, struct short_channel_id **failchannel, u8 **failupdate, @@ -2919,7 +2919,7 @@ void wallet_payment_get_failinfo(const tal_t *ctx, } *faildestperm = db_column_int(stmt, 1) != 0; *failindex = db_column_int(stmt, 2); - *failcode = (enum onion_type) db_column_int(stmt, 3); + *failcode = (enum onion_wire) db_column_int(stmt, 3); if (db_column_is_null(stmt, 4)) *failnode = NULL; else { @@ -2958,7 +2958,7 @@ void wallet_payment_set_failinfo(struct wallet *wallet, const struct onionreply *failonionreply, bool faildestperm, int failindex, - enum onion_type failcode, + enum onion_wire failcode, const struct node_id *failnode, const struct short_channel_id *failchannel, const u8 *failupdate /*tal_arr*/, @@ -3724,7 +3724,7 @@ static bool wallet_forwarded_payment_update(struct wallet *w, const struct htlc_in *in, const struct htlc_out *out, enum forward_status state, - enum onion_type failcode, + enum onion_wire failcode, struct timeabs *resolved_time) { struct db_stmt *stmt; @@ -3777,7 +3777,7 @@ void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in, const struct short_channel_id *scid_out, const struct htlc_out *out, enum forward_status state, - enum onion_type failcode) + enum onion_wire failcode) { struct db_stmt *stmt; struct timeabs *resolved_time; diff --git a/wallet/wallet.h b/wallet/wallet.h index 39feec833..18f38e79e 100644 --- a/wallet/wallet.h +++ b/wallet/wallet.h @@ -20,9 +20,8 @@ #include #include #include -#include +#include -enum onion_type; struct amount_msat; struct invoices; struct channel; @@ -194,7 +193,7 @@ struct forwarding { struct amount_msat msat_in, msat_out, fee; struct sha256 *payment_hash; enum forward_status status; - enum onion_type failcode; + enum onion_wire failcode; struct timeabs received_time; /* May not be present if the HTLC was not resolved yet. */ struct timeabs *resolved_time; @@ -662,7 +661,7 @@ void wallet_htlc_save_out(struct wallet *wallet, void wallet_htlc_update(struct wallet *wallet, const u64 htlc_dbid, const enum htlc_state new_state, const struct preimage *payment_key, - enum onion_type badonion, + enum onion_wire badonion, const struct onionreply *failonion, const u8 *failmsg, bool *we_filled); @@ -1075,7 +1074,7 @@ void wallet_payment_get_failinfo(const tal_t *ctx, struct onionreply **failonionreply, bool *faildestperm, int *failindex, - enum onion_type *failcode, + enum onion_wire *failcode, struct node_id **failnode, struct short_channel_id **failchannel, u8 **failupdate, @@ -1091,7 +1090,7 @@ void wallet_payment_set_failinfo(struct wallet *wallet, const struct onionreply *failonionreply, bool faildestperm, int failindex, - enum onion_type failcode, + enum onion_wire failcode, const struct node_id *failnode, const struct short_channel_id *failchannel, const u8 *failupdate, @@ -1251,7 +1250,7 @@ void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in, const struct short_channel_id *scid_out, const struct htlc_out *out, enum forward_status state, - enum onion_type failcode); + enum onion_wire failcode); /** * Retrieve summary of successful forwarded payments' fees diff --git a/wire/Makefile b/wire/Makefile index 7b1aa8759..8b2f7441b 100644 --- a/wire/Makefile +++ b/wire/Makefile @@ -10,9 +10,16 @@ WIRE_HEADERS_NOGEN := wire/onion_defs.h \ wire/wire.h \ wire/wire_sync.h \ wire/wire_io.h -WIRE_GEN_HEADERS := wire/gen_peer_wire.h wire/gen_onion_wire.h wire/gen_common_wire.h -WIRE_GEN_SRC := wire/gen_peer_wire.c wire/gen_common_wire.c -WIRE_GEN_ONION_SRC := wire/gen_onion_wire.c +WIRE_GEN_HEADERS := wire/peer_wiregen.h \ + wire/onion_wiregen.h \ + wire/common_wiregen.h \ + wire/peer_printgen.h \ + wire/onion_printgen.h + +WIRE_GEN_SRC := wire/peer_wiregen.c wire/common_wiregen.c +WIRE_GEN_ONION_SRC := wire/onion_wiregen.c +WIRE_GEN_PRINT_SRC := wire/peer_printgen.c wire/onion_printgen.c + WIRE_SRC := wire/wire_sync.c \ wire/wire_io.c \ wire/fromwire.c \ @@ -53,45 +60,34 @@ ifeq ($(EXPERIMENTAL_FEATURES),1) EXPERIMENTAL_PEER_PATCHES := $(sort $(wildcard wire/extracted_peer_experimental_*)) EXPERIMENTAL_ONION_PATCHES := $(sort $(wildcard wire/extracted_onion_experimental_*)) -wire/gen_peer_wire_csv: wire/extracted_peer_wire_csv $(EXPERIMENTAL_PEER_PATCHES) +wire/peer_wire.csv: wire/extracted_peer_wire_csv $(EXPERIMENTAL_PEER_PATCHES) @set -e; trap "rm -f $@.$$$$" 0; cp $< $@.$$$$; for exp in $(EXPERIMENTAL_PEER_PATCHES); do patch $@.$$$$ $$exp >/dev/null ; done; mv $@.$$$$ $@ -wire/gen_onion_wire_csv: wire/extracted_onion_wire_csv $(EXPERIMENTAL_ONION_PATCHES) +wire/onion_wire.csv: wire/extracted_onion_wire_csv $(EXPERIMENTAL_ONION_PATCHES) @set -e; trap "rm -f $@.$$$$" 0; cp $< $@.$$$$; for exp in $(EXPERIMENTAL_ONION_PATCHES); do patch $@.$$$$ $$exp; done >/dev/null ; mv $@.$$$$ $@ else # /* EXPERIMENTAL_FEATURES */ -wire/gen_peer_wire_csv: wire/extracted_peer_wire_csv +wire/peer_wire.csv: wire/extracted_peer_wire_csv @cp $< $@ -wire/gen_onion_wire_csv: wire/extracted_onion_wire_csv +wire/onion_wire.csv: wire/extracted_onion_wire_csv @cp $< $@ endif # We (may) need to rebuild these if config changes -wire/gen_peer_wire_csv wire/gen_onion_wire_csv: config.vars +wire/peer_wire.csv wire/onion_wire.csv: config.vars # tlvs_n1 and n2 are used for test vectors, thus not referenced: expose them # for testing and to prevent compile error about them being unused. # This will be easier if test vectors are moved to separate files. -wire/gen_peer_wire.h: wire/gen_peer_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile - $(BOLT_GEN) --include='common/channel_id.h' --include='bitcoin/tx.h' --include='bitcoin/preimage.h' --include='bitcoin/short_channel_id.h' --include='common/node_id.h' --include='common/bigsize.h' --include='bitcoin/block.h' --include='bitcoin/privkey.h' -s --expose-tlv-type=n1 --expose-tlv-type=n2 --page header $@ wire_type < $< > $@ +wire/peer_wiregen.h_args := --include='common/channel_id.h' --include='bitcoin/tx.h' --include='bitcoin/preimage.h' --include='bitcoin/short_channel_id.h' --include='common/node_id.h' --include='common/bigsize.h' --include='bitcoin/block.h' --include='bitcoin/privkey.h' -s --expose-tlv-type=n1 --expose-tlv-type=n2 -wire/gen_peer_wire.c: wire/gen_peer_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile - $(BOLT_GEN) -s --expose-tlv-type=n1 --expose-tlv-type=n2 --page impl ${@:.c=.h} wire_type < $< > $@ +wire/peer_wiregen.c_args := -s --expose-tlv-type=n1 --expose-tlv-type=n2 # The tlv_payload isn't parsed in a fromwire, so we need to expose it. -wire/gen_onion_wire.h: wire/gen_onion_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile - $(BOLT_GEN) --include='bitcoin/short_channel_id.h' --include='bitcoin/privkey.h' --include='common/bigsize.h' --include='common/amount.h' --include='common/node_id.h' --include='bitcoin/block.h' -s --expose-tlv-type=tlv_payload --page header $@ onion_type < $< > $@ +wire/onion_wiregen.h_args := --include='bitcoin/short_channel_id.h' --include='bitcoin/privkey.h' --include='common/bigsize.h' --include='common/amount.h' --include='common/node_id.h' --include='bitcoin/block.h' -s --expose-tlv-type=tlv_payload -wire/gen_onion_wire.c: wire/gen_onion_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile - $(BOLT_GEN) -s --expose-tlv-type=tlv_payload --page impl ${@:.c=.h} onion_type < $< > $@ - -# Some messages that are common among all daemons -wire/gen_common_wire.h: wire/common_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile - $(BOLT_GEN) -s --page header $@ common_wire_type < $< > $@ - -wire/gen_common_wire.c: wire/common_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile - $(BOLT_GEN) -s --page impl ${@:.c=.h} common_wire_type < $< > $@ +wire/onion_wiregen.c_args := -s --expose-tlv-type=tlv_payload check-source: $(WIRE_SRC:%=check-src-include-order/%) $(WIRE_HEADERS_NOGEN:%=check-hdr-include-order/%) diff --git a/wire/common_wire_csv b/wire/common_wire.csv similarity index 100% rename from wire/common_wire_csv rename to wire/common_wire.csv diff --git a/wire/peer_wire.c b/wire/peer_wire.c index 19313ee7f..5acf6dc04 100644 --- a/wire/peer_wire.c +++ b/wire/peer_wire.c @@ -1,7 +1,7 @@ #include #include -static bool unknown_type(enum wire_type t) +static bool unknown_type(enum peer_wire t) { switch (t) { case WIRE_INIT: @@ -42,7 +42,7 @@ static bool unknown_type(enum wire_type t) bool is_msg_for_gossipd(const u8 *cursor) { - switch ((enum wire_type)fromwire_peektype(cursor)) { + switch ((enum peer_wire)fromwire_peektype(cursor)) { case WIRE_CHANNEL_ANNOUNCEMENT: case WIRE_NODE_ANNOUNCEMENT: case WIRE_CHANNEL_UPDATE: @@ -83,7 +83,7 @@ bool is_msg_for_gossipd(const u8 *cursor) /* Return true if it's an unknown ODD message. cursor is a tal ptr. */ bool is_unknown_msg_discardable(const u8 *cursor) { - enum wire_type t = fromwire_peektype(cursor); + enum peer_wire t = fromwire_peektype(cursor); return unknown_type(t) && (t & 1); } diff --git a/wire/peer_wire.h b/wire/peer_wire.h index 2964ed6c8..008410304 100644 --- a/wire/peer_wire.h +++ b/wire/peer_wire.h @@ -2,7 +2,7 @@ #define LIGHTNING_WIRE_PEER_WIRE_H #include "config.h" #include -#include +#include /* BOLT #1: * diff --git a/wire/test/Makefile b/wire/test/Makefile index a7e3eeeac..97e306986 100644 --- a/wire/test/Makefile +++ b/wire/test/Makefile @@ -22,4 +22,4 @@ ALL_TEST_PROGRAMS += $(WIRE_TEST_PROGRAMS) wire-tests: $(WIRE_TEST_PROGRAMS:%=unittest/%) -wire/test/run-peer-wire: wire/gen_peer_wire.o common/bigsize.o +wire/test/run-peer-wire: wire/peer_wiregen.o common/bigsize.o diff --git a/wire/test/run-peer-wire.c b/wire/test/run-peer-wire.c index ff8c4258e..c5b7e54f3 100644 --- a/wire/test/run-peer-wire.c +++ b/wire/test/run-peer-wire.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include extern secp256k1_context *secp256k1_ctx; diff --git a/wire/test/run-tlvstream.c b/wire/test/run-tlvstream.c index ff3248075..dd05357c5 100644 --- a/wire/test/run-tlvstream.c +++ b/wire/test/run-tlvstream.c @@ -13,7 +13,7 @@ static const char *reason; #include #include -#include +#include #include #include