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

95 Commits

Author SHA1 Message Date
jrakibi
ec525cc418 Update Signet port to correct hex value in BOLT #1 spec 2024-02-16 08:57:36 +10:30
t-bast
811e55cd9e Use signed amounts in RBF messages
While dual funding only needs unsigned funding amounts, other protocols
that leverage interactive-tx may use signed funding amounts, for example
to take funds out of an existing channel (splice-out).

It is thus more future-proof to use signed amounts in `tx_init_rbf` and
`tx_ack_rbf`.
2024-02-13 11:55:23 -06:00
niftynei
c00c0dd7bc interactive-tx: Add dual-funding flow, using the interactive tx protocol
This commit adds the interactive transaction construction protcol, as
well as the first practical example of using it, v2 of channel
establishment.

Note that for v2 we also update the channel_id, which now uses the hash
of the revocation_basepoints. We move away from using the funding
transaction id, as the introduction of RBF* makes it such that a single
channel may have many funding transaction id's over the course of
its lifetime.

*Later, also splicing
2024-02-13 11:55:23 -06:00
niftynei
15fb2df63a spelling: fix spelling mistakes + add new words to ignore spelling 2024-02-13 11:55:23 -06:00
Rusty Russell
95f2bbf2e2 BOLT 1: define what offered and negotiated mean.
i.e. it was present in the init feature bits.  We use this in several places, but assume everyone knows what it means.

It's particularly fraught with required features: it's explicitly legitimate to assume these are accepted if
the node keeps talking to you after init!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-13 12:02:14 +09:30
Matt Corallo
2bf041f382
Merge pull request #1075 from t-bast/remove-disconnect-warning
Remove requirements to disconnect on warnings
2023-05-09 18:06:53 +00:00
Peter Neuroth
5635a3657e
Bolt 1: Clarify the definition of tu fields (#1073)
Truncated integer fields, e.g. tu16 cannot have leading zeros
judging by the implementations of the parsers, which are used
across the different ln implementations.
The `can` imposed that it is not necessary to truncate the fields
to values of information.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2023-05-08 22:57:46 +02:00
t-bast
3747ba8302
Remove requirements to disconnect on warnings
We generally shouldn't disconnect when sending or receiving warning
messages. Whenever disconnecting after a warning makes sense, it should
be specified in the requirements linked to that specific scenario.

Fixes #1072
2023-05-05 09:37:48 +02:00
Vincenzo Palazzo
c74a3bbcf8
BOLT 1: introduce port convention for different network (#968)
* bolt1: introduce port convention for different network

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-05-23 13:44:05 -07: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
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
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
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
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
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
Corné Plooy
13520a0e36 tlvs -> tlv_stream subsitution everywhere 2020-11-09 13:10:22 -06:00
Dr. Maxim Orlovsky
bdd4271101
Clarification on the occurences of TLV records with the same type (#777)
Closes #776
2020-07-07 10:09:54 +02:00
Rusty Russell
9e8e29af9b
Complete the Fundamental Types. (#778)
* Rename all the 'varint' to 'bigsize'.

Having both is confusing; we chose the name bigsize, so use it
explicitly.

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

* BOLT 7: use `byte` instead of `u8`.

`u8` isn't a type; see BOLT #1 "Fundamental Types".

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

* BOLT 1: promote bigsize to a Fundamental Type.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-25 22:25:46 +02:00
Bastien Teinturier
f068dd0d8d
Bolt 1: Specify that extensions to existing messages must use TLV (#754)
The spec already prepared a hook to add additional information to existing
messages (additional bytes at the end of a message must be ignored).

Since we're using TLV in many places, it makes sense to use that optional
additional space at the end of each message to allow an optional tlv stream.

This requires making a few previously optional fields mandatory:

- channel_reestablish commitment points: it makes sense to always include those
  regardless of whether `option_dataloss_protect` or `option_static_remotekey` are set.
- option_upfront_shutdown_script: if you're not using one, just set the length to 0.
  That field is moved to a TLV record because luckily, the resulting bytes are the same.
  This provides more flexibility to later remove the requirement of making this field mandatory.

No need to change the `channel_update`'s `htlc_maximum_msat` because
the `message_flags` encode its presence/absence.
It can still be either included or omitted without causing issues to the extension stream.
2020-03-31 08:58:22 +02:00
Bastien Teinturier
f38f559244
Revert "Bolt 1: Specify that extensions to existing messages must use TLV (#714)" (#753)
This reverts commit 6ac177f95c.
2020-02-29 15:00:42 +01:00
Bastien Teinturier
6ac177f95c
Bolt 1: Specify that extensions to existing messages must use TLV (#714)
The spec already prepared a hook to add additional information to existing
messages (additional bytes at the end of a message must be ignored).

Since we're using TLV in many places, it makes sense to use that optional
additional space at the end of each message to allow an optional tlv stream.

This requires making a few previously optional fields mandatory:

- channel_reestablish commitment points: it makes sense to always include those
  regardless of whether `option_dataloss_protect` or `option_static_remotekey` are set.
- option_upfront_shutdown_script: if you're not using one, just set the length to 0.
  That field is moved to a TLV record because luckily, the resulting bytes are the same.
  This provides more flexibility to later remove the requirement of making this field mandatory.

No need to change the `channel_update`'s `htlc_maximum_msat` because
the `message_flags` encode its presence/absence.
It can still be either included or omitted without causing issues to the extension stream.
2020-02-28 10:25:44 +01:00
Rusty Russell
7b0169263e
BOLT 1: add networks to init message. (#682)
Add networks to init message via TLV extension.
This prevents accidentally connecting a testnet node to mainnet or the other way around.
2020-02-18 09:46:58 +01:00
kiminuo
75f46ba89b
Update 01-messaging.md (#732)
Add missing parenthesis in link.
2020-01-29 10:11:46 +01:00
Bastien Teinturier
caca4375e6 BOLT 1: Define custom message type range 2020-01-21 13:39:27 +01:00
Conner Fromknecht
4c638b7353 09+11: require transitive feature dependencies
This commit:
 - Adds a new Dependencies column to the BOLT 9 feature table
   populated with existing feature dependencies.
 - Requires that all valid feature vectors set transitive dependencies.
 - Requires checking transitive dependencies when validating init
   messages and payment request.
 - Removes transitive feature requiremetns from the BOLT 11 writer, now
   that they are implicit by needing to comply with the BOLT 9 origin
   requirements.
2020-01-21 13:26:49 +01: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
ueno
efd16b9b20 fix <id> tag 2019-11-20 00:12:20 +00: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
Dimitris Apostolou
3476c9b25a Fix typos 2019-09-26 06:12:41 +00: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
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
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
Rusty Russell
76d4ab9f1a BOLT 1: Remove git conflict marker (#628)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-09 09:37:03 +02:00
Rusty Russell
6f6ea63233 BOLT 1,2,4,7: remove pubkey fundamental type in favor of point.
And remove `secret` and `preimage` types in favor of open-coding.

Agreed-at: http://www.erisian.com.au/meetbot/lightning-dev/2019/lightning-dev.2019-07-08-20.05.html

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-09 00:48:46 +00:00
Rusty Russell
72ed1b2214 BOLT 1: add TLV types.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-09 00:48:46 +00:00
Rusty Russell
6639cef095 Spec: use explicit types, not just bytelengths for fields.
It's trivial to make types->lengths, but not so much the other way.

The types I used here are the ones I found useful in implementation, and
I think add some clarity, though we can certainly argue about them.

There's no normative changes to the spec in here.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-09 00:48:46 +00:00
Conner Fromknecht
779664cd82
BOLT01: add TLV spec 2019-06-12 15:14:55 -07:00
Pierre-Marie Padiou
1fd1e76f9e clarify that error should target the unkown channel 2018-10-18 05:15:22 +00:00
Pierre-Marie Padiou
1de095a0b3 reply to unknown channels with an error 2018-10-18 05:15:22 +00:00
Rusty Russell
a8207ec316 BOLT 1: options must be included if negotiated, not if understood.
Obviously you can't include fields you don't understand, but importantly
if the other side doesn't agree, you don't need to include them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-06-28 00:21:23 +00:00
Rusty Russell
6ea6418a92 BOLT 1: dont close channels with other nodes.
Seems obvious, but the spec should spell it out!

Closes: #418
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-05-24 04:21:49 +00:00
ueno
4ef035f8c2 fix #385 2018-02-22 00:15:22 +00:00
practicalswift
a820356da8 Redundancy. Drop redundant use of "very". 2018-01-30 03:34:22 +00:00
MeshCollider
4b5379b2ac Fix formatting of BOLT links 2018-01-22 14:02:01 +01:00
practicalswift
2d9a0b5793 Add missing closing parenthesis 2018-01-08 02:30:34 +00:00
Pierre-Marie Padiou
b46aa422dd do not print DEL character 2017-12-11 23:10:39 +00:00