1
0
mirror of https://github.com/lightning/bolts.git synced 2024-11-19 10:00:04 +01:00
Commit Graph

764 Commits

Author SHA1 Message Date
Rusty Russell
9d6f969722 BOLT 7: fixup: specify exactly which version of CRC32.
This is the one in SSE4, FWIW, and the iSCSI RFC contains test
vectors.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-16 22:36:59 +02:00
Rusty Russell
62dcf0fced BOLT 7: fixup: add missing encoding_type in checksums_tlv.
Since some can be zero (missing updates), it's probably worth
doing the compression thing optionally.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-16 22:36:59 +02:00
Rusty Russell
420d740311 BOLT 7: fix up TLV formatting for modern parser.
Formatting changes only.

This make tools/extract-formats.py work (well, it misses some stuff
until the tlv-testcases merge, but then it's OK).

We use `tlvs` (for tlv stream), and we refer to TLV records as "being
included" rather than re-using the TLV name.

We even use subtypes for the pairs of checksums and timestamps.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-16 22:36:59 +02:00
sstone
fc44a58a93 BOLT7: query_channel_range: allow requesting timestamps & checksums (folded)
Nodes that support extended queries will append an additional extended query flag to
their `query_channel_range` queries. If the receiver supports extended queries and
understands this flag, it will append the required additional data to its
`reply_channel_range` message.

There is currently only one type of additional data: one timestamp and one checksum
per `channel_update`.
The checksum is a CRC32 checksum computed over the `channel_update`
with `timestamp` and `signature` omitted.

Along with query_short_channel_ids extension, this can be used to
avoid querying `channel_updates` that are older than the ones you
already have, or that are newer but don't include new information.
2019-09-16 22:36:59 +02:00
sstone
0b5ba0cd4e BOLT7: query_short_channel_ids: allow requesting specific information (folded)
Nodes can append additional data to their `query_short_channel_ids`
messages, which consists in one flag per short channel id and
specifies what they would like to receive (`node_announcement`,
`channel_announcement`, or/and one `channel_update` or both).
2019-09-16 22:36:59 +02:00
Darosior
6e1bea0d48 bolt04: Correct some typos (#667) 2019-09-06 08:39:16 +00:00
Darosior
d669b01ba7 BOLT #3: Use space to indent in key derivation algorithms (#665) 2019-09-05 07:44:38 +00:00
Bastien Teinturier
db92932a9f
BOLT 04: Add failure code for invalid payload. (#627)
The specification currently doesn't specify the case where the onion per-hop
payload can't be correctly decoded.

This is somewhat fine with the fixed frames because every field of the payload
can always be interpreted as a numeric value from the input bytes, so it leads
to application errors in upper layers when those values are actually
interpreted (and we realize that for instance we have an invalid
short_channel_id` value).

With variable-length tlv streams in the onion payloads, we will encounter
decoding errors (duplicate tlv types, invalid ordering, etc) and the spec
should define the failure code to use in that case.
2019-09-03 06:54:13 +00:00
Rusty Russell
03fd18e5bc fixup! BOLT 11: Add test vectors for feature bitfield. 2019-09-03 01:00:47 +00:00
Rusty Russell
2eea93e133 BOLT 11: Add test vectors for feature bitfield.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-03 01:00:47 +00:00
Rusty Russell
b93b3bf518 BOLT 11: Add feature bits.
Most obviously, we want this for BASE AMP, but it's useful in future.

Even though even bits won't cause existing implementations to know
they can't pay the invoice, it will allow it in future once everyone
has upgraded.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-03 01:00:47 +00:00
ueno
aba7a8fe46 BOLT7: channel_update after exchange funding_locked (#657)
If a node sends its own `channel_update` to a peer node before receiving a `funding_lock`, the peer node may discard because it has not `short_channel_id` yet.
2019-09-02 20:09:59 +00:00
Nadav Kohen
8555709811 BOLT 3: Explicit description of implicitly enforced timelocks on HTLC outputs (#601)
* Added descriptions of how a 2-of-2 multisignature verification is used for enforcing timelocks when timing out on-chain offered HTLCs as well as spending on-chain received HTLCs in the success case.
2019-08-19 21:52:09 +00:00
Joost Jager
6729755f0c BOLT 4: Merge final_expiry_too_soon into incorrect_or_unknown_payment_details (#608)
In commit 914ebab908 the
incorrect_payment_amount error was merged into
incorrect_or_unknown_payment_details to prevent a probing attack
that allowed intermediate nodes to learn the final destination of
a payment.

A similar attack is possible using the htlc expiry value. By trying
payments with the correct amount but low expiry values to candidate
destinations, an incorrect_or_unknown_payment_details error can be
elicited. This would signal that the probe payment was sent to the
final destination.

For the intermediate node to determine the correct amount, an estimate
must be calculated. A logical choice would be the outgoing amount of the
intermediate node plus some allowance for routing fees that would
otherwise be paid to subsequent nodes along the path.

Picking a low enough - but not too low - expiry value is more tricky.
A reasonable guess could be made using external knowledge of the
final destination's implementation defaults or the type of invoice that
is paid to. Especially in the case of an hodl invoice that typically has
a large expiry delta, it is easier to make a correct guess.

This form of attack is arguably harder to realize than the amount probe
that was previously possible. The attacker may accidentally
pay the invoice if the expiry value guess satisfies the invoice
final cltv requirement. In that case, the attacker still has the
incoming htlc to pull which limits the loss.
2019-08-19 13:12:52 -07:00
lisa neigut
300f7a6e61 option_data_loss_protect: concretely define
`my_current_per_commitment_point`

Make it more obvious what the expected value of
`my_current_per_commitment_point` is.
2019-08-09 12:39:18 -05:00
Rusty Russell
d498d2ac56 tools/extract-formats.py: allow '.' in length fields.
In practice, using '...*type' is the clearest and simplest way to specify
the common case of "the rest of the TLV is an array of 'type'", rather
than some arbitrary expression with a made-up length field.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-06 00:18:49 +00:00
Rusty Russell
9491348d27 tools/extract-formats.py: allow '*' as well as '1.'/'2.'
The format for TLV types looked pretty, but @ZmnSCPxj points out that
successive ordered lists in markdown get merged into one megalist.

If we allow ordered or unordered lists, we're a bit more futureproof
against formatting changes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-06 00:18:49 +00:00
Bastien Teinturier
8b2cf00546
Bolt 04: fix a few left-over spelling / clean-up nits (#653)
* Fix a few left-over spelling / clean-up nits
* Bolt 09: fix spec links
2019-07-31 07:21:38 +00:00
Hiroki Gondo
44c6071d18 BOLT 2: correct next_remote_revocation_number to next_revocation_number (#652) 2019-07-29 07:31:07 +00:00
Rusty Russell
3da8923453 spelling: check all the .md files
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-28 07:03:19 +00:00
Rusty Russell
4f68ed4d6e CONTRIBUTING.md: first draft of how to write and change spec.
Thanks to feedback from @t-bast and @ariard, and Michael Kerrisk
who helped me find the 1999(!) man page text.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-28 07:03:19 +00:00
Christian Decker
d23f4b056c bolt04: Remove TLV based termination signal
As discussed during the IRC meeting on 2019-07-22 this would have been a
duplication of signals. It was decided to use one for now, with the option of
coming back should we ever need the last 32 bytes of the onion.
2019-07-26 11:38:33 +02:00
Christian Decker
15299bd57a bolt09: Cleanup the feature bits tables and extract URLs into footer
The tables were a bit unreadable in the source view, and the globalfeatures
table was not rendering correctly. This is just a minor cleanup pass.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
Suggested-by: Janus Troelsen <@ysangkok>
2019-07-26 11:38:33 +02:00
Christian Decker
0616c29bed bolt04: Introduce the destination_signal to the tlv_payload
As discussed during the spec meeting this allows us not to use the 32 byte
HMAC to identify the last hop, and use a 2-byte signal instead.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-07-26 11:38:33 +02:00
Christian Decker
6120510dd3 bolt07: Add feature bits for multi-frame support 2019-07-26 11:38:33 +02:00
Christian Decker
4ac1bcc99b bolt04: Shut the spellchecker up 2019-07-26 11:38:33 +02:00
Christian Decker
6cdbedb649 bolt04: Add the TLV types for the new payload format
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-07-26 11:38:33 +02:00
Christian Decker
10c345bcf4 bolt04: Remove in-spec test vector in favor of JSON test vector
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-07-26 11:38:33 +02:00
Christian Decker
ecaf591bca bolt04: Amend the filler generation and onion decoding to varpayload
This actually introduces the variable size shift and filler generation.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-07-26 11:38:33 +02:00
Christian Decker
a148abbad5 bolt04: Describe the variable size hop_payload
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-07-26 11:38:33 +02:00
Christian Decker
3ac0091ef9 bolt04: Formatting cleanup and fold clarifications into conventions
The clarifications were tacked on after the fact, but they should really be
part of the conventions. I also updated the links to use the reference style,
which results in better text flow and makes it easier to read the source.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-07-26 11:38:33 +02:00
Ugam Kamat
1810eaf4c8 BOLT #7: Correct indentation typo in channel_update message (#649) 2019-07-23 09:27:29 +02:00
ueno
11650d7ebe BOLT7: (announcement_signatures) Fail channel if short_channel_id not correct. (#635) 2019-07-23 09:25:59 +02:00
Rusty Russell
aa33af0c4d BOLT 1: Add test vectors.
These are based on @t-bast's vectors from #607, with a few more
cases:

1. Explicitly test encodings for 253, 254 and 255.
2. Use BigSize and make sure tests break badly if endian parsing is wrong.'
3. Test wrap-around of type encodings in stream.

Many thanks to @t-bast and @cfromknecht for their contributions and testing

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-22 23:27:13 +00:00
Rusty Russell
2fe6af8567 spellcheck: allow space-separated hex, and a few new terms.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-22 23:27:13 +00:00
Rusty Russell
f3fb4ec9c4 BOLT 1: explicitly disallow trailing data, require minimal values.
We didn't explicitly say that the TLV is bad if length exceeds
the message length!

We didn't specify whether to ignore extra bytes: we should.
Similarly, contents of values must be minimal (i.e. tu64 etc).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-22 23:27:13 +00:00
Rusty Russell
6af2ba23a8 tools/extract-formats.py: handle continuous types in tlvs.
We were swallowing the unused line after `data`, but it's
normal to do:

```
1. tlvs: `n1`
2. types:
   1. type: 1 (`tlv1`)
   2. data:
     * [`tu64`:`amount_msat`]
   1. type: 2 (`tlv2`)
   2. data:
     * [`short_channel_id`:`scid`]
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-22 23:27:13 +00:00
Rusty Russell
acad3fc8fe tools/extract-formats.py: recognize numerics in field names.
For some reason (typo?) we only allowed "2", not other numbers!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-22 23:27:13 +00:00
Rusty Russell
950b2f5481 BOLT 2: remove local/remote from reestablish field names.
(No spec change, just wording)

The "local" and "remote" here are just *confusing*.  Each side says
where it's at, and the other side retransmits based on that.

We could call it 'number_of_next_commitment_i_expect_to_receive' and
'number_of_next_revocation_i_expect_to_receive' but that's getting
silly.

These names were a major source of confusion while writing tests!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-22 16:47:19 -05:00
Orfeas Stefanos Thyfronitis Litos
238c06282d Rephrase last node payload requirements (#615)
Mention that `outgoing_cltv_value` has to be equal to
`min_final_cltv_expiry` and `amt_to_forward` has to be equal to
`amount` if the [BOLT #11](11-payment-encoding.md) invoice is used
2019-07-22 22:42:00 +02:00
Conner Fromknecht
65784f755f BOLT01: swap CompactSize for BigSize in TLV format
This commit modifies the varint encoding used for TLV types and lengths
to use a custom format called BigSize. The format is identical to
bitcoin's CompactSize, except it replaces the use of little-endian
encodings for multi-byte values with big-endian. This is done to prevent
mixing endianness within the protocol, since otherwise CompactSize would
be the first introduction of little-endian encodings.
2019-07-22 15:19:09 -05:00
Conner Fromknecht
bc9570d7b4 tools/spellcheck: ignore code blocks 2019-07-22 15:19:09 -05:00
neil saitug
55a9428810
Merge pull request #612 from jtimon/b9-format-table
BOLT9: Format table
2019-07-22 12:58:04 -05:00
Conner Fromknecht
e9ad0fd6a4 BOLT07: correct gossip_timestamp_range to gossip_timstamp_filter (#648) 2019-07-19 09:30:49 +02:00
Jorge Timón
8bdfc16156 BOLT11: Clarification on n field (#613) 2019-07-17 09:45:35 +02:00
Ugam Kamat
1db481ffeb BOLT #7: receiving node requirements related to timestamp for channel_update message (#621)
Clarify timestamp requirements for channel_update messages.
2019-07-16 09:24:26 +02:00
Hugo Doyon
ffeece3dab Bolt 00: Added Internal Links to Glossary (#637) 2019-07-15 10:01:15 +02:00
Hiroki Gondo
ea588805c7 BOLT 7: move the rational of short_channel_id to the definition (#636) 2019-07-11 09:33:42 +02:00
Alex Bosworth
636b9f2e28 Change opcode reference format (#594)
OP_CHECKLOCKTIMEVERIFY and OP_CSV use an inconsistent naming convention.
Update OP_CSV to match the OP_CHECKLOCKTIMEVERIFY convention as OP_CHECKSEQUENCEVERIFY.
2019-07-09 10:40:29 +02:00
Otto Suess
53343c99a5 BOLT 11: fix link (#626)
Update link to reference Bolt04's overpayment ("if the amount paid is more than twice the amount expected [the final node] SHOULD fail the HTLC.")
2019-07-09 09:38:34 +02:00