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

927 Commits

Author SHA1 Message Date
t-bast
daa853ce35
Peer backup storage (features 40/41/42/43)
Nodes can offer to altruistically store small amounts of data on behalf
of their channel peers. It complements `option_data_loss_protect` and can
let nodes that lost data fully recover their channels.

There are two types of backups available:

* Per-channel backups, for channel-related data
* Per-node backups, for data potentially unrelated to channels

There are two distinct pairs of features bits, because this is an
assymmetric feature: one feature bit for the consumers and one for the
providers of peer backups.

This gives a lot of flexibility for use-cases where nodes may want to be
both a consumer and provider of the feature, and lets consumers require
their peers to be providers of the feature.
2022-05-24 16:08:16 +02:00
Matt Corallo
fe96e8fc3d Note that lightning implementations used to skip the msg type bytes
...well, okay, do today, but by the time anyone is reading this
it'll be "used to".
2022-05-19 08:28:31 +02:00
Matt Corallo
de8bb07a65 Clarify how to encode channel_update messages in onions
Apparently not all implementations implemented the onion encoding
the same, causing vastly differing onion failure packets. This
should unify them somewhat.

CC https://github.com/ElementsProject/lightning/issues/5154
2022-05-19 08:28:31 +02:00
Matt Corallo
03468e1756 Clarify what the two flag bytes are in channel_disabled failures
Fixes #791
2022-05-19 08:28:31 +02:00
Vincenzo Palazzo
e7017173d6
bolt2: disallow sending multiple shutdown msg (#977)
The rationale for this is to avoid bad cases like the following one
which was previously allowed:

* sender -> shutdown(script_one) -> receiver
* sender -> shutdown(script_two) -> receiver
* sender <- shutdown(script_one) <- receiver

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-05-18 15:51:37 +02:00
Rusty Russell
105c2e5e9f BOLT 1: make remote_addr definition machine readable.
It had a blank line and invalid format for tools/extract-formats.py.

And move the format information into the requirements section
(and fix spelling: `node_announement` -> `node_announcement`

Diff for extract-formats.py before and after:

```diff
--- /tmp/before	2022-05-17 10:47:01.583086352 +0930
+++ /tmp/after	2022-05-17 10:51:59.166850111 +0930
@@ -6,6 +6,8 @@
 msgdata,init,tlvs,init_tlvs,
 tlvtype,init_tlvs,networks,1
 tlvdata,init_tlvs,networks,chains,chain_hash,...
+tlvtype,init_tlvs,remote_addr,3
+tlvdata,init_tlvs,remote_addr,data,byte,...
 msgtype,error,17
 msgdata,error,channel_id,channel_id,
 msgdata,error,len,u16,
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-05-18 10:15:05 +09:30
Gregory Sanders
c4a0369e70
Make generated pubkeys slightly more grep-able (#988)
* remotepubkey instead of remote_pubkey
* Add a grepable reference of localpubkey usage
2022-05-12 09:19:21 +02:00
Matt Corallo
c1b94dfad1
Merge pull request #981 from TheBlueMatt/2022-4-no-zlib
Remove zlib compression gossip query support
2022-04-25 20:42:49 +00:00
Antoni Spaanderman
2bd5d7e682
Bolt 3: fix broken markdown link (#984) 2022-04-22 13:31:59 +02:00
ziggie1984
71610b06bb
Minor clarification of htlcs to_self_delay (#983)
This is a minor clarification that the `to_self_delay` is enforced
in a 2nd-stage transaction for HTLCs, while it's directly enforced
in the commit tx for the main output.
2022-04-22 09:36:52 +02:00
Matt Corallo
2e8f2095a3 Remove zlib compression gossip query support
Gossip query compression is not very useful - it was added for
mobile clients to, in theory, sync the gossip data directly from
P2P peers, but to my knowledge no mobile clients actually use it
for that, or at least use it where the gossip *query* data is a
substantial portion of their overall bandwidth usage.

Further, because of the semantics of `gossip_timestamp_filter`, its
impractical to ensure you receive a reliable, full view of the
gossip data without re-downloading large portions of the gossip
data on startup.

Ultimately, gossip queries are a pretty non-optimal method of
synchronizing the gossip data. If someone wants highly optimized
gossip data synchronization a new method based on set
reconciliation needs to be propose.

Finally, the current gossip query encoding semantics do not allow
for negotiation and instead require all lightning implementations
take a zlib dependency in some form or another. Given the recent
zlib decoding memory corruption vulnerability, this seems like an
opportune time to simply remove the zlib support, requiring that
nodes stop sending compressed gossip query data (though they can
support reading such gossip query data as long as they wish).

This is an alternative to the suggested gossip query encoding
support in #825.
2022-04-21 18:23:38 +00:00
Gregory Sanders
cf4fddd99e
Fix routing example: channel_update contains cltv_expiry_delta (#978) 2022-04-15 08:48:41 +02:00
t-bast
32a76e80c7 Echo channel_type in accept_channel
One argument for adding a feature bit for channel types was to make things
more explicit and remove ambiguity.

When sending `open_channel`, we require funders to include a `channel_type`,
so it would make sense to require fundees to echo that `channel_type`
back to explicitly confirm that they're ok with this `channel_type`.
2022-03-14 14:58:34 -05:00
Rusty Russell
e60d594abf
Fix typo and aspell list. (#963)
Since Travis died, we don't get CI to check these any more :(

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-02-25 12:17:18 +01:00
Bastien Teinturier
5fa6ff3360
Warn on quick close fee mismatch instead of disconnecting (#904)
When peers disagree on the closing fee range, disconnecting
doesn't make sense: upon reconnection they will just send the
same `closing_signed` again.

A warning should instead be sent and logged, so that node
operators can decide to update their fee range if they want
this channel close to make progress.
2022-02-15 08:47:53 +01:00
Ken Sedgwick
d975de1ba5
Clarify the sighash types for HTLC Success and Timeout transactions (#954) 2022-01-31 21:05:20 +01:00
lightning-developer
29db92f334
Removed requirement to broadcast an outdated commitment transaction (#942)
If a node has to fail a channel but knows that its latest commitment transaction is outdated it should not be required to send it but rather wait for the peer to unilaterally close the channel. 

The proposed solution is not so clean because it might produce a deadlock in which two peers assume they have outdated state and send `error` back and forth without actually force closing. Maybe in such a scenario we could create a protocol that mutually closes with split balance? 

Also replaced the word use with broadcast as it seems more accurate.

Co-authored-by: t-bast <bastuc@hotmail.fr>
2022-01-17 20:09:28 +01:00
Matt Corallo
ed7b5f5749
Merge pull request #917 from m-schmoock/bolt1-remote-address
BOLT 1: adds remote address to optional init_tlvs (IP discovery)
2022-01-17 19:05:46 +00:00
Matt Corallo
c878cd8e1d
s/send a warning/warn the user/ in BOLT 5 to avoid confusion (#951)
Prior to the addition of `warning` messages, BOLT 5 specified a
few cases where users should be warned that funds may have been
lost. However, it used the phrasing "send a warning" which can now
be confused  with `warning` messages. Nodes should not generally
inform their counterparty that they have been robbed.
2022-01-17 19:40:47 +01:00
Michael Schmoock
efe9d2d151 BOLT 1: adds remote address to optional init_tlvs
This adds the option to report an remote IP address back to a connecting
peer using the `init` message. A node can decide to use that information
to discover a potential update to its public IPv4 address (NAT) and use
that for a `node_announcement` update message containing the new address.

The proposal includes reporting the IPv4 and IPv6 address,
however in IPv6 there are likely no NAT issues. TOR is skipped for
obvious reasons.

Certain approaches to check and use this information are thinkable:
 - Wait for multiple peers or a certain fraction to report the
   same new address.
 - Check some random node known via gossip to also report the new
   address.
 - Verify this information by making a test connection to itself.
2022-01-07 16:39:19 +01:00
Olaoluwa Osuntokun
ea37941537
anchors: follow up changes after initial zero fee anchors merge (#903)
We can remove references to anchors in a few places, and you need
static key in order to support it, so that reference is redundant.
2022-01-04 09:26:43 +01:00
Matt Corallo
f6c4d76041
Merge pull request #912 from joostjager/custom-invoice-data
Add payment metadata to payment request (feature 48)
2022-01-03 20:18:52 +00:00
Matt Corallo
93909f67f6
Merge pull request #950 from rustyrussell/guilt/soft-errors
Really: BOLT 1: introduce warning messages, reduce requirements to send (hard) errors
2022-01-03 19:36:04 +00:00
Rusty Russell
8032f70f57 BOLT 1: Restore all-zero error semantics
There were valid uses for "I don't want to talk to you anymore" apparently!

Also fixed some tabs -> spaces.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-01-04 05:55:42 +10:30
Joost Jager
2ab3a9f022
Add payment metadata to payment request 2022-01-03 20:09:14 +01:00
Rusty Russell
c36c14d6da BOLT 2: Error instead of warning on shutdown on unopened channel.
Abandoning channel is kinda what they want here.

Reported-by: Matt Corallo
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-12-14 10:32:24 +10:30
Rusty Russell
4fc9f51889 Update 03-transactions.md
Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
2021-12-14 10:32:24 +10:30
Rusty Russell
eb6f3084c5 Make it explicit when to send warnings, errors, fail channel and close connection.
And make most places warn or error.  Places where we're operating
on a channel tend to be "warn and close connection" since we want to
forget the mistake they just sent, and closing the connection does that.

We now use the same words everywhere:
1. "fail channel" means to go onchain (if necessary).
2. "send `error`" means to send an error message.
3. "send `warning`" means to send a warning message.
4. "close connection" means close the connection.

These are all spelled out explicitly, rather than having "fail channel"
imply sending an error packet, for example.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-12-14 10:32:22 +10:30
Rusty Russell
474b68caea BOLT 1: Add warning message, remove "close all" error.
Under this spec, an error with an all-zero channel id is ignored.
Warnings, being odd, will be ignored by older nodes too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-12-10 04:48:20 +10:30
Matt Corallo
58287e2f5b
Merge pull request #918 from TheBlueMatt/2021-09-drop-ping-rl
Drop ping sending rate-limit suggestion
2021-12-09 18:17:20 +00:00
Antoine Poinsot
886c8f0d98
gossip: deprecate Tor v2 onion services (#940)
Advise to not include/ignore them in announcements
2021-12-06 09:18:58 +01:00
Olaoluwa Osuntokun
630bf989db
BOLT-02+09: introduce feature bit to gate new channel_type feature (#906)
In this commit, we add a new feature bit to gate the new explicit
channel type funding via the new `channel_type` TLV. The addition of
this new bit allows peers to seek out other peers that understand the
new explicit channel negotiation. This is useful in practice, as it
allows peers to avoid needing to "downgrade" the feature bits advertised
at the connection level due to one peer not understanding a new
required feature bit while it has a channel with a connecting peer.

Such a workaround is already deployed on the network between lnd peers
and certain eclair peers, as the `lnd` peers require static key, but the
feature bit is unknown to eclair peers. This situation (forced
downgrade) is undesirable, as until the connected peer updates (or the
channel is closed) and "worst" feature bit set must always be advertised
in order to maintain connectivity.

The other benefit of adding this feature bit is that it allows
implementations to simplify their code by ensuring that the new feature
will be used before sending any messages that include or reference that
feature. Without a feature bit, peers are instead forced to essentially
guess if a peer understands that feature, with logic to be able to "bail
out" of an invalid state.

The addition of this feature bit matches the prior precedent of adding
feature bits when new fields in the channel negotiation message (last
one was upfront shutdown) are added.
2021-12-05 16:35:35 -08:00
Gregory Sanders
6458473336
BOLT01: Switch extension records to unknown fields in test vector (#938)
The test vectors for invalid `init` messages were invalid since we added
the `networks` tlv extension.

They are now fixed and made more future-proof by using tlvs with high
values.
2021-11-29 14:29:09 +01:00
ghost43
0dc3af80ce
Fix typo in name mailing list name (#931) 2021-10-27 15:54:09 +02:00
katesalazar
39806e7d8b
Make Markdown linguist-detectable (#930)
Before this change, repository gets detected as:

Python 51.1%
Shell 48.9%

After this change, repository gets detected as:

Markdown 98.0%
Other 2.0%

This change was added for a cosmetic effect on GitHub, and the line
this change adds can go away if needed.
2021-10-25 20:55:05 +02:00
Bastien Teinturier
86a96ea7c6
Remove link to lightning.network website (#926)
None of the project maintainers have access to that website.

It is completely outdated and could be modified without our consent,
so we shouldn't link to it anymore.
2021-10-19 08:15:02 +02:00
Adam Gibson
3d88d1dd31
Remove stale reference to the gamma key from Bolt 4 (#928)
Fixes #927.
The gamma key was removed from the onion routing spec in 8b29062.

Co-authored-by: Adam Gibson <AdamISZ@protonmail.com>
2021-10-19 08:14:36 +02:00
Bastien Teinturier
8f2104e3b6
Peers need to check each other's dust limit (#894)
Since HTLCs below this amount will not appear in the commitment tx, they
are effectively converted to miner fees. The peer could use this to grief
you by broadcasting its commitment once it contains a lot of dust HTLCs.

Add network dust thresholds computation details, as implemented in Bitcoin
Core's default relay policy.

Drop non-segwit support in shutdown: this allows dust limit to go as low
as 354 sats without creating relay issues with default node policies.

We add a requirement that dust limit cannot be lower than 354 sats.
This ensures implementers don't have to figure this subtlety on their own.

Fixes #696 and #905
2021-10-06 09:40:22 +02:00
Bastien Teinturier
e832059827
Restrict bitcoin amounts (#908)
It doesn't make sense to exchange amounts that exceed the total bitcoin
supply, so let's make that an explicit requirement.
2021-09-28 08:33:27 +02:00
Matt Corallo
49e1c1cba9 Drop ping sending rate-limit suggestion
There's not a lot of reason to explicitly rate-limit ping messages
on the sending side, hosts on the internet can *always* send you
as much traffic as they want, its up to you whether you want to
talk back to them.

This seems to have been intended as a cutoff where nodes can skip
responding to pings below a certain rate, but in practice 30
seconds is much too long a time to learn that your peer has
disconnected.

We could reduce the threshold, but its not like this is the only
place in the spec where a peer can request a message response, and
that is unlikely to change, making it of highly dubious value.
2021-09-27 20:42:03 +00:00
Bastien Teinturier
c876dac2b5
Add payment secret feature to Bolt 11 test vectors (#898)
Bolt 11 invoices must contain a `payment_secret`, which means that the
`features` field must set the `payment_secret` feature (and its dependency,
`var_onion_optin`).

Fixes #897
2021-09-14 09:11:45 +02:00
Rusty Russell
38abac6206
BOLT 3: add a missing Otherwise, don't SHOULD "be". (#907)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-09-03 08:37:48 +02:00
Bastien Teinturier
498f104fd3
Update closing_signed fee requirement (#847)
With anchor outputs, we can keep the commit tx feerate lower than the real
on-chain feerate. That means that when closing the channel, the resulting
fee will not necessarily be lower than the current commit tx fee, this
requirement doesn't make sense to be strict.

Both sides can optionally include a preferred fee range in their
`closing_signed`. This lets their peer know what fees they find acceptable
and simplifies the closing negotiation.
2021-08-31 09:08:07 +02:00
Rusty Russell
4372f9d538 BOLT 2: define channel_type, make negotiation explicit.
This is extracted from channel_upgrade (#868), but used for opening
negotiation as suggested by @roasbeef on the last spec meeting.

It's a trivial change, fully backwards compatible, but now each channel
has a channel_type, which defines its behavior, rather than an ad-hoc
set of "sticky" feature bits.  It also means both peers can *support* a
feature without endorsing it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-08-31 10:02:20 +09:30
Johan T. Halseth
fdc078f845
feature: define option_zero_htlc_tx_fee (feature 22/23) (#824)
This PR adds a new feature bit to define the new and improved anchor outputs commitment format.
2021-08-30 13:50:25 -07:00
Rusty Russell
d892c318af
BOLT 7: remove 2^32 restriction from channel_update as well. (#902)
This was missed in #877

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-08-30 18:29:21 +02:00
Olaoluwa Osuntokun
07c7caed51
Merge pull request #887 from lightningnetwork/bolt11-test-vectors-payment-secret
Make payment secret mandatory and update Bolt 11 test vectors
2021-08-16 18:37:21 -07:00
t-bast
ec1d4dc665
Make s field mandatory in invoices 2021-08-10 17:22:23 +02:00
t-bast
42bd71d49c
Add payment secret to Bolt 11 test vectors
Update Bolt 11 test vectors to always include a payment secret.

We want to make it mandatory in invoices which would make the existing
test vectors invalid.
2021-07-19 14:41:34 +02:00
Bastien Teinturier
84213f45c0
Remove HTLC amount restriction (#877)
We previously had a restriction on HTLC amounts to avoid big losses during
the early phases of the network, but it shouldn't be necessary anymore.

As long as we honor `max_htlc_value_in_flight_msat` and implementations
provide safe defaults for that parameter, we don't need that additional
restriction.
2021-06-21 22:41:46 +02:00