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

989 Commits

Author SHA1 Message Date
Rusty Russell
5776d2a7ec BOLT 11: Add payment_secret field (compulsory for new invoices).
We also define what the basic_mpp feature means in an invoice, by
reference to the next commit.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-12-13 03:48:57 +00:00
Rusty Russell
b2a3c2fb07 BOLT 9: Add feature bits for payment_secret and basic_mpp.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-12-13 03:48:57 +00:00
Rusty Russell
2422630274 BOLT 4: don't allow a "fee" for the final node.
I recently made a cut & paste bug with the protocol tests, and
paid an HTLC of amount 100M msat, but with only a 1M msat `amt_to_forward`
in the hop_data.  To my surprise, it was accepted.

This is because we allow overpaying the routing fee (considered 0
for the final hop).  This doesn't make sense for the final hop: anything
but exact equality implies a bug, or that the previous node took the
wrong amount from the payment.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-12-13 01:07:09 +00:00
Arvanitis Christos
0fb66ca6cc Minor href fix in Contents of 07-routing-gossip.md (#707) 2019-12-09 19:59:47 +01:00
Rusty Russell
8e69306e0a BOLT 11: use the same features for BOLT11 invoices as for others.
A bit less dense, but avoids a separate feature space.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-11-25 19:34:23 +00:00
Rusty Russell
6502e30e8f BOLT 7: always propagate announcements with unknown features.
The feature fields refer to the properties of the channel/node, not the
message itself, so we can still propagate them (and should, to avoid
splitting the network).

If we want to make an incompatible announcement message, we'll use a
different type, or insert an even TLV type.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-11-25 19:34:23 +00:00
Rusty Russell
206084c939 BOLT 9: flatten feature fields.
We simply specify, in each case, where they will appear ("Context").

Because `globalfeatures` is already in use, we fold that into the
renamed `localfeatures` field to unify them (now called `features`),
but dissuade further use.

Note also: we REQUIRE minimal `features` field in
channel_announcement, since otherwise both sides of channel will not
agree and not be able to create their signatures!

Consider these theoretical future features:

`opt_dlog_chan`: a new channel type which uses a new discrete log HTLC
type, but can't support traditional HTLC:

* `init`: presents as odd (optional) or even (if traditional channels
  not supported)
* `node_announcement`: the same as above, so you can seek suitable peers.
* `channel_announcement`: presents as even (compulsory), since users need
  to use the new HTLCs.

`opt_wumbochan`: a node which allows channels > 2^24 satoshis:

* `init`: presents as odd (optional), or maybe even (if you only want
  giant channels)
* `node_announcement`: the same as above, so you can seek suitable peers.
* `channel_announcement`: not present, since size of channel indicates
  capacity.

`opt_wumbohtlc`: a channel which allows HTLCs > 2^32 millisatoshis:

* `init`: presents as odd (optional), or even (compulsory)
* `node_announcement`: the same as above, so you can seek suitable peers.
* `channel_announcement`: odd (optional) since you can use the channel
  without understanding what this option means.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Co-Authored-By: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
2019-11-25 19:34:23 +00:00
Janus Troelsen
5f57ee3689 BOLT-02: Fix link to channel_id section (#704) 2019-11-21 20:05:23 -08:00
darosior
b84d09e076 bolt07: remove trailing tabs
Tabs or spaces ? Spaces seems to largely beat tabs in this files (and more globally in the repo).
2019-11-20 00:15:38 +00:00
ueno
3a0a7fd064 remove funding_locked future section 2019-11-20 00:12:44 +00:00
ueno
efd16b9b20 fix <id> tag 2019-11-20 00:12:20 +00:00
Thorkil Værge
a5b3818204
Specify that resolution of amount is msat
When the `p` multiplier is used, the amount MUST be divisible
by 10 since the resolution used internally is millisatoshi.

This addresses but does not close #692.
2019-11-14 08:38:53 +01:00
Tim Ruffing
35f6376f20 pubkeys live on the curve, not in the finite field 2019-11-04 06:00:50 +01:00
Joost Jager
3d60581a7a BOLT 1: Define custom tlv record range (#660) 2019-10-28 12:11:31 -07:00
Chris Shucksmith
7078c9141a minimally encoded explanation needs inverting (#685) 2019-10-21 09:44:46 +02:00
Rusty Russell
78bc516f96 BOLT 2: specify that you can't send funding_locked until you've checked the tx.
We might argue this does not apply if you set `minimum_depth` to 0, since
you're assuming trust (TurboChannels-style), but it needs to be specified.

See: CVE-2019-12998 / CVE-2019-12999 / CVE-2019-13000
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-10-03 00:41:12 +00:00
Rusty Russell
3154157459 BOLT 7: gossip_query_ex typos. (#673)
* BOLT 7: fix cut & paste typo.

This is `reply_channel_range_tlvs`: `query_channel_range_tlvs` is defined
above.  Somehow this fix got lost in the merge process, and breaks
our spec parsing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

* BOLT 7: add missing `encoding_type` field in query_short_channel_ids_tlvs / reply_channel_range_tlvs

The implementations have it, and the requirements refer to it,
but it's not actually in the description!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

* BOLT 7: clarify specification.

As agreed in http://www.erisian.com.au/meetbot/lightning-dev/2019/lightning-dev.2019-08-05-20.03.html,
checksums are not encoded as encoding_type + byte, but as a straight
array.  Referring to them as `*byte` is thus underspecifying them:
they are literally `*channel_update_checksums`.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-30 13:50:47 +02:00
Rusty Russell
2afe3559e8 option_static_remotekey: final draft.
This separates out the static remotekey changes from the more ambitious
option_simplified_commitment (which also included pushme outputs and
bring-your-own-fee for HTLC outputs).

As per http://www.erisian.com.au/meetbot/lightning-dev/2019/lightning-dev.2019-09-02-20.06.html

Thanks to everyone for feedback: @araspitzu @roasbeef @bitconner

Suggested-by: @roasbeef
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-26 06:19:58 +00:00
Dimitris Apostolou
3476c9b25a Fix typos 2019-09-26 06:12:41 +00:00
sstone
c8e53fe5bf BOTL 7: fixup: clarify when to reply with a node_announcement
Do not reply with a node_announcement if the query includes an optional query flag that does not request it.
The current wording could be interpreted as "always follow with node announcements whenever
you reply with a channel announcements" which defeats the point of using query flags (if you want the node
announcements just set the corresponding bits).
2019-09-16 22:36:59 +02:00
sstone
313c0f290e Add test vector for extended queries 2019-09-16 22:36:59 +02:00
sstone
30485af1df Define a feature bit for extended gossip queries 2019-09-16 22:36:59 +02:00
Fabrice Drouin
2f3514fe75 TLV Formatting changes
We use the more tool-friendly `...*` description for TLV extensions.
Checksums are now serialized as raw arrays, as using zlib compression here would not help.
2019-09-16 22:36:59 +02:00
sstone
2ba49eb467 Fixup: address review comments 2019-09-16 22:36:59 +02:00
sstone
1f95ea95bc Spelling fixes 2019-09-16 22:36:59 +02:00
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