From 8774070a311255ab7fc7778a16dd1e7ac989771e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 2 Aug 2019 12:54:25 +0930 Subject: [PATCH] bolt: Update to latest bolt, including TLV onion format. Signed-off-by: Rusty Russell --- Makefile | 2 +- common/sphinx.h | 24 ++++-------------------- wire/Makefile | 13 +++++++------ wire/extracted_onion_wire_csv | 6 ++++++ 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 49b406f87..2a8b0fed4 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ CCANDIR := ccan # Where we keep the BOLT RFCs BOLTDIR := ../lightning-rfc/ -BOLTVERSION := aa33af0c4d7ae0180c04ef98e61af49c1f876a36 +BOLTVERSION := d23f4b056c8ccc5234494c2431c901c455fa877f -include config.vars diff --git a/common/sphinx.h b/common/sphinx.h index d5480c2d2..ed62d3dfb 100644 --- a/common/sphinx.h +++ b/common/sphinx.h @@ -49,28 +49,12 @@ struct sphinx_path; /* BOLT #4: * - * The `hops_data` field is a structure that holds obfuscations of the - * next hop's address, transfer information, and its associated HMAC. It is - * 1300 bytes (`20x65`) long and has the following structure: + * ## Legacy `hop_data` payload format * - * 1. type: `hops_data` - * 2. data: - * * [`byte`:`realm`] - * * [`32*byte`:`per_hop`] - * * [`32*byte`:`HMAC`] - * * ... - * * `filler` - * - * Where, the `realm`, `per_hop` (with contents dependent on `realm`), and `HMAC` - * are repeated for each hop; and where, `filler` consists of obfuscated, - * deterministically-generated padding, as detailed in - * [Filler Generation](#filler-generation). Additionally, `hops_data` is - * incrementally obfuscated at each hop. - * - * The `realm` byte determines the format of the `per_hop` field; currently, only - * `realm` 0 is defined, for which the `per_hop` format follows: + * The `hop_data` format is identified by a single `0x00`-byte length, + * for backward compatibility. It's payload is defined as: * - * 1. type: `per_hop` (for `realm` 0) + * 1. type: `hop_data` (for `realm` 0) * 2. data: * * [`short_channel_id`:`short_channel_id`] * * [`u64`:`amt_to_forward`] diff --git a/wire/Makefile b/wire/Makefile index 1d30e612e..50ecb129b 100644 --- a/wire/Makefile +++ b/wire/Makefile @@ -70,17 +70,18 @@ wire/gen_peer_wire_csv wire/gen_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/gen_peer_wire.h: wire/gen_peer_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile $(BOLT_GEN) -s --expose-tlv-type=n1 --expose-tlv-type=n2 --page header $@ wire_type < $< > $@ -wire/gen_peer_wire.c: wire/gen_peer_wire_csv $(WIRE_BOLT_DEPS) +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/gen_onion_wire.h: wire/gen_onion_wire_csv $(WIRE_BOLT_DEPS) - $(BOLT_GEN) -s --page header $@ onion_type < $< > $@ +# 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) -s --expose-tlv-type=tlv_payload --page header $@ onion_type < $< > $@ -wire/gen_onion_wire.c: wire/gen_onion_wire_csv $(WIRE_BOLT_DEPS) - $(BOLT_GEN) -s --page impl ${@:.c=.h} onion_type < $< > $@ +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 < $< > $@ check-source: $(WIRE_SRC:%=check-src-include-order/%) $(WIRE_HEADERS_NOGEN:%=check-hdr-include-order/%) diff --git a/wire/extracted_onion_wire_csv b/wire/extracted_onion_wire_csv index e2e02684f..c9c529292 100644 --- a/wire/extracted_onion_wire_csv +++ b/wire/extracted_onion_wire_csv @@ -1,4 +1,10 @@ #include +tlvtype,tlv_payload,amt_to_forward,2 +tlvdata,tlv_payload,amt_to_forward,amt_to_forward,tu64, +tlvtype,tlv_payload,outgoing_cltv_value,4 +tlvdata,tlv_payload,outgoing_cltv_value,outgoing_cltv_value,tu32, +tlvtype,tlv_payload,short_channel_id,6 +tlvdata,tlv_payload,short_channel_id,short_channel_id,short_channel_id, msgtype,invalid_realm,PERM|1 msgtype,temporary_node_failure,NODE|2 msgtype,permanent_node_failure,PERM|NODE|2