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

1060 Commits

Author SHA1 Message Date
andrew.shvv
a0c4f7cfd1 BOLT 3: add more detailed commitment transaction estimation (#26)
* add more detailed estimation
* fix miscalculations
2016-11-30 06:50:05 +10:30
Rusty Russell
7c884f2af4 BOLT 01: reorganize, tighten nomenclature.
Major changes:
1. Move crypto first, then cover contents
2. Use "lightning messages" explicitly to refer to upper layer, use
   "packet" in the one case where we refer to the whole thing.
3. Collapse "Transport Message Exchange" and "Protocol Message Encapsulation"
   into "Lightning Message Specification" which already contains much overlap.

Minor changes:
1. Put the big-endian requirement in the general overview, since the crypto
   layer uses that too.
2. Say "is" instead of "should be" encrypted: it's not an option.
3. Note why we separate local and global features.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-30 06:47:32 +10:30
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
351e0deda2 Merge pull request #24 from rustyrussell/rfc-short-packets
[RFC] BOLT 1, BOLT 2, BOLT 5: 2-byte lengths everywhere.
2016-11-29 11:16:38 +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
1a1dc1e70f Merge pull request #22 from lightningnetwork/fix-fee-calc
BOLT 3: Fix fee calculation.
2016-11-28 13:17:29 +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
Olaoluwa Osuntokun
a86c9f8944
BOLT 1: clarify handshake by making components more explicit
This commit clarifies the current draft of the crypto spec in several areas by
making the steps more explicit. In addition a few errors in the prior version
of this draft have been fixed.

Thanks @EthanHeilman for pointing out several ambiguities in the prior draft of
the document.

A future commit will contain the addition of several test vectors to ensure
implementation parity.
2016-11-24 15:06:13 -06:00
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
bcb03f870f Merge pull request #16 from lightningnetwork/flags-in-routing
BOLT 7: Use a flags word, not padding.
2016-11-24 16:26:45 +10:30
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
Fabrice Drouin
de87eaa147 BOLT 3: fix witness scripts
1. Add a short paragraph on P2WSH (the witness script is omitted for brevity in all descriptions) and fix witness scripts for spending the different tx outputs.
2. use CHECK(MULTI)SIG instead of CHECK(MULTI)SIGVERIFY
3. Fix order and nulldummy for witness in HTLC transactions
4. Fix a minor typo (if -> it)

(Commits rebased and squashed together by Rusty)
2016-11-24 11:05:31 +10:30
Rusty Russell
1e7e21b5c6 BOLT 3: Fix fee calculation.
I forgot to add in the amount+scriptsize overhead for each HTLC.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-24 10:56:13 +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
4806e273ee BOLT 7: Use a flags word, not padding.
This lets us gain 7 more bits, but also as Christian points out, you need
to remember the padding for re-broadcast since the signature covers it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-23 14:26:31 +10:30
Rusty Russell
b928505386 BOLT 7: Use channel-id as per BOLT 2, instead of open-coding components.
This also makes it obvious they're the same as in BOLT 2.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-23 14:13:02 +10:30
Ethan Heilman
1ed7469d03 BOLT 1: fix a few typos 2016-11-22 20:50:27 -06:00
Rusty Russell
fab307b57d tools/extract-formats.py: extract message definitions and check alignment.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-23 11:54:14 +10:30
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
fa448bd21e BOLT 1: clean up message formatting to match other fields.
Make the parser's life trivial.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-23 11:24:08 +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
Rusty Russell
865cf82e65 BOLT 07: Signatures should be at beginning.
This means they cover future fields as well (which may or may not be good!)
but also ensures they're naturally aligned in case anyone cares.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-23 10:44:25 +10:30
Rusty Russell
5f5f87d124 Merge pull request #10 from lightningnetwork/feerate
BOLT 02/03: Add fee calculation details.
2016-11-23 06:27:50 +10:30
Rusty Russell
193bbef972 Add CC-BY.
Closes: #2
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-23 06:22:59 +10:30
Rusty Russell
1a132d4fab BOLT 2: Only single byte for channel-index.
And make it channel-index not channel_index to match the others (markdown
doesn't treat - specially, unlike _).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-23 06:07:08 +10:30
Rusty Russell
f333f46216 Merge pull request #15 from sstone/fixscripts
'to-local output': add revocation key
2016-11-23 05:53:12 +10:30
Fabrice Drouin
f51f5c8690 'to-local output': add revocation key
The 'to local' output in the commit tx should be spendable without delay if you know the revocation key.
2016-11-22 15:33:07 +01:00
BitfuryLightning
25db6434fc Merge pull request #11 from rustyrussell/more-complex-gossip
BOLT #7: More complex proposal, using three separate message types.
2016-11-22 14:59:52 +02:00
Rusty Russell
9137aed167 BOLT #2: fill in descriptions and requirements for remaining fields. 2016-11-22 13:20:46 +10:30
Rusty Russell
e96412af52 FIX! Clarifications and typo fixes due to Pierre.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-22 12:24:10 +10:30
Rusty Russell
5e40cf2455 Merge pull request #12 from pm47/patch-1
minor: close_signature -> closing_signed
2016-11-22 11:27:29 +10:30
Pierre-Marie Padiou
7bf986da23 close_signature -> closing_signed 2016-11-21 11:45:49 +01:00
Rusty Russell
2e93a4184e BOLT #7: More complex proposal, using three separate message types.
Contents stolen from Christian's draft.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-21 16:18:12 +10:30
Rusty Russell
bf80e07df0 BOLT 02/03: Add fee calculation details.
Make the fee amount by kiloweight, not by kilobyte, and spell out how
to calculate it.  Note that we have to trim HTLCs outputs whose second-stage
would also fall below dust limit, and we also make some reasonable
approximations on transaction size (which is unknowable before signatures
anyway).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-21 13:43:42 +10:30
Rusty Russell
a15f3f9ca3 BOLT #2: delete duplicate sentence.
It's already in the next paragraph.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-21 11:32:20 +10:30
Rusty Russell
60d91f2758 MSG_REVOCATION -> MSG_REVOKE_AND_ACK.
The fact that a revocation response also serves to acknowledge the
pending changes (and thus indicate the sender should apply them
to itself) is documented in the desciption, but still terribly
subtle.  Joseph suggested making it clearer, I think this
does that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-21 10:34:43 +10:30
Rusty Russell
77afd570af BOLT #3: re-add XORing to obscure the commitment index.
I missed this somehow from the spec.

Reported-by: Olaoluwa Osuntokun <laolu32@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-19 10:39:30 +10:30
Rusty Russell
57b457ebd7 Merge pull request #8 from rustyrussell/fix-derivation
BOLT 2/3: watcher-compatible key derivation.

Nobody complained!
2016-11-19 10:31:40 +10:30
Pierre-Marie Padiou
db9ad2e63d BOLT #2: Add TOC
(Rebased by Rusty Russell <rusty@rustcorp.com.au>)
2016-11-18 14:02:32 +10:30
Pierre-Marie Padiou
e81ffb304c BOLT #2: Rename fee-per-kilobyte to feerate-per-kilobyte for clarity.
(Rebased by Rusty Russell <rusty@rustcorp.com.au>)
2016-11-18 14:02:21 +10:30
Pierre-Marie Padiou
18824a803a BOLT #2: Fix indent levels
(Rebased by Rusty Russell <rusty@rustcorp.com.au>)
2016-11-18 14:02:09 +10:30
Rusty Russell
32779962b5 BOLT 2/3: watcher-compatible key derivation.
After much discussion with Tadge and Laolu, I think we have something
which is nicely outsourcable, and yetnot insanely complex.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-17 14:33:22 +10:30
Olaoluwa Osuntokun
17060cbf9d BOLT 3: use code block for multi-sig script
This commit modifies BOLT 3 slightly to use a code block for the multi-sig script. Without this change, the script doesn't display correctly, as the angle brackets are interpreted as markdown syntax.
2016-11-16 17:13:48 -08:00
Pierre-Marie Padiou
fc9975f529 minor: updated open channel diagram 2016-11-16 16:24:50 -08:00