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

1071 Commits

Author SHA1 Message Date
t-bast
03e9309140
Trampoline Routing
This proposal allows nodes running on constrained devices to sync only a
small portion of the network and leverage trampoline nodes to calculate
the missing parts of the payment route.

The main idea is to use layered onions: a normal onion contains a smaller
onion for the last hop of the route, and that smaller onion contains routing
information to reach the next trampoline hop.
2024-10-23 10:34:45 +02:00
Rusty Russell
247e83d528 BOLT 12: the test vectors.
Three vectors:

1. Raw string decoding tests.  (Start here!)
2. Offer decoding tests.
3. TLV signature tests.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-09-24 19:40:59 +09:00
Rusty Russell
ca06224cf6 BOLT 4: add bolt12 payloads to onion message payloads.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-09-24 19:40:59 +09:00
Rusty Russell
aed3d28d5a BOLT 12: offers, sixth draft
A BOLT11 "invoice" has proven too low-level for human use in many
scenarios.  Efforts like lnurl have covered the gap, but integrating
some of such higher layers into the lightning protocol itself has many
advantages.

This draft defines three new things:

1. A new invoice format.  I know, this is painful, but it maps almost
   1:1 to the current format (though signatures are very different),
   is easier to implement, and easier to send via the lightning
   network itself.

2. Formats for an "offer", which for all intents and purposes serves
   as the new, persistent invoice for users.

3. Format for an "invoice_request": this is a message sent via the
   lightning network itself to receive the real invoice, or can
   be used directly in a send-money scenario (e.g. ATM).

The offer (for accepting payments) or invoice_request (for sending
payments) are usually presented via a QR code or similar, the replies
are sent using onion messages.  Each copies fields from the prior so
it stands alone, to allow statelessness.

Features which have been deliberately omitted for the initial version:
- Recurrence.
- Invoice replacement ("don't accept that old payment!")
- Payer proof for refunds.

This effort has been EPIC, and there is absolutely no way I could have
done this without the often thankless task of implementing,
re-implementing, revising and re-reading this text.

In particular I have been delighted to receive the mental boost from
the following people:

1. Thomas H of ACINQ (https://github.com/thomash-acinq)
2. Jeffrey Czyz of Square Crypto (https://github.com/jkczyz)
3. Joost Jager (https://github.com/joostjager)
4. Aditya Sharma (https://github.com/adi2011)
5. Rene Pickhardt (https://github.com/renepickhardt)
6. Bastien Teinturier of ACINQ (https://github.com/t-bast)
7. Valentine Wallace of LDK (https://github.com/valentinewallace)
8. Matt Corallo of LDK (https://github.com/BlueMatt)

Also @bjarnemagnussen, @ellemouton, @animatedbarber, @617a7a,
@instagibbs, @evansmj, @eupn and @yyforyongyu.

(And no doubt others over the years, who I've accidentally omitted!)

Yes, of course, thanks to my family for their patience with me.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-09-24 19:40:59 +09:00
Jeffrey Czyz
df4af02eb1 Add a sciddir_or_pubkey fundamental type
Offers may contain blinded paths to allow for greater recipient privacy.
However, they come at a cost of increased QR code size as the
introduction node requires a 33-byte `point`.

Define a new `sciddir_or_pubkey` fundamental type such that either a point or a
reference to one in a `channel_announcement` can be used. This is
backwards compatible with `point`.

Use this new type for the `blinded_path` subtype's `first_node_id`.
2024-09-24 19:40:59 +09:00
Jeffrey Czyz
86ba089de7 Allow using short_channel_id in onion messages
Offers may contain blinded paths to allow for greater recipient privacy.
However, they come at a cost of increased QR code size as each hop
requires a 33-byte `point` for the `next_node_id`. Allow using
`short_channel_id` instead, which only requires 8 bytes.

Still allow for use of `next_node_id` for cases where the blinded path
may not involve channel counterparties or for long-lived offers, which
may outlive the given channels.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-09-24 19:40:59 +09:00
Rusty Russell
b26da74abf tools/spellcheck.sh: more generally ignore things inside ``.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-09-24 19:40:59 +09:00
Rusty Russell
4e0e38459b BOLT 1: Add utf8 type.
It's far easier to validate these on parsing than to hand-validate them
elsewhere.

I didn't turn `alias` or `error` into this, though they're similar
(`alias` can have a nul terminator).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-09-24 19:40:59 +09:00
Rusty Russell
0277f4276e BOLT 1: add bip340sig type.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-09-24 19:40:59 +09:00
ziggieXXX
0809f77c7b
BOlT07: clarify dont_forward bit use cases. (#1198) 2024-09-18 13:37:56 +02:00
Antoni Spaanderman
e6ee5f8b95
Fix broken links to anchor section (#1000) 2024-09-18 13:32:39 +02:00
Hugo
e0b1200ffa
Bolt 11: add example SHA256 hash of description (#994)
Clarify test vector.
2024-09-18 11:09:49 +02:00
Matt Morehouse
0463bdb51b
Replace "logical OR" with "bitwise OR" (#991)
This makes more sense given the context of combining bitmaps.
2024-09-18 11:08:53 +02:00
Yong
fd83d7cee0
trivial: fix wording and links in bolt03 (#1192)
* bolt03: fix link to `bitcoind`'s `policy.cpp` file

The original link is broken, we now replace it with a permalink.

* bolt03: remove 0 `txout` count in closing tx

Txns cannot have zero outputs.

* bolt03: remove wrong ref to `remotepubkey` and fix format

`remotepubkey` has been placed at the wrong place, also fixes the format
so it's easier to read.
2024-08-27 09:29:19 +02:00
Rusty Russell
5dec5eb849 BOLT 3: Fix example keys in test vectors.
All the test vectors use static keys now, which are listed above
already as the local_payment_basepoint and remote_payment_basepoint.
The keys listed here are the pre-static rotated ones: if you use
these, the vectors don't work!

We actually use the same basepoint for the HTLCs, but never spelled it
out.  So do that now, and these are the local/remote htlc keys.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-08-16 10:16:05 +09:30
Olaoluwa Osuntokun
22b9c87453
Merge pull request #1182 from rustyrussell/clarify-onions-part-2
Clarify onions part 2: a bit deeper rework
2024-08-13 16:11:20 -07:00
Alex Bosworth
9b7895b209
Make blinded link work (#1190)
Fix link reference to point at sub section with minimal link reference
2024-08-12 17:00:39 +02:00
Rusty Russell
0aae209c1a BOLT 4: fix nomenclature in bolt04/route-blinding-test.json
Bastien points out we didn't update this when we changed terms.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-30 06:57:20 +09:30
Rusty Russell
3c0fd9ad90 BOLT 4: More clarifying changes.
1. Always use the term `encrypted_recipient_data` for the encrypted field:
   it's confusing enough without multiple names!
2. Don't give an option for joining blinded payments, since everyone will
   use an unblinded payment to the introduction node (at least, for now).
3. Avoid the term "payer" and at least note that encrypted_recipient_data
   can be made by the sender themselves, pointing out that the forwarding
   node cannot tell.

Thanks t-bast and gijswijs for this feedback!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-30 06:56:48 +09:30
Rusty Russell
6654c5711a BOLT 4: rename onionmsg_hop to blinded_path_hop
It's used for blinded payment paths, too, not just onion messages.

Suggested-by: @t-bast
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:56:32 +09:30
Rusty Russell
43725d7f07 BOLT 4: put dummy hop recommendation into the requirements.
It was mentioned in the rationale only.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:55:27 +09:30
Rusty Russell
d91642e6a0 BOLT 4: try to improve blinded path description.
It's a bit complex, but try to convey the idea of an introduction point,
blinded node ids and encrypted blobs.  Since the requirements detail the
two ways to reach the introduction node, I handwaved on that a bit.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:54:27 +09:30
Rusty Russell
9c15a5c092 BOLT 4: clarify blinded path requirements.
Writer parts:
1. Be explicit that the writer creates a route.
2. Make it clear we create shared secrets, then derive blinded points.
3. Refer explicitly to all `blinded_path` fields.

Split reader into the *two* readers:
1. The reader of the blinded path, who uses it to make an onion (which wasn't described at all!)
2. The reader of the encrypted_recipient_data, who decrypts it.

In the latter case, we don't have to discuss unblinding the onion since
that's now covered in the "Onion Decryption" section.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:53:27 +09:30
Rusty Russell
6c0f0d878f BOLT 4: concretely refer to the blinded_path type and field when constructing.
This spec was initially written before the `blinded_path` type
existed.  Be precise (and we no longer need to say "MUST communicate"!).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:45:10 +09:30
Rusty Russell
14ebb445e6 BOLT 4: move Route Blinding section up a level, and put blinded_path type there.
It's currently buried in the onion message section, but it applies to payments too.

We now have a separate sub-section for the encrypted_data_tlv definition.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:41:35 +09:30
t-bast
3fffab3b88 Clean-up nits
This commit doesn't change the logic at all, it simply:

- removes `realm` from onion test vector
- cleans-up markdown formatting and indents
- fixes typos and missing parenthesis
- consistently uses `_` instead of `-` for field names
- fixes math formatting (including changes from #1169 and #1158)
2024-07-17 10:40:35 +09:30
Rusty Russell
5e9ea22272 BOLT 2, 4: rename blinding to path_key.
Sure, it's used to derive a secret for blinding, but it's also used to derive the key
for encrypted_recipient_data.  It's not used as a blinding factor *directly*.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:40:35 +09:30
Rusty Russell
bc1ce064d2 BOLT 2, BOLT 4: refer to the onion decryption section in update_add_htlc/onion message requirements.
This ties it together, saying what to use as associated data, blinding, and what to do on failure.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:40:35 +09:30
Rusty Russell
8abd9c7e26 BOLT 4: Generalize and create proper requirements for onion decryption
There's currently a *description* of how to decrypt an onion, and some requirements
in forwarding.  But it also applies to onion messages, so:

1. Turn the description into actual enumerated requirements.
2. Ensure the description covers both payload and messaging onions.
3. Include both methods to apply the blinding tweak.
4. Leave the actual handling of the extracted payload (payment vs messaging onion) to those specific sections (e.g. reporting failure)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:40:35 +09:30
Rusty Russell
6a51861d93 BOLT 4: remove obsolete references to realm
This was from the legacy onion, and is no longer present.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:40:35 +09:30
Elle
e29fca5703
bolt4+proposals: fix max_cltv_expiry calculation (#1176)
* BOLT4: include `min_final_cltv_expiry_delta` in `max_cltv_expiry` calc

Include `min_final_cltv_expiry_delta` in the `max_cltv_expiry`
calculation. Also add a note that indicates that this field may be set
for the final node too. This is useful for the final node as then it
does not need to persist the path expiry separately and can rely on just
checking the `payment_relay` field when the payment arrives.

* BOLT4: include calculation for `total_cltv_delta` of a blinded path

Include an explicit formula to use for determining the total CLTV delta
of a blinded path so that it is clear that it should include the
recipient's `min_final_cltv_expiry_delta`.

* proposals: fix `max_cltv_expiry` value for final hop in example

More info
[here](https://github.com/lightning/bolts/issues/1174#issue-2371364610)
outlining why the example needed to be updated.
2024-07-15 22:20:48 +02:00
Matt Corallo
93b7ee031b
Drop the required channel_update in failure onions (#1173)
As noted previously, `channel_update`s in the onion failure packets
are massive gaping fingerprintign vulnerabilities - if a node
applies them in a publicly-visible way the err'ing node can easily
identify the sender of an HTLC.

While the updates are still arguably marginally useful for nodes to
use in their pathfinding local to retires of the same payment, this
too will eventually become an issue with PTLCs. Further, we
shouldn't be letting nodes get away with delaying payments by
failing to announce the latest channel parameters or enforcing new
parameters too soon, so treating the node as having indicated
insufficient liquidity (or other general failure) is appropriate
in the general case.

Thus, here, we begin phasing out the `channel_update` field,
requiring nodes ignore it outside of the current payment and making
it formally optional (though nodes have been doing this for some
time due to various bugs).

Because some nodes may want to use update data on mobile when they
have stale gossip data, it is left optional.
2024-07-11 09:32:21 +02:00
ziggieXXX
64ce121cdc
BOLT04: Add rationale for constant error decryption. (#1154)
To avoid timing analysis when decrypting failed payments the sender
should act as if the failure in the route came for the 27th hop.
Also changed the maximum number of hops in the route from 20 (legacy)
to 27 (tlv onion).
2024-07-02 12:03:54 +02:00
Rusty Russell
c562d91ace BOLT 2: add requirement for disconnect if quiescence takes too long with HTLCs pending.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-06-18 07:08:11 +09:30
Keagan McClelland
99d67c6c73 require quiescence sessions to be single-use 2024-06-18 07:08:11 +09:30
Rusty Russell
5dd9d9cd5f BOLT 2: quiescence protocol.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>




Header from folded patch 'bolt_2__set_an_initiator_in_quiescence.patch':

BOLT #2: Set an initiator in quiescence.

This is especially useful for protocols such as splicing; for
simplified commitment transactions, there is already an implied
initiator at each point, so having the negotiation at splicing
time would be redundant.

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



Header from folded patch 'option_quiesce__feature_to_support_stfu_method.patch':

option_quiesce: feature to support stfu method.

In practice, sftu is useless unless you have something (e.g. channel_upgrade)
which uses it, but adding a feature is best practice IMHO.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-06-18 07:08:11 +09:30
Olaoluwa Osuntokun
57ce4b1e05
Merge pull request #1165 from t-bast/remove-old-features-typos
Clean-up: follow-up on removing spec features
2024-06-03 13:11:04 -07:00
t-bast
3e9b5728cc
Clean-up: follow-up on removing spec features
This is a follow-up to https://github.com/lightning/bolts/pull/1092
that fixes the following issues:

- fix a few typos
- remove non-zero-fee anchors test cases
- remove `remote_pubkey` rotation
2024-05-21 10:58:55 +02:00
Rusty Russell
fc687e8c76 BOLT 9: Remove initial_routing_sync.
This only had an effect when `gossip_queries` was not negotiated, which is now assumed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-20 15:06:27 -05:00
Rusty Russell
fce8bab931 BOLT 9: Assume gossip_queries.
Supported by all but 11 nodes*.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
[* there are 449 three-year old LND nodes which advertize `2200` as their features, which have already been trimmed from most gossip for not having htlc_maximum_msat in their channel_updates]
2024-05-20 15:06:27 -05:00
Rusty Russell
e042c615ef BOLT 9: assume var_onion_optin.
Advertized as supported by all but 6 nodes (and those can no longer
route payments since people only send the modern onion these days)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-20 15:06:27 -05:00
Rusty Russell
c48b4e3b27 BOLT 9: rename option_anchors_zero_fee_htlc_tx to option_anchors.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-20 15:06:27 -05:00
Rusty Russell
d745028f65 BOLT 9: Remove option_anchor_outputs, in favor of option_anchors_zero_fee_htlc_tx.
It's supported only by pre-23.05 core-lightning nodes built with
EXPERIMENTAL_FEATURES.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-20 15:06:27 -05:00
Rusty Russell
91f4bd2383 BOLT 9: option_data_loss_protect and option_static_remotekey are now assumed.
These still have names and numbers, since they appear in `channel_type`.  They are somewhat tangled with each other, so let's tie them together as assumed.

option_data_loss_protect is advertized by all by 11 nodes(*), and option_static_remotekey all but 16 nodes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
[* there are 449 three-year old LND nodes which advertize `2200` as their features, which have already been trimmed from most gossip for not having htlc_maximum_msat in their channel_updates]
2024-05-20 15:06:27 -05:00
Rusty Russell
b750c3d8f9 BOLT 9: Add ASSUMED marker we can use on features.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-20 15:06:27 -05:00
Bastien Teinturier
5f8fea8dc3
gossip: 12-blocks delay channel closed follow-up (#1156)
We introduced a 12-blocks delay for channel closing in #1004, but we
didn't update the requirement in the section about pruning.
2024-05-07 09:45:44 +02:00
Olaoluwa Osuntokun
db278ab9b2
Merge pull request #1151 from Roasbeef/blinded-paths-notation
BOLT-04: use underscores in place of parens for blinded paths notation
2024-04-22 13:21:55 -07:00
Olaoluwa Osuntokun
ed012edc15
BOLT-04: convert blinded paths syntax to use LaTeX rendering
Github now supports inline LaTeX rendering:
https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/writing-mathematical-expressions

In this commit, we use this new feature to improve the rendering of the
routines for blinded paths.
2024-03-27 18:30:37 -07:00
Olaoluwa Osuntokun
25e7dbd5ed
BOLT-04: use underscores in place of parens for blinded paths notation
In this commit, we propose a purely syntactical change to the current
blinded paths specification. Rather than denote the public key of the i-th
node as `E(i)`, we propose that instead it's denoted as: `E_i`. This results
in less overall characters, and is more similar to notation customarily
used in LaTeX.

My personal preference is that the proposed notation is easier to scan at a
glance, and also less ambiguous (doesn't look like a function call).
2024-03-27 18:30:31 -07:00
Erik De Smedt
08ce2f6f83
Fix broken link in BOLT-2 (#1148) 2024-03-14 11:48:03 +01:00