mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
common/onion: split into decode and encode routines.
Some places (e.g. the pay plugin) only need to construct onions, not decode them. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
c5656ec90a
commit
8720bbedae
28 changed files with 184 additions and 203 deletions
|
@ -59,7 +59,8 @@ COMMON_SRC_NOGEN := \
|
||||||
common/memleak.c \
|
common/memleak.c \
|
||||||
common/msg_queue.c \
|
common/msg_queue.c \
|
||||||
common/node_id.c \
|
common/node_id.c \
|
||||||
common/onion.c \
|
common/onion_decode.c \
|
||||||
|
common/onion_encode.c \
|
||||||
common/onionreply.c \
|
common/onionreply.c \
|
||||||
common/onion_message_parse.c \
|
common/onion_message_parse.c \
|
||||||
common/peer_billboard.c \
|
common/peer_billboard.c \
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <common/blindedpay.h>
|
#include <common/blindedpay.h>
|
||||||
#include <common/bolt12.h>
|
#include <common/bolt12.h>
|
||||||
#include <common/onion.h>
|
#include <common/onion_encode.h>
|
||||||
|
|
||||||
u8 **blinded_onion_hops(const tal_t *ctx,
|
u8 **blinded_onion_hops(const tal_t *ctx,
|
||||||
struct amount_msat final_amount,
|
struct amount_msat final_amount,
|
||||||
|
|
|
@ -5,122 +5,10 @@
|
||||||
#include <ccan/mem/mem.h>
|
#include <ccan/mem/mem.h>
|
||||||
#include <common/blindedpath.h>
|
#include <common/blindedpath.h>
|
||||||
#include <common/ecdh.h>
|
#include <common/ecdh.h>
|
||||||
#include <common/onion.h>
|
#include <common/onion_decode.h>
|
||||||
#include <common/sphinx.h>
|
#include <common/sphinx.h>
|
||||||
#include <sodium/crypto_aead_chacha20poly1305.h>
|
#include <sodium/crypto_aead_chacha20poly1305.h>
|
||||||
|
|
||||||
/* 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)
|
static u64 ceil_div(u64 a, u64 b)
|
||||||
{
|
{
|
||||||
return (a + b - 1) / b;
|
return (a + b - 1) / b;
|
32
common/onion_decode.h
Normal file
32
common/onion_decode.h
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
#ifndef LIGHTNING_COMMON_ONION_DECODE_H
|
||||||
|
#define LIGHTNING_COMMON_ONION_DECODE_H
|
||||||
|
#include "config.h"
|
||||||
|
#include <bitcoin/privkey.h>
|
||||||
|
#include <common/amount.h>
|
||||||
|
#include <common/onion_encode.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 */
|
122
common/onion_encode.c
Normal file
122
common/onion_encode.c
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
#include "config.h"
|
||||||
|
#include <assert.h>
|
||||||
|
#include <ccan/array_size/array_size.h>
|
||||||
|
#include <ccan/cast/cast.h>
|
||||||
|
#include <ccan/mem/mem.h>
|
||||||
|
#include <common/blindedpath.h>
|
||||||
|
#include <common/ecdh.h>
|
||||||
|
#include <common/onion_encode.h>
|
||||||
|
#include <common/sphinx.h>
|
||||||
|
#include <sodium/crypto_aead_chacha20poly1305.h>
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef LIGHTNING_COMMON_ONION_H
|
#ifndef LIGHTNING_COMMON_ONION_ENCODE_H
|
||||||
#define LIGHTNING_COMMON_ONION_H
|
#define LIGHTNING_COMMON_ONION_ENCODE_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <bitcoin/privkey.h>
|
#include <bitcoin/privkey.h>
|
||||||
#include <common/amount.h>
|
#include <common/amount.h>
|
||||||
|
@ -7,7 +7,14 @@
|
||||||
struct route_step;
|
struct route_step;
|
||||||
struct tlv_encrypted_data_tlv_payment_relay;
|
struct tlv_encrypted_data_tlv_payment_relay;
|
||||||
|
|
||||||
|
enum onion_payload_type {
|
||||||
|
ONION_V0_PAYLOAD = 0,
|
||||||
|
ONION_TLV_PAYLOAD = 1,
|
||||||
|
};
|
||||||
|
|
||||||
struct onion_payload {
|
struct onion_payload {
|
||||||
|
enum onion_payload_type type;
|
||||||
|
|
||||||
struct amount_msat amt_to_forward;
|
struct amount_msat amt_to_forward;
|
||||||
u32 outgoing_cltv;
|
u32 outgoing_cltv;
|
||||||
struct amount_msat *total_msat;
|
struct amount_msat *total_msat;
|
||||||
|
@ -48,29 +55,4 @@ u8 *onion_blinded_hop(const tal_t *ctx,
|
||||||
const u8 *enctlv,
|
const u8 *enctlv,
|
||||||
const struct pubkey *blinding)
|
const struct pubkey *blinding)
|
||||||
NON_NULL_ARGS(4);
|
NON_NULL_ARGS(4);
|
||||||
|
#endif /* LIGHTNING_COMMON_ONION_ENCODE_H */
|
||||||
/**
|
|
||||||
* 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 */
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <ccan/mem/mem.h>
|
#include <ccan/mem/mem.h>
|
||||||
#include <common/onion.h>
|
#include <common/onion_decode.h>
|
||||||
#include <common/onionreply.h>
|
#include <common/onionreply.h>
|
||||||
#include <common/overflows.h>
|
#include <common/overflows.h>
|
||||||
#include <common/sphinx.h>
|
#include <common/sphinx.h>
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
#include "../blindedpath.c"
|
#include "../blindedpath.c"
|
||||||
#include "../blinding.c"
|
#include "../blinding.c"
|
||||||
#include "../hmac.c"
|
#include "../hmac.c"
|
||||||
#include "../onion.c"
|
#include "../onion_decode.c"
|
||||||
|
#include "../onion_encode.c"
|
||||||
#include "../sphinx.c"
|
#include "../sphinx.c"
|
||||||
#include "../type_to_string.c"
|
#include "../type_to_string.c"
|
||||||
#include <common/setup.h>
|
#include <common/setup.h>
|
||||||
|
|
|
@ -12,7 +12,7 @@ static void maybe_print(const char *fmt, ...);
|
||||||
#include "../blinding.c"
|
#include "../blinding.c"
|
||||||
#include "../features.c"
|
#include "../features.c"
|
||||||
#include "../hmac.c"
|
#include "../hmac.c"
|
||||||
#include "../onion.c"
|
#include "../onion_encode.c"
|
||||||
#include "../onion_message_parse.c"
|
#include "../onion_message_parse.c"
|
||||||
#include "../sphinx.c"
|
#include "../sphinx.c"
|
||||||
#include "../type_to_string.c"
|
#include "../type_to_string.c"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "../bigsize.c"
|
#include "../bigsize.c"
|
||||||
#include "../json_parse.c"
|
#include "../json_parse.c"
|
||||||
#include "../json_parse_simple.c"
|
#include "../json_parse_simple.c"
|
||||||
#include "../onion.c"
|
#include "../onion_decode.c"
|
||||||
#include "../sphinx.c"
|
#include "../sphinx.c"
|
||||||
#include "../hmac.c"
|
#include "../hmac.c"
|
||||||
#include "../type_to_string.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 */
|
/* Generated stub for amount_msat */
|
||||||
struct amount_msat amount_msat(u64 millisatoshis UNNEEDED)
|
struct amount_msat amount_msat(u64 millisatoshis UNNEEDED)
|
||||||
{ fprintf(stderr, "amount_msat called!\n"); abort(); }
|
{ 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 */
|
/* Generated stub for amount_msat_less */
|
||||||
bool amount_msat_less(struct amount_msat a UNNEEDED, struct amount_msat b UNNEEDED)
|
bool amount_msat_less(struct amount_msat a UNNEEDED, struct amount_msat b UNNEEDED)
|
||||||
{ fprintf(stderr, "amount_msat_less called!\n"); abort(); }
|
{ fprintf(stderr, "amount_msat_less called!\n"); abort(); }
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "../hmac.c"
|
#include "../hmac.c"
|
||||||
#include "../json_parse.c"
|
#include "../json_parse.c"
|
||||||
#include "../json_parse_simple.c"
|
#include "../json_parse_simple.c"
|
||||||
#include "../onion.c"
|
#include "../onion_encode.c"
|
||||||
#include "../sphinx.c"
|
#include "../sphinx.c"
|
||||||
#include "../type_to_string.c"
|
#include "../type_to_string.c"
|
||||||
#if EXPERIMENTAL_FEATURES
|
#if EXPERIMENTAL_FEATURES
|
||||||
|
@ -30,9 +30,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/* AUTOGENERATED MOCKS START */
|
/* 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 */
|
/* Generated stub for mvt_tag_str */
|
||||||
const char *mvt_tag_str(enum mvt_tag tag UNNEEDED)
|
const char *mvt_tag_str(enum mvt_tag tag UNNEEDED)
|
||||||
{ fprintf(stderr, "mvt_tag_str called!\n"); abort(); }
|
{ fprintf(stderr, "mvt_tag_str called!\n"); abort(); }
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "../hmac.c"
|
#include "../hmac.c"
|
||||||
#include "../onion.c"
|
#include "../onion_decode.c"
|
||||||
|
#include "../onion_encode.c"
|
||||||
#include "../onionreply.c"
|
#include "../onionreply.c"
|
||||||
#include "../sphinx.c"
|
#include "../sphinx.c"
|
||||||
#include <ccan/str/hex/hex.h>
|
#include <ccan/str/hex/hex.h>
|
||||||
|
|
|
@ -60,7 +60,7 @@ CONNECTD_COMMON_OBJS := \
|
||||||
common/memleak.o \
|
common/memleak.o \
|
||||||
common/msg_queue.o \
|
common/msg_queue.o \
|
||||||
common/node_id.o \
|
common/node_id.o \
|
||||||
common/onion.o \
|
common/onion_decode.o \
|
||||||
common/onionreply.o \
|
common/onionreply.o \
|
||||||
common/onion_message_parse.o \
|
common/onion_message_parse.o \
|
||||||
common/ping.o \
|
common/ping.o \
|
||||||
|
|
|
@ -71,7 +71,7 @@ devtools/create-gossipstore.o: gossipd/gossip_store_wiregen.h
|
||||||
|
|
||||||
devtools/onion.c: ccan/config.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
|
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
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/ecdh.h>
|
#include <common/ecdh.h>
|
||||||
#include <common/json_parse.h>
|
#include <common/json_parse.h>
|
||||||
#include <common/onion.h>
|
#include <common/onion_decode.h>
|
||||||
|
#include <common/onion_encode.h>
|
||||||
#include <common/sphinx.h>
|
#include <common/sphinx.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
|
|
@ -18,10 +18,8 @@ GOSSIPD_TEST_COMMON_OBJS := \
|
||||||
common/hmac.o \
|
common/hmac.o \
|
||||||
common/node_id.o \
|
common/node_id.o \
|
||||||
common/lease_rates.o \
|
common/lease_rates.o \
|
||||||
common/onion.o \
|
|
||||||
common/pseudorand.o \
|
common/pseudorand.o \
|
||||||
common/setup.o \
|
common/setup.o \
|
||||||
common/sphinx.o \
|
|
||||||
common/type_to_string.o \
|
common/type_to_string.o \
|
||||||
common/utils.o \
|
common/utils.o \
|
||||||
common/wireaddr.o \
|
common/wireaddr.o \
|
||||||
|
@ -41,7 +39,6 @@ gossipd/test/run-onion_message: \
|
||||||
common/blindedpath.o \
|
common/blindedpath.o \
|
||||||
common/blinding.o \
|
common/blinding.o \
|
||||||
common/hmac.o \
|
common/hmac.o \
|
||||||
common/onion.o \
|
|
||||||
common/sphinx.o \
|
common/sphinx.o \
|
||||||
|
|
||||||
# JSON needed for this test
|
# JSON needed for this test
|
||||||
|
|
|
@ -59,9 +59,6 @@ bool cupdate_different(struct gossip_store *gs UNNEEDED,
|
||||||
const struct half_chan *hc UNNEEDED,
|
const struct half_chan *hc UNNEEDED,
|
||||||
const u8 *cupdate UNNEEDED)
|
const u8 *cupdate UNNEEDED)
|
||||||
{ fprintf(stderr, "cupdate_different called!\n"); abort(); }
|
{ 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 */
|
/* Generated stub for gossip_store_add */
|
||||||
u64 gossip_store_add(struct gossip_store *gs UNNEEDED, const u8 *gossip_msg UNNEEDED,
|
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)
|
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,
|
const u8 *nannounce UNNEEDED,
|
||||||
bool *only_missing_tlv UNNEEDED)
|
bool *only_missing_tlv UNNEEDED)
|
||||||
{ fprintf(stderr, "nannounce_different called!\n"); abort(); }
|
{ 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_ */
|
/* Generated stub for new_reltimer_ */
|
||||||
struct oneshot *new_reltimer_(struct timers *timers UNNEEDED,
|
struct oneshot *new_reltimer_(struct timers *timers UNNEEDED,
|
||||||
const tal_t *ctx UNNEEDED,
|
const tal_t *ctx UNNEEDED,
|
||||||
|
|
|
@ -27,9 +27,6 @@ bool blinding_next_pubkey(const struct pubkey *pk UNNEEDED,
|
||||||
/* Generated stub for daemon_conn_send */
|
/* Generated stub for daemon_conn_send */
|
||||||
void daemon_conn_send(struct daemon_conn *dc UNNEEDED, const u8 *msg UNNEEDED)
|
void daemon_conn_send(struct daemon_conn *dc UNNEEDED, const u8 *msg UNNEEDED)
|
||||||
{ fprintf(stderr, "daemon_conn_send called!\n"); abort(); }
|
{ 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 */
|
/* Generated stub for find_peer */
|
||||||
struct peer *find_peer(struct daemon *daemon UNNEEDED, const struct node_id *id UNNEEDED)
|
struct peer *find_peer(struct daemon *daemon UNNEEDED, const struct node_id *id UNNEEDED)
|
||||||
{ fprintf(stderr, "find_peer called!\n"); abort(); }
|
{ 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 */
|
/* Generated stub for master_badmsg */
|
||||||
void master_badmsg(u32 type_expected UNNEEDED, const u8 *msg)
|
void master_badmsg(u32 type_expected UNNEEDED, const u8 *msg)
|
||||||
{ fprintf(stderr, "master_badmsg called!\n"); abort(); }
|
{ 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_ */
|
/* Generated stub for new_reltimer_ */
|
||||||
struct oneshot *new_reltimer_(struct timers *timers UNNEEDED,
|
struct oneshot *new_reltimer_(struct timers *timers UNNEEDED,
|
||||||
const tal_t *ctx UNNEEDED,
|
const tal_t *ctx UNNEEDED,
|
||||||
|
|
|
@ -45,9 +45,6 @@ bigsize_t *decode_scid_query_flags(const tal_t *ctx UNNEEDED,
|
||||||
/* Generated stub for decode_short_ids */
|
/* Generated stub for decode_short_ids */
|
||||||
struct short_channel_id *decode_short_ids(const tal_t *ctx UNNEEDED, const u8 *encoded UNNEEDED)
|
struct short_channel_id *decode_short_ids(const tal_t *ctx UNNEEDED, const u8 *encoded UNNEEDED)
|
||||||
{ fprintf(stderr, "decode_short_ids called!\n"); abort(); }
|
{ 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 */
|
/* Generated stub for find_peer */
|
||||||
struct peer *find_peer(struct daemon *daemon UNNEEDED, const struct node_id *id UNNEEDED)
|
struct peer *find_peer(struct daemon *daemon UNNEEDED, const struct node_id *id UNNEEDED)
|
||||||
{ fprintf(stderr, "find_peer called!\n"); abort(); }
|
{ 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 */
|
/* Generated stub for master_badmsg */
|
||||||
void master_badmsg(u32 type_expected UNNEEDED, const u8 *msg)
|
void master_badmsg(u32 type_expected UNNEEDED, const u8 *msg)
|
||||||
{ fprintf(stderr, "master_badmsg called!\n"); abort(); }
|
{ 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_ */
|
/* Generated stub for new_reltimer_ */
|
||||||
struct oneshot *new_reltimer_(struct timers *timers UNNEEDED,
|
struct oneshot *new_reltimer_(struct timers *timers UNNEEDED,
|
||||||
const tal_t *ctx UNNEEDED,
|
const tal_t *ctx UNNEEDED,
|
||||||
|
|
|
@ -45,9 +45,6 @@ bigsize_t *decode_scid_query_flags(const tal_t *ctx UNNEEDED,
|
||||||
/* Generated stub for decode_short_ids */
|
/* Generated stub for decode_short_ids */
|
||||||
struct short_channel_id *decode_short_ids(const tal_t *ctx UNNEEDED, const u8 *encoded UNNEEDED)
|
struct short_channel_id *decode_short_ids(const tal_t *ctx UNNEEDED, const u8 *encoded UNNEEDED)
|
||||||
{ fprintf(stderr, "decode_short_ids called!\n"); abort(); }
|
{ 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 */
|
/* 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)
|
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(); }
|
{ 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 */
|
/* Generated stub for master_badmsg */
|
||||||
void master_badmsg(u32 type_expected UNNEEDED, const u8 *msg)
|
void master_badmsg(u32 type_expected UNNEEDED, const u8 *msg)
|
||||||
{ fprintf(stderr, "master_badmsg called!\n"); abort(); }
|
{ 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 */
|
/* Generated stub for peer_supplied_good_gossip */
|
||||||
void peer_supplied_good_gossip(struct peer *peer UNNEEDED, size_t amount UNNEEDED)
|
void peer_supplied_good_gossip(struct peer *peer UNNEEDED, size_t amount UNNEEDED)
|
||||||
{ fprintf(stderr, "peer_supplied_good_gossip called!\n"); abort(); }
|
{ fprintf(stderr, "peer_supplied_good_gossip called!\n"); abort(); }
|
||||||
|
|
|
@ -26,12 +26,6 @@ bool blinding_next_pubkey(const struct pubkey *pk UNNEEDED,
|
||||||
const struct sha256 *h UNNEEDED,
|
const struct sha256 *h UNNEEDED,
|
||||||
struct pubkey *next UNNEEDED)
|
struct pubkey *next UNNEEDED)
|
||||||
{ fprintf(stderr, "blinding_next_pubkey called!\n"); abort(); }
|
{ 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_ */
|
/* Generated stub for new_reltimer_ */
|
||||||
struct oneshot *new_reltimer_(struct timers *timers UNNEEDED,
|
struct oneshot *new_reltimer_(struct timers *timers UNNEEDED,
|
||||||
const tal_t *ctx UNNEEDED,
|
const tal_t *ctx UNNEEDED,
|
||||||
|
|
|
@ -30,9 +30,6 @@ bool cupdate_different(struct gossip_store *gs UNNEEDED,
|
||||||
const struct half_chan *hc UNNEEDED,
|
const struct half_chan *hc UNNEEDED,
|
||||||
const u8 *cupdate UNNEEDED)
|
const u8 *cupdate UNNEEDED)
|
||||||
{ fprintf(stderr, "cupdate_different called!\n"); abort(); }
|
{ 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 */
|
/* Generated stub for gossip_store_add */
|
||||||
u64 gossip_store_add(struct gossip_store *gs UNNEEDED, const u8 *gossip_msg UNNEEDED,
|
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)
|
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,
|
const u8 *nannounce UNNEEDED,
|
||||||
bool *only_missing_tlv UNNEEDED)
|
bool *only_missing_tlv UNNEEDED)
|
||||||
{ fprintf(stderr, "nannounce_different called!\n"); abort(); }
|
{ 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_ */
|
/* Generated stub for notleak_ */
|
||||||
void *notleak_(void *ptr UNNEEDED, bool plus_children UNNEEDED)
|
void *notleak_(void *ptr UNNEEDED, bool plus_children UNNEEDED)
|
||||||
{ fprintf(stderr, "notleak_ called!\n"); abort(); }
|
{ fprintf(stderr, "notleak_ called!\n"); abort(); }
|
||||||
|
|
|
@ -110,7 +110,8 @@ LIGHTNINGD_COMMON_OBJS := \
|
||||||
common/memleak.o \
|
common/memleak.o \
|
||||||
common/msg_queue.o \
|
common/msg_queue.o \
|
||||||
common/node_id.o \
|
common/node_id.o \
|
||||||
common/onion.o \
|
common/onion_decode.o \
|
||||||
|
common/onion_encode.o \
|
||||||
common/onionreply.o \
|
common/onionreply.o \
|
||||||
common/penalty_base.o \
|
common/penalty_base.o \
|
||||||
common/per_peer_state.o \
|
common/per_peer_state.o \
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <ccan/array_size/array_size.h>
|
#include <ccan/array_size/array_size.h>
|
||||||
#include <common/onion.h>
|
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
#include <lightningd/channel.h>
|
#include <lightningd/channel.h>
|
||||||
#include <lightningd/coin_mvts.h>
|
#include <lightningd/coin_mvts.h>
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include <common/configdir.h>
|
#include <common/configdir.h>
|
||||||
#include <common/json_command.h>
|
#include <common/json_command.h>
|
||||||
#include <common/json_param.h>
|
#include <common/json_param.h>
|
||||||
#include <common/onion.h>
|
|
||||||
#include <common/overflows.h>
|
#include <common/overflows.h>
|
||||||
#include <common/random_select.h>
|
#include <common/random_select.h>
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <common/configdir.h>
|
#include <common/configdir.h>
|
||||||
#include <common/json_command.h>
|
#include <common/json_command.h>
|
||||||
#include <common/json_param.h>
|
#include <common/json_param.h>
|
||||||
#include <common/onion.h>
|
|
||||||
#include <common/onionreply.h>
|
#include <common/onionreply.h>
|
||||||
#include <common/route.h>
|
#include <common/route.h>
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <common/ecdh.h>
|
#include <common/ecdh.h>
|
||||||
#include <common/json_command.h>
|
#include <common/json_command.h>
|
||||||
#include <common/json_param.h>
|
#include <common/json_param.h>
|
||||||
#include <common/onion.h>
|
#include <common/onion_decode.h>
|
||||||
#include <common/onionreply.h>
|
#include <common/onionreply.h>
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
#include <common/onion.h>
|
#include <common/onion_encode.h>
|
||||||
#include <common/penalty_base.h>
|
#include <common/penalty_base.h>
|
||||||
#include <common/utxo.h>
|
#include <common/utxo.h>
|
||||||
#include <common/wallet.h>
|
#include <common/wallet.h>
|
||||||
|
|
Loading…
Add table
Reference in a new issue