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

70 Commits

Author SHA1 Message Date
Rusty Russell
034c234829 BOLT 2,3: SHOULD NOT create malleable funding tx.
But note that our funding transaction example is.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-07 06:39:28 +10:30
Rusty Russell
4af8e18411 BOLT 0,1,2,7: use txout not channel-id for demuxing. (#119)
At cost of a few extra bytes between peers, this avoids the whole "oops, we were on a chain fork" problem, and simplifies generation of temporary channel-ids (just pick a random one).

Now we move the announcement_signature exchange to at least 6 confirms, which makes re-xmit tricky; I resolved that by insisting on reconnect that we send if we haven't received, and reply to the first one.

The term "channel shortid" wasn't used anywhere, so I removed it; it's now a gossip-only thing anyway.

One subtle change: pkt_error on unknown channels is now "MUST ignore"; this section was reworked anyway, and we'll want this if the #120 goes through, where one side might have forgotten unformed channels).

Closes: #114
Suggested-by: Olaoluwa Osuntokun <laolu32@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

* FIXUP! Two bytes for funding-output-index.

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

* FIXUP! Channel-id rework, temp ids, 32 bits only.

Re-add the idea of temporary channel ids: far simpler since they're now
big enough we can just fill with noise.

Remove the alignment issues by combining txid and outnum using XOR; we
could reduce to 128 bit if we really wanted to, but we don't.

Error handling is now simple again, but while editing I changed the
behaviour for unknown channels to MUST ignore (this is important for

Change the 8-byte gossip channel id to `short-channel-id`.

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

* FIXUP!  Minor text tweaks from Pierre-Marie and Christian

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-02 14:50:13 +10:30
Pierre-Marie Padiou
03a917fa6b revoke_and_ack is not acked by update messages 2017-02-20 12:05:29 +10:30
Rusty Russell
f63d89c207 BOLT 2: document requirements of max-htlc-value-in-flight-msat
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-16 11:30:17 +01:00
pm47
0958747fe0 BOLT 2: added requirements on htlc forwarding 2017-02-16 10:07:51 +10:30
Otto Allmendinger
5114f58b0e BOLT 02: fix state listing in "Normal Operation"
Markdown wants a newline there.
2017-02-14 09:06:53 +10:30
Otto Allmendinger
560439ddf8 BOLT 02: change "responser" to "responder" 2017-02-14 09:06:53 +10:30
Otto Allmendinger
c977e7ea18 BOLT 02: Remove reference to nonexistent field
Field was removed from the message in commit b228a2e, but it's still
referenced in the description.
2017-02-14 09:06:53 +10:30
Rusty Russell
c5b0bfb620 BOLT 2: specify requirement not to send fulfill until both sides locked in.
Otherwise you can lose funds!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-13 06:30:48 +10:30
Christian Decker
4e3ad54a90 BOLT 2&7: Cleaner separation of concerns wrt announcement signatures (#97)
* BOLT 2&7: Cleaner separation of concerns wrt announcement signatures

So far we did not have any indication on what to do if a node does not
allow announcing the channel and we had a mix of concerns in the
`funding_locked` message, which would also transfer the signatures
needed for the announcement. This is a proposal about splitting the
signatures into their own message, so that simple omission is an
opt-out of announcements, and it does not mix announcement/gossip
stuff into the peer-protocol.

(It also ended up adding a localfeatures flag to opt-into the channel-announcement, and thus creating BOLT 9)
2017-02-07 11:23:39 +10:30
Pierre-Marie Padiou
240f914cde BOLT 2: fixed broken table of contents 2017-02-01 13:52:52 +01:00
Pierre-Marie Padiou
74c9fa7493 replaced payment-key by payment-hash 2017-02-01 20:46:38 +10:30
Rusty Russell
40b747806e BOLT 2, BOLT 5: restrict to ASCII characters.
’ -> '

LANG=C python3 complains otherwise.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-25 10:40:10 +10:30
Rusty Russell
9308eb145a BOLT 2: clarify comment about reversing uncommitted changes on reconnect, and timeouts.
Olaoluwa pointed out that peers can make work for us by starting to open
connections then disconnecting: we need to allow timeouts, since it's
the simplest solution.

The comment about remembering `r` values (ie. `payment-preimage`) from
update_fulfill_htlc was also vague: it was meant to simply note that
it's not completely reversible, since the knowledge is (and probably
should be!) used to fulfill an incoming HTLC.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-24 06:51:06 +10:30
Rusty Russell
614af24071 BOLT 2: Message retransmission and reconnect semantics.
1) Make it clear that `init` needs to be sent every time.
   - This means if you upgrade and no longer support an old connection, it's
     clear, plus it simplifies the question of re-transmission of `init`.
2) Spell out the retransmission requirements for reconnection.
   - We agreed in Milan to simply use retransmit and ignore-dups.
   - This needs actual testing by implementations, but this is my best guess
     on exactly how far back to retransmit.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-24 06:51:06 +10:30
Rusty Russell
fddc992b2d BOLT 2, BOLT 3: fee-per-kw kilo == 1000, not 1024.
I checked the bitcoin source to be sure, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-22 16:17:30 -08:00
Rusty Russell
c93bf5cf8c BOLT 4: make format of failure codes the same as normal messages.
This reduces failure codes to 2 bytes, places them into data itself.

Now we can use the same parsing code for them as we use for normal packets.

BOLT 2 is adjusted to match, and order of args changed to restore sha256
alignment to a nice 8 bytes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-16 12:37:31 -08:00
Rusty Russell
62b5eedb4a BOLT 2: allow more leniancy with forks during channel establishment. (#77)
* BOLT 2: allow more leniancy with forks during channel establishment.

Christoper points out that two nodes with aggressive minimum-depth settings
may see different blocks and the protocol requires they close the channel
since their funding_locked messages will disagree.

This can also happen when only one side has an aggressive minimum-depth
setting: if it sends funding_locked referring to a block which is orphaned,
it can't update it.

There are three changes here, two optional.
- Allow sending of an updated funding_locked.  This fixes this case where
  one side is on an orphan and uses a v. low minimum-depth.
- Require accepting of an updated funding_locked.
- Allow waiting instead of immediate failure if funding_lock disagrees.
  eg. you might wait another block or two to see if one side reorgs.

Reported-by: Christopher Jämthagen
Closes: #73
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-13 11:39:39 +10:30
Rusty Russell
467429249f BOLT 2: fix duplicate numbers.
revoke-and-ack is already 133.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-06 13:22:39 +10:30
Rusty Russell
d57b33d3c3 BOLT #2: allow different handling of update_fail_malformed_htlc if SHA wrong.
Suggested-by: Olaoluwa Osuntokun <laolu32@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-06 10:01:09 +10:30
Rusty Russell
c7cca57e32 BOLT 2: add another method of failing HTLCs.
If we get sent junk (or unknown version), we can't encrypt the
failure.  Currently that's only if the onion version is non-zero, or
the ephemeral key is malformed.

We do check the BADONION bit so the origin can tell that we're
reporting it on the next peer's behalf, in case that ever matters.

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


Header from folded patch 'fix__feedback_from_roasbeef.patch':

FIX: Feedback from roasbeef.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-06 10:01:09 +10:30
Rusty Russell
ab2c5bf3c9 BOLT 2, BOLT 4: error response is not fixed-length.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-06 10:01:09 +10:30
Rusty Russell
0c4a8ae6b8 BOLT 2, BOLT 7: rename expiry to cltv-expiry / cltv-expiry-delta.
I can't remember who suggested this, but it's a good idea!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-06 10:01:09 +10:30
pm47
2c4cd03b4c added a section about who pays the fee 2017-01-04 15:55:41 +10:30
Rusty Russell
00a8e97a68 BOLT 1: recommend full tx in error pkt if signature fails. (#65)
* BOLT 1: recommend full tx in error pkt if signature fails.

This will usually be the commitment tx, but could also be the HTLC
tx.

Reported-by: pm47 <pm.padiou@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

* FIX: Feedback

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

* BOLT 1: tighten error message `len` requirement.

Of course it has to match data length exactly.

Reported-by: pm47 <pm.padiou@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

* BOLT 1, BOLT 2, BOLT 5: commitsig -> commitment_signed.

Consistency FTW.

Reported-by: pm47 <pm.padiou@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-12-21 11:37:47 +01:00
Pierre-Marie Padiou
eebbd617bd BOLT 2: Specify ordering of htlc-timeout signatures (minor) (#59)
* specify ordering of htlc-timeout signatures
* made commitsig and revoke_and_ack requirements more consistent
2016-12-14 16:18:41 +01:00
pm47
abe0e8c3cc fixed toc inconsistency 2016-12-12 12:05:06 +01:00
Christopher Jämthagen
b0379781a4 Some minor fixes 2016-12-12 10:37:45 +10:30
Christian Decker
336717ea61 trivial: Fixing links in BOLT02. 2016-12-11 11:08:53 +10:30
Christian Decker
a868d1381d onion: Specifying payment-key commitment in onion (#47)
Specifying that the `onion-routing-packet` commits to the
`payment-key` by setting the associated data. This avoids replay
attacks and specifying it here keeps the onion-routing spec clean.
2016-12-09 17:15:44 -08:00
Christopher Jämthagen
d076039df2 Use "Bitcoin" with capital "B" where it is appropriate
pseudo random -> pseudo-random
onchain -> on-chain
2016-12-09 10:50:19 +01:00
pm47
1bb765819e moved update_fee message to 'normal operations' 2016-12-07 11:20:38 +10:30
pm47
248281738b fixed toc 2016-12-06 17:18:25 +01:00
Pierre-Marie Padiou
9bb732f991 Moved msg type description from BOLT#2 to BOLT#1 (#35)
* moved msg type description from BOLT#2 to BOLT#1
* added a ToC
2016-12-06 15:54:10 +01:00
Christopher Jämthagen
9fff656d70 Some spelling and language fixes in BOLTs 0,1,2 2016-12-06 15:30:48 +01:00
Olaoluwa Osuntokun
57235bbd50
BOLT 02: update opening channel establishment paragraph
This commit updates the opening paragraph in the channel establishment
section. The messages referenced are were from the prior iteration of
the funding messages and naming scheme. The section has been updated to
properly reference the latest messages and also to give a bit more
context to the reader to start with.
2016-12-05 12:16:35 -08:00
Rusty Russell
b228a2e77d BOLT 2: remove attempts to align signatures.
They're really a blob of bytes, and we weren't aligning them correctly in
two cases anyway.  This gets rid of gratuitous padding, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-29 12:58:13 +10:30
Rusty Russell
14e199d823 BOLT 1, BOLT 2, BOLT 5: 2-byte lengths everywhere.
Since our cryptopacket limits us to 2 bytes, and since people will
send 1-message-per-crypto-packet and nobody will test the
multiple-messages-in-one-cryptopacket code, let's just restrict to
64k messages.

1. Make cryptopacket length not include the HMAC, so we can actually send
   64k messages.
2. Remove len prefix from packet, make type 2 bytes, note alignment properties.
3. Change message internal lengths/counts from 4 to 2 bytes, since more
   is nonsensical anyway, and this removes a need to check before allocating:
    - init feature bitfield length
    - error message length
    - shutdown scriptpubkey length
    - commit_sig number of HTLC signatures
    - revoke_and_ack number of HTLC-timeout signatures
4. Change max-accepted-htlcs to two bytes, and limit it to 511 to ensure
   that commit_sig will always be under 64k.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-29 10:34:43 +10:30
Rusty Russell
d12f245b4d BOLT 2: clarify what feerate-per-kw stands for and how it's calculated.
Bitcoin still uses feerate-per-kb, which needs to be multiplied by 4
in segwit.  It's more than a little confusing.

Split the paragraphs, too, as it's a little overwhelming.

Reported-by: Olaoluwa Osuntokun <laolu32@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-28 13:18:09 +10:30
Rusty Russell
2e0b7266d1 Merge pull request #14 from lightningnetwork/extraction-tools
tools/extract-formats.py: produce structure definitions and check alignment
2016-11-28 11:34:09 +10:30
Rusty Russell
727295e6bb Merge pull request #25 from lightningnetwork/open-first-commitment-point
Adding a first-per-commitment-point field to open_channel
2016-11-25 10:44:18 +10:30
Rusty Russell
be3b72b768 BOLT 2: rename open_channel's max-num-htlcs to max-accepted-htlcs.
This is what it actually is (and how it's documented): you can't control
the total since both sides can add at the same time, you can only tell
the other side how many *it* can add, and control how many you add.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-25 10:31:47 +10:30
Pierre-Marie Padiou
a0bc945260 typo 2016-11-24 16:47:33 +01:00
Pierre-Marie Padiou
f8ad90b680 adding first-per-commitment-point to open_channel 2016-11-24 15:40:01 +01:00
Pierre-Marie Padiou
1781d28a97 fix tabs->spaces 2016-11-24 14:35:39 +01:00
Rusty Russell
0dd4583db1 Merge pull request #17 from lightningnetwork/funding-created-single-byte-outindex
BOLT 2: Only single byte for channel-index.
2016-11-24 12:42:36 +10:30
Rusty Russell
bfc392c6f9 Merge pull request #19 from lightningnetwork/fix-funding-locked-announce-sigs
BOLT 2: fix funding_locked announcement signatures.
2016-11-24 12:42:20 +10:30
Christian Decker
4dde8e6a26 Merge pull request #18 from lightningnetwork/license
Add CC-BY.
2016-11-23 15:49:46 +01:00
Rusty Russell
b742d2f73d BOLT 1, BOLT 2, BOLT 7: Remove message enums
The MSG_XXX is trivially derived from the name of the message if
people want to do that, so just change it to the actual message name.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-23 11:33:25 +10:30
Rusty Russell
2ea334a17f BOLT 2: fix funding_locked announcement signatures.
We need to supply a pair (a signature using our bitcoin key which signs the
node id, and a signature using our node key which signs the announce message),
and the length was wrong.  Move them to make alignment nicer, too (though
it probably doesn't matter, they're 4-byte aligned everywhere else).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-23 11:23:08 +10:30