diff --git a/common/Makefile b/common/Makefile index eba0fa1df..8112120ef 100644 --- a/common/Makefile +++ b/common/Makefile @@ -59,7 +59,8 @@ COMMON_SRC_NOGEN := \ common/memleak.c \ common/msg_queue.c \ common/node_id.c \ - common/onion.c \ + common/onion_decode.c \ + common/onion_encode.c \ common/onionreply.c \ common/onion_message_parse.c \ common/peer_billboard.c \ diff --git a/common/blindedpay.c b/common/blindedpay.c index 78d3df834..b542bb26a 100644 --- a/common/blindedpay.c +++ b/common/blindedpay.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include u8 **blinded_onion_hops(const tal_t *ctx, struct amount_msat final_amount, diff --git a/common/onion.c b/common/onion_decode.c similarity index 77% rename from common/onion.c rename to common/onion_decode.c index 368f543da..4d7b81a6a 100644 --- a/common/onion.c +++ b/common/onion_decode.c @@ -5,122 +5,10 @@ #include #include #include -#include +#include #include #include -/* BOLT #4: - * - * ### `tlv_payload` format - * - * This is a more flexible format, which avoids the redundant - * `short_channel_id` field for the final node. It is formatted - * according to the Type-Length-Value format defined in [BOLT - * #1](01-messaging.md#type-length-value-format). - */ -static u8 *make_tlv_hop(const tal_t *ctx, - const struct tlv_tlv_payload *tlv) -{ - /* We can't have over 64k anyway */ - u8 *tlvs = tal_arr(ctx, u8, 3); - - towire_tlv_tlv_payload(&tlvs, tlv); - - switch (bigsize_put(tlvs, tal_bytelen(tlvs) - 3)) { - case 1: - /* Move over two unused bytes */ - memmove(tlvs + 1, tlvs + 3, tal_bytelen(tlvs) - 3); - tal_resize(&tlvs, tal_bytelen(tlvs) - 2); - return tlvs; - case 3: - return tlvs; - } - abort(); -} - -u8 *onion_nonfinal_hop(const tal_t *ctx, - const struct short_channel_id *scid, - struct amount_msat forward, - u32 outgoing_cltv) -{ - struct tlv_tlv_payload *tlv = tlv_tlv_payload_new(tmpctx); - - /* BOLT #4: - * - * The writer: - *... - * - For every node: - * - MUST include `amt_to_forward` and `outgoing_cltv_value`. - * - For every non-final node: - * - MUST include `short_channel_id` - * - MUST NOT include `payment_data` - */ - tlv->amt_to_forward = &forward.millisatoshis; /* Raw: TLV convert */ - tlv->outgoing_cltv_value = &outgoing_cltv; - tlv->short_channel_id = cast_const(struct short_channel_id *, scid); - return make_tlv_hop(ctx, tlv); -} - -u8 *onion_final_hop(const tal_t *ctx, - struct amount_msat forward, - u32 outgoing_cltv, - struct amount_msat total_msat, - const struct secret *payment_secret, - const u8 *payment_metadata) -{ - struct tlv_tlv_payload *tlv = tlv_tlv_payload_new(tmpctx); - struct tlv_tlv_payload_payment_data tlv_pdata; - - /* These go together! */ - if (!payment_secret) - assert(amount_msat_eq(total_msat, forward)); - - /* BOLT #4: - * - * The writer: - *... - * - For every node: - * - MUST include `amt_to_forward` and `outgoing_cltv_value`. - *... - * - For the final node: - * - MUST NOT include `short_channel_id` - * - if the recipient provided `payment_secret`: - * - MUST include `payment_data` - * - MUST set `payment_secret` to the one provided - * - MUST set `total_msat` to the total amount it will send - */ - tlv->amt_to_forward = &forward.millisatoshis; /* Raw: TLV convert */ - tlv->outgoing_cltv_value = &outgoing_cltv; - - if (payment_secret) { - tlv_pdata.payment_secret = *payment_secret; - tlv_pdata.total_msat = total_msat.millisatoshis; /* Raw: TLV convert */ - tlv->payment_data = &tlv_pdata; - } - tlv->payment_metadata = cast_const(u8 *, payment_metadata); - return make_tlv_hop(ctx, tlv); -} - -u8 *onion_blinded_hop(const tal_t *ctx, - const struct amount_msat *amt_to_forward, - const u32 *outgoing_cltv_value, - const u8 *enctlv, - const struct pubkey *blinding) -{ - struct tlv_tlv_payload *tlv = tlv_tlv_payload_new(tmpctx); - - if (amt_to_forward) { - tlv->amt_to_forward - = cast_const(u64 *, - &amt_to_forward->millisatoshis); /* Raw: TLV convert */ - } - tlv->outgoing_cltv_value = cast_const(u32 *, outgoing_cltv_value); - tlv->encrypted_recipient_data = cast_const(u8 *, enctlv); - tlv->blinding_point = cast_const(struct pubkey *, blinding); - - return make_tlv_hop(ctx, tlv); -} - static u64 ceil_div(u64 a, u64 b) { return (a + b - 1) / b; diff --git a/common/onion_decode.h b/common/onion_decode.h new file mode 100644 index 000000000..3ed65f55b --- /dev/null +++ b/common/onion_decode.h @@ -0,0 +1,32 @@ +#ifndef LIGHTNING_COMMON_ONION_DECODE_H +#define LIGHTNING_COMMON_ONION_DECODE_H +#include "config.h" +#include +#include +#include + +/** + * onion_decode: decode payload from a decrypted onion. + * @ctx: context to allocate onion_contents off. + * @blinding_support: --experimental-route-blinding? + * @rs: the route_step, whose raw_payload is of at least length + * onion_payload_length(). + * @blinding: the optional incoming blinding point. + * @accepted_extra_tlvs: Allow these types to be in the TLV without failing + * @amount_in: Incoming HTLC amount + * @cltv_expiry: Incoming HTLC cltv_expiry + * @failtlvtype: (out) the tlv type which failed to parse. + * @failtlvpos: (out) the offset in the tlv which failed to parse. + * + * If the payload is not valid, returns NULL. + */ +struct onion_payload *onion_decode(const tal_t *ctx, + bool blinding_support, + const struct route_step *rs, + const struct pubkey *blinding, + const u64 *accepted_extra_tlvs, + struct amount_msat amount_in, + u32 cltv_expiry, + u64 *failtlvtype, + size_t *failtlvpos); +#endif /* LIGHTNING_COMMON_ONION_DECODE_H */ diff --git a/common/onion_encode.c b/common/onion_encode.c new file mode 100644 index 000000000..711b8dc9c --- /dev/null +++ b/common/onion_encode.c @@ -0,0 +1,122 @@ +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* BOLT #4: + * + * ### `tlv_payload` format + * + * This is a more flexible format, which avoids the redundant + * `short_channel_id` field for the final node. It is formatted + * according to the Type-Length-Value format defined in [BOLT + * #1](01-messaging.md#type-length-value-format). + */ +static u8 *make_tlv_hop(const tal_t *ctx, + const struct tlv_tlv_payload *tlv) +{ + /* We can't have over 64k anyway */ + u8 *tlvs = tal_arr(ctx, u8, 3); + + towire_tlv_tlv_payload(&tlvs, tlv); + + switch (bigsize_put(tlvs, tal_bytelen(tlvs) - 3)) { + case 1: + /* Move over two unused bytes */ + memmove(tlvs + 1, tlvs + 3, tal_bytelen(tlvs) - 3); + tal_resize(&tlvs, tal_bytelen(tlvs) - 2); + return tlvs; + case 3: + return tlvs; + } + abort(); +} + +u8 *onion_nonfinal_hop(const tal_t *ctx, + const struct short_channel_id *scid, + struct amount_msat forward, + u32 outgoing_cltv) +{ + struct tlv_tlv_payload *tlv = tlv_tlv_payload_new(tmpctx); + + /* BOLT #4: + * + * The writer: + *... + * - For every node: + * - MUST include `amt_to_forward` and `outgoing_cltv_value`. + * - For every non-final node: + * - MUST include `short_channel_id` + * - MUST NOT include `payment_data` + */ + tlv->amt_to_forward = &forward.millisatoshis; /* Raw: TLV convert */ + tlv->outgoing_cltv_value = &outgoing_cltv; + tlv->short_channel_id = cast_const(struct short_channel_id *, scid); + return make_tlv_hop(ctx, tlv); +} + +u8 *onion_final_hop(const tal_t *ctx, + struct amount_msat forward, + u32 outgoing_cltv, + struct amount_msat total_msat, + const struct secret *payment_secret, + const u8 *payment_metadata) +{ + struct tlv_tlv_payload *tlv = tlv_tlv_payload_new(tmpctx); + struct tlv_tlv_payload_payment_data tlv_pdata; + + /* These go together! */ + if (!payment_secret) + assert(amount_msat_eq(total_msat, forward)); + + /* BOLT #4: + * + * The writer: + *... + * - For every node: + * - MUST include `amt_to_forward` and `outgoing_cltv_value`. + *... + * - For the final node: + * - MUST NOT include `short_channel_id` + * - if the recipient provided `payment_secret`: + * - MUST include `payment_data` + * - MUST set `payment_secret` to the one provided + * - MUST set `total_msat` to the total amount it will send + */ + tlv->amt_to_forward = &forward.millisatoshis; /* Raw: TLV convert */ + tlv->outgoing_cltv_value = &outgoing_cltv; + + if (payment_secret) { + tlv_pdata.payment_secret = *payment_secret; + tlv_pdata.total_msat = total_msat.millisatoshis; /* Raw: TLV convert */ + tlv->payment_data = &tlv_pdata; + } + tlv->payment_metadata = cast_const(u8 *, payment_metadata); + return make_tlv_hop(ctx, tlv); +} + +u8 *onion_blinded_hop(const tal_t *ctx, + const struct amount_msat *amt_to_forward, + const u32 *outgoing_cltv_value, + const u8 *enctlv, + const struct pubkey *blinding) +{ + struct tlv_tlv_payload *tlv = tlv_tlv_payload_new(tmpctx); + + if (amt_to_forward) { + tlv->amt_to_forward + = cast_const(u64 *, + &amt_to_forward->millisatoshis); /* Raw: TLV convert */ + } + tlv->outgoing_cltv_value = cast_const(u32 *, outgoing_cltv_value); + tlv->encrypted_recipient_data = cast_const(u8 *, enctlv); + tlv->blinding_point = cast_const(struct pubkey *, blinding); + + return make_tlv_hop(ctx, tlv); +} diff --git a/common/onion.h b/common/onion_encode.h similarity index 57% rename from common/onion.h rename to common/onion_encode.h index 37587038c..ba4821191 100644 --- a/common/onion.h +++ b/common/onion_encode.h @@ -1,5 +1,5 @@ -#ifndef LIGHTNING_COMMON_ONION_H -#define LIGHTNING_COMMON_ONION_H +#ifndef LIGHTNING_COMMON_ONION_ENCODE_H +#define LIGHTNING_COMMON_ONION_ENCODE_H #include "config.h" #include #include @@ -7,7 +7,14 @@ struct route_step; struct tlv_encrypted_data_tlv_payment_relay; +enum onion_payload_type { + ONION_V0_PAYLOAD = 0, + ONION_TLV_PAYLOAD = 1, +}; + struct onion_payload { + enum onion_payload_type type; + struct amount_msat amt_to_forward; u32 outgoing_cltv; struct amount_msat *total_msat; @@ -48,29 +55,4 @@ u8 *onion_blinded_hop(const tal_t *ctx, const u8 *enctlv, const struct pubkey *blinding) NON_NULL_ARGS(4); - -/** - * onion_decode: decode payload from a decrypted onion. - * @ctx: context to allocate onion_contents off. - * @blinding_support: --experimental-route-blinding? - * @rs: the route_step, whose raw_payload is of at least length - * onion_payload_length(). - * @blinding: the optional incoming blinding point. - * @accepted_extra_tlvs: Allow these types to be in the TLV without failing - * @amount_in: Incoming HTLC amount - * @cltv_expiry: Incoming HTLC cltv_expiry - * @failtlvtype: (out) the tlv type which failed to parse. - * @failtlvpos: (out) the offset in the tlv which failed to parse. - * - * If the payload is not valid, returns NULL. - */ -struct onion_payload *onion_decode(const tal_t *ctx, - bool blinding_support, - const struct route_step *rs, - const struct pubkey *blinding, - const u64 *accepted_extra_tlvs, - struct amount_msat amount_in, - u32 cltv_expiry, - u64 *failtlvtype, - size_t *failtlvpos); -#endif /* LIGHTNING_COMMON_ONION_H */ +#endif /* LIGHTNING_COMMON_ONION_ENCODE_H */ diff --git a/common/sphinx.c b/common/sphinx.c index 4de8f2322..19d50ba89 100644 --- a/common/sphinx.c +++ b/common/sphinx.c @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include diff --git a/common/test/run-blindedpath_onion.c b/common/test/run-blindedpath_onion.c index 4bff3d81c..94e03de96 100644 --- a/common/test/run-blindedpath_onion.c +++ b/common/test/run-blindedpath_onion.c @@ -4,7 +4,8 @@ #include "../blindedpath.c" #include "../blinding.c" #include "../hmac.c" -#include "../onion.c" +#include "../onion_decode.c" +#include "../onion_encode.c" #include "../sphinx.c" #include "../type_to_string.c" #include diff --git a/common/test/run-onion-message-test.c b/common/test/run-onion-message-test.c index 508ab6d97..a2e3bba97 100644 --- a/common/test/run-onion-message-test.c +++ b/common/test/run-onion-message-test.c @@ -12,7 +12,7 @@ static void maybe_print(const char *fmt, ...); #include "../blinding.c" #include "../features.c" #include "../hmac.c" -#include "../onion.c" +#include "../onion_encode.c" #include "../onion_message_parse.c" #include "../sphinx.c" #include "../type_to_string.c" diff --git a/common/test/run-onion-test-vector.c b/common/test/run-onion-test-vector.c index 62dde8050..9c1dd4de7 100644 --- a/common/test/run-onion-test-vector.c +++ b/common/test/run-onion-test-vector.c @@ -2,7 +2,7 @@ #include "../bigsize.c" #include "../json_parse.c" #include "../json_parse_simple.c" -#include "../onion.c" +#include "../onion_decode.c" #include "../sphinx.c" #include "../hmac.c" #include "../type_to_string.c" @@ -31,9 +31,6 @@ struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED) /* Generated stub for amount_msat */ struct amount_msat amount_msat(u64 millisatoshis UNNEEDED) { fprintf(stderr, "amount_msat called!\n"); abort(); } -/* Generated stub for amount_msat_eq */ -bool amount_msat_eq(struct amount_msat a UNNEEDED, struct amount_msat b UNNEEDED) -{ fprintf(stderr, "amount_msat_eq called!\n"); abort(); } /* Generated stub for amount_msat_less */ bool amount_msat_less(struct amount_msat a UNNEEDED, struct amount_msat b UNNEEDED) { fprintf(stderr, "amount_msat_less called!\n"); abort(); } diff --git a/common/test/run-route_blinding_onion_test.c b/common/test/run-route_blinding_onion_test.c index b07001ce4..b22397727 100644 --- a/common/test/run-route_blinding_onion_test.c +++ b/common/test/run-route_blinding_onion_test.c @@ -11,7 +11,7 @@ #include "../hmac.c" #include "../json_parse.c" #include "../json_parse_simple.c" -#include "../onion.c" +#include "../onion_encode.c" #include "../sphinx.c" #include "../type_to_string.c" #if EXPERIMENTAL_FEATURES @@ -30,9 +30,6 @@ #include /* AUTOGENERATED MOCKS START */ -/* Generated stub for ecdh */ -void ecdh(const struct pubkey *point UNNEEDED, struct secret *ss UNNEEDED) -{ fprintf(stderr, "ecdh called!\n"); abort(); } /* Generated stub for mvt_tag_str */ const char *mvt_tag_str(enum mvt_tag tag UNNEEDED) { fprintf(stderr, "mvt_tag_str called!\n"); abort(); } diff --git a/common/test/run-sphinx.c b/common/test/run-sphinx.c index 861829c81..47de12e05 100644 --- a/common/test/run-sphinx.c +++ b/common/test/run-sphinx.c @@ -1,6 +1,7 @@ #include "config.h" #include "../hmac.c" -#include "../onion.c" +#include "../onion_decode.c" +#include "../onion_encode.c" #include "../onionreply.c" #include "../sphinx.c" #include diff --git a/connectd/Makefile b/connectd/Makefile index ad8853ae3..b8c9b3d34 100644 --- a/connectd/Makefile +++ b/connectd/Makefile @@ -60,7 +60,7 @@ CONNECTD_COMMON_OBJS := \ common/memleak.o \ common/msg_queue.o \ common/node_id.o \ - common/onion.o \ + common/onion_decode.o \ common/onionreply.o \ common/onion_message_parse.o \ common/ping.o \ diff --git a/devtools/Makefile b/devtools/Makefile index 9d23d644c..0d5e3cf9a 100644 --- a/devtools/Makefile +++ b/devtools/Makefile @@ -71,7 +71,7 @@ devtools/create-gossipstore.o: gossipd/gossip_store_wiregen.h devtools/onion.c: ccan/config.h -devtools/onion: $(DEVTOOLS_COMMON_OBJS) $(JSMN_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) $(BITCOIN_OBJS) common/onion_decode.o common/onion_encode.o common/onionreply.o wire/fromwire.o wire/towire.o devtools/onion.o common/sphinx.o devtools/gossipwith: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o wire/peer$(EXP)_wiregen.o devtools/gossipwith.o common/cryptomsg.o common/cryptomsg.o diff --git a/devtools/onion.c b/devtools/onion.c index e19360ae5..b08a6f25b 100644 --- a/devtools/onion.c +++ b/devtools/onion.c @@ -7,7 +7,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/gossipd/test/Makefile b/gossipd/test/Makefile index 21ef60425..2abf4a91a 100644 --- a/gossipd/test/Makefile +++ b/gossipd/test/Makefile @@ -18,10 +18,8 @@ GOSSIPD_TEST_COMMON_OBJS := \ common/hmac.o \ common/node_id.o \ common/lease_rates.o \ - common/onion.o \ common/pseudorand.o \ common/setup.o \ - common/sphinx.o \ common/type_to_string.o \ common/utils.o \ common/wireaddr.o \ @@ -41,7 +39,6 @@ gossipd/test/run-onion_message: \ common/blindedpath.o \ common/blinding.o \ common/hmac.o \ - common/onion.o \ common/sphinx.o \ # JSON needed for this test diff --git a/gossipd/test/run-check_channel_announcement.c b/gossipd/test/run-check_channel_announcement.c index fc8f88884..0e983618e 100644 --- a/gossipd/test/run-check_channel_announcement.c +++ b/gossipd/test/run-check_channel_announcement.c @@ -59,9 +59,6 @@ bool cupdate_different(struct gossip_store *gs UNNEEDED, const struct half_chan *hc UNNEEDED, const u8 *cupdate UNNEEDED) { fprintf(stderr, "cupdate_different called!\n"); abort(); } -/* Generated stub for ecdh */ -void ecdh(const struct pubkey *point UNNEEDED, struct secret *ss UNNEEDED) -{ fprintf(stderr, "ecdh called!\n"); abort(); } /* Generated stub for gossip_store_add */ u64 gossip_store_add(struct gossip_store *gs UNNEEDED, const u8 *gossip_msg UNNEEDED, u32 timestamp UNNEEDED, bool push UNNEEDED, bool spam UNNEEDED, const u8 *addendum UNNEEDED) @@ -107,9 +104,6 @@ bool nannounce_different(struct gossip_store *gs UNNEEDED, const u8 *nannounce UNNEEDED, bool *only_missing_tlv UNNEEDED) { fprintf(stderr, "nannounce_different called!\n"); abort(); } -/* Generated stub for new_onionreply */ -struct onionreply *new_onionreply(const tal_t *ctx UNNEEDED, const u8 *contents TAKES UNNEEDED) -{ fprintf(stderr, "new_onionreply called!\n"); abort(); } /* Generated stub for new_reltimer_ */ struct oneshot *new_reltimer_(struct timers *timers UNNEEDED, const tal_t *ctx UNNEEDED, diff --git a/gossipd/test/run-check_node_announcement.c b/gossipd/test/run-check_node_announcement.c index a1119f775..6c0dabb28 100644 --- a/gossipd/test/run-check_node_announcement.c +++ b/gossipd/test/run-check_node_announcement.c @@ -27,9 +27,6 @@ bool blinding_next_pubkey(const struct pubkey *pk UNNEEDED, /* Generated stub for daemon_conn_send */ void daemon_conn_send(struct daemon_conn *dc UNNEEDED, const u8 *msg UNNEEDED) { fprintf(stderr, "daemon_conn_send called!\n"); abort(); } -/* Generated stub for ecdh */ -void ecdh(const struct pubkey *point UNNEEDED, struct secret *ss UNNEEDED) -{ fprintf(stderr, "ecdh called!\n"); abort(); } /* Generated stub for find_peer */ struct peer *find_peer(struct daemon *daemon UNNEEDED, const struct node_id *id UNNEEDED) { fprintf(stderr, "find_peer called!\n"); abort(); } @@ -65,9 +62,6 @@ u8 *handle_node_announcement(struct routing_state *rstate UNNEEDED, const u8 *no /* Generated stub for master_badmsg */ void master_badmsg(u32 type_expected UNNEEDED, const u8 *msg) { fprintf(stderr, "master_badmsg called!\n"); abort(); } -/* Generated stub for new_onionreply */ -struct onionreply *new_onionreply(const tal_t *ctx UNNEEDED, const u8 *contents TAKES UNNEEDED) -{ fprintf(stderr, "new_onionreply called!\n"); abort(); } /* Generated stub for new_reltimer_ */ struct oneshot *new_reltimer_(struct timers *timers UNNEEDED, const tal_t *ctx UNNEEDED, diff --git a/gossipd/test/run-crc32_of_update.c b/gossipd/test/run-crc32_of_update.c index 2a8c197f6..3d61283e6 100644 --- a/gossipd/test/run-crc32_of_update.c +++ b/gossipd/test/run-crc32_of_update.c @@ -45,9 +45,6 @@ bigsize_t *decode_scid_query_flags(const tal_t *ctx UNNEEDED, /* Generated stub for decode_short_ids */ struct short_channel_id *decode_short_ids(const tal_t *ctx UNNEEDED, const u8 *encoded UNNEEDED) { fprintf(stderr, "decode_short_ids called!\n"); abort(); } -/* Generated stub for ecdh */ -void ecdh(const struct pubkey *point UNNEEDED, struct secret *ss UNNEEDED) -{ fprintf(stderr, "ecdh called!\n"); abort(); } /* Generated stub for find_peer */ struct peer *find_peer(struct daemon *daemon UNNEEDED, const struct node_id *id UNNEEDED) { fprintf(stderr, "find_peer called!\n"); abort(); } @@ -91,9 +88,6 @@ u8 *handle_node_announcement(struct routing_state *rstate UNNEEDED, const u8 *no /* Generated stub for master_badmsg */ void master_badmsg(u32 type_expected UNNEEDED, const u8 *msg) { fprintf(stderr, "master_badmsg called!\n"); abort(); } -/* Generated stub for new_onionreply */ -struct onionreply *new_onionreply(const tal_t *ctx UNNEEDED, const u8 *contents TAKES UNNEEDED) -{ fprintf(stderr, "new_onionreply called!\n"); abort(); } /* Generated stub for new_reltimer_ */ struct oneshot *new_reltimer_(struct timers *timers UNNEEDED, const tal_t *ctx UNNEEDED, diff --git a/gossipd/test/run-extended-info.c b/gossipd/test/run-extended-info.c index d69b852f7..835d8bfae 100644 --- a/gossipd/test/run-extended-info.c +++ b/gossipd/test/run-extended-info.c @@ -45,9 +45,6 @@ bigsize_t *decode_scid_query_flags(const tal_t *ctx UNNEEDED, /* Generated stub for decode_short_ids */ struct short_channel_id *decode_short_ids(const tal_t *ctx UNNEEDED, const u8 *encoded UNNEEDED) { fprintf(stderr, "decode_short_ids called!\n"); abort(); } -/* Generated stub for ecdh */ -void ecdh(const struct pubkey *point UNNEEDED, struct secret *ss UNNEEDED) -{ fprintf(stderr, "ecdh called!\n"); abort(); } /* Generated stub for fromwire_gossipd_dev_set_max_scids_encode_size */ bool fromwire_gossipd_dev_set_max_scids_encode_size(const void *p UNNEEDED, u32 *max UNNEEDED) { fprintf(stderr, "fromwire_gossipd_dev_set_max_scids_encode_size called!\n"); abort(); } @@ -68,9 +65,6 @@ const u8 *gossip_store_get(const tal_t *ctx UNNEEDED, /* Generated stub for master_badmsg */ void master_badmsg(u32 type_expected UNNEEDED, const u8 *msg) { fprintf(stderr, "master_badmsg called!\n"); abort(); } -/* Generated stub for new_onionreply */ -struct onionreply *new_onionreply(const tal_t *ctx UNNEEDED, const u8 *contents TAKES UNNEEDED) -{ fprintf(stderr, "new_onionreply called!\n"); abort(); } /* Generated stub for peer_supplied_good_gossip */ void peer_supplied_good_gossip(struct peer *peer UNNEEDED, size_t amount UNNEEDED) { fprintf(stderr, "peer_supplied_good_gossip called!\n"); abort(); } diff --git a/gossipd/test/run-next_block_range.c b/gossipd/test/run-next_block_range.c index b7f39e6fe..b83fa2bf9 100644 --- a/gossipd/test/run-next_block_range.c +++ b/gossipd/test/run-next_block_range.c @@ -26,12 +26,6 @@ bool blinding_next_pubkey(const struct pubkey *pk UNNEEDED, const struct sha256 *h UNNEEDED, struct pubkey *next UNNEEDED) { fprintf(stderr, "blinding_next_pubkey called!\n"); abort(); } -/* Generated stub for ecdh */ -void ecdh(const struct pubkey *point UNNEEDED, struct secret *ss UNNEEDED) -{ fprintf(stderr, "ecdh called!\n"); abort(); } -/* Generated stub for new_onionreply */ -struct onionreply *new_onionreply(const tal_t *ctx UNNEEDED, const u8 *contents TAKES UNNEEDED) -{ fprintf(stderr, "new_onionreply called!\n"); abort(); } /* Generated stub for new_reltimer_ */ struct oneshot *new_reltimer_(struct timers *timers UNNEEDED, const tal_t *ctx UNNEEDED, diff --git a/gossipd/test/run-txout_failure.c b/gossipd/test/run-txout_failure.c index 2307c1d7d..598f11ff9 100644 --- a/gossipd/test/run-txout_failure.c +++ b/gossipd/test/run-txout_failure.c @@ -30,9 +30,6 @@ bool cupdate_different(struct gossip_store *gs UNNEEDED, const struct half_chan *hc UNNEEDED, const u8 *cupdate UNNEEDED) { fprintf(stderr, "cupdate_different called!\n"); abort(); } -/* Generated stub for ecdh */ -void ecdh(const struct pubkey *point UNNEEDED, struct secret *ss UNNEEDED) -{ fprintf(stderr, "ecdh called!\n"); abort(); } /* Generated stub for gossip_store_add */ u64 gossip_store_add(struct gossip_store *gs UNNEEDED, const u8 *gossip_msg UNNEEDED, u32 timestamp UNNEEDED, bool push UNNEEDED, bool spam UNNEEDED, const u8 *addendum UNNEEDED) @@ -74,9 +71,6 @@ bool nannounce_different(struct gossip_store *gs UNNEEDED, const u8 *nannounce UNNEEDED, bool *only_missing_tlv UNNEEDED) { fprintf(stderr, "nannounce_different called!\n"); abort(); } -/* Generated stub for new_onionreply */ -struct onionreply *new_onionreply(const tal_t *ctx UNNEEDED, const u8 *contents TAKES UNNEEDED) -{ fprintf(stderr, "new_onionreply called!\n"); abort(); } /* Generated stub for notleak_ */ void *notleak_(void *ptr UNNEEDED, bool plus_children UNNEEDED) { fprintf(stderr, "notleak_ called!\n"); abort(); } diff --git a/lightningd/Makefile b/lightningd/Makefile index adc8a1f80..8d2d32603 100644 --- a/lightningd/Makefile +++ b/lightningd/Makefile @@ -110,7 +110,8 @@ LIGHTNINGD_COMMON_OBJS := \ common/memleak.o \ common/msg_queue.o \ common/node_id.o \ - common/onion.o \ + common/onion_decode.o \ + common/onion_encode.o \ common/onionreply.o \ common/penalty_base.o \ common/per_peer_state.o \ diff --git a/lightningd/coin_mvts.c b/lightningd/coin_mvts.c index b1cf1418b..cdba2af1d 100644 --- a/lightningd/coin_mvts.c +++ b/lightningd/coin_mvts.c @@ -1,6 +1,5 @@ #include "config.h" #include -#include #include #include #include diff --git a/lightningd/invoice.c b/lightningd/invoice.c index 459a80704..c3265ee3b 100644 --- a/lightningd/invoice.c +++ b/lightningd/invoice.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/lightningd/pay.c b/lightningd/pay.c index b3bfec8f1..2277e99fa 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index fd1d3262f..8ca9b5acd 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/wallet/wallet.h b/wallet/wallet.h index 4b1d98e38..0ee3816c1 100644 --- a/wallet/wallet.h +++ b/wallet/wallet.h @@ -3,7 +3,7 @@ #include "config.h" #include "db.h" -#include +#include #include #include #include