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

279 Commits

Author SHA1 Message Date
Hiroki Gondo
c423308886 BOLT 0,2,5: closing transaction not (mutual) close transaction.
Be consistent.
2019-01-07 20:17:45 +01:00
Hiroki Gondo
7f68780c20 BOLT 2: delete unnecessary space. 2019-01-07 20:17:31 +01:00
Hiroki Gondo
353721b65e BOLT 2: update not HTLC in Normal Operation.
In the description here, the target is not only `HTLC`
but also general `update`.
2019-01-07 20:17:31 +01:00
Rusty Russell
a07dc3df3b BOLT 2: add missing spellcheck words, change 'funding txo' to 'funding output'.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 02:46:07 +00:00
Matt Corallo
fa52e74eac Clarify temporary_channel_id's acceptable usages 2018-12-10 02:46:07 +00:00
Rusty Russell
20524d4109
BOLT 2: advise ping-before-commitment_signed on quiescent connections. (#508)
This seems to be a cause of stuck HTLCs on the network: c-lightning has
done this for a while now (since 0.6.1).

[ Minor wording clarification merged --RR ]
Decided-at: Adelaide Summit 2018
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-11-29 04:32:11 +00:00
Hiroki Gondo
ae8c78c8a8 BOLT 2: Hashed Time Locked Contracts not Hash TimeLocked Contracts.
Be consistent.
ref. 00-introduction.md#glossary-and-terminology-guide
2018-11-29 04:24:47 +00:00
lisa neigut
a307f3b282 peer-protocol: periods make meaning clearer. sometimes. 2018-11-29 04:12:06 +00:00
lisa neigut
d923df5e43 peer-protocol: fixup punctuation to clarify meaning
The punctuation in this case made it hard to understand.
2018-11-29 04:12:06 +00:00
lisa neigut
9b5c3df9ce peer-protocol: explain what a commitment number is, in situ
Although commitment numbers are explained in the
[glossary](00-introduction.md#glossary-and-terminology-guide),
it's helpful to re-iterate at the place that it's first used.
2018-11-29 04:12:06 +00:00
lisa neigut
1bbcd5552b peer-protocol: fix tense use -> used 2018-11-29 04:12:06 +00:00
lisa neigut
c572c1c42a peer-protocol: add missing word
Missing `to`
2018-11-29 04:12:06 +00:00
lisa neigut
0087a64244 peer-protocol: Add link to channel failure in 05
To 'fail a channel' is mentioned multiple places in this
BOLT without any mention or definition of what that means.

This adds a link to the relevant text in BOLT 05 in the
first place that we mention 'fail the channel'.
2018-11-29 04:12:06 +00:00
lisa neigut
2f72c225ea peer-protocol: Add short note about channel_id
Clarify association between temp_id and channel_id, and make
explicit why we have to wait for the funding transaction.
2018-11-29 04:12:06 +00:00
lisa neigut
05a4d18c1e peer-protocol: Add links to referenced BOLTs
Add links to make it clearer that these two actions:
'authentication' and 'initialization' are specified elsewhere.
2018-11-29 04:12:06 +00:00
lisa neigut
5727c3dff0 peer-protocol: Add chan_reestablish message name to TOC
Make it easier to tell at a glance what messages this BOLT
concerns.
2018-11-29 04:12:06 +00:00
ZmnSCPxj, ZmnSCPxj jxPCSmnZ
65753ff6fb 02-peer-protocol.md: Minor typo. (#505) 2018-11-12 16:47:57 +01:00
ueno
1ddc1a54d7 BOLT2: both nodes send update_add_htlc
issue #472
2018-10-29 00:07:56 +00:00
ueno
3f2c747955 fix typos 2018-08-07 00:07:42 +00:00
Rusty Russell
4b62d26af9 BOLT 2: fix placement of chain_hash requirement.
Reported-by: Matthias Grundmann @mattias-g
Fixes: #453
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-26 03:11:01 +00:00
Rusty Russell
42a2963a3d BOLT 2: use cross-reference to BOLT3 when we refer to to_local and to_remote
Closes: #421
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-05-24 04:25:13 +00:00
yuntai
f159d3f5a6 Fix typo 2018-05-14 19:48:20 +00:00
Carsten Otto
c2ced54fa6 BOLT2: Rephrase channel establishment introduction
A channel may be established, but this is not mandatory. Furthermore, the connection initialization has to happen first.
2018-04-30 20:40:26 +00:00
Rusty Russell
a7e109a286 BOLT 2: dust limit is lower limit for non-dust.
So we need to be >= it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-04-16 23:26:34 +02:00
Rusty Russell
a676ae6a0b YA typo fix
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-04-16 23:26:34 +02:00
Rusty Russell
07ec50602d typo fix
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-04-16 23:26:34 +02:00
Rusty Russell
f5b28a9a24 BOLT 2: set lower limit on funds available on channel open.
Even with push_msat, we need to make sure that funder can pay the fees,
so require that.

Also require that there be some funds above reserve on one side, otherwise
the channel is useless, and we risk that all outputs are dust.

Note: a side *may* reject the channel if funding_satoshis is too small
already, but this sets a clear minimum bar.

Fixes: #393
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-04-16 23:26:34 +02:00
Rusty Russell
fbaa6f5287 Complete requirements.
Add requirements on accept_channel, so each side doesn't consider the
*other* reserve dust either.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-04-16 23:26:34 +02:00
Rusty Russell
a0214d3722 Fix missing set typo. 2018-04-16 23:26:34 +02:00
Rusty Russell
c256c4626b BOLT 2: avoid obvious all-dust cases
After more consideration, I believe that this is sufficient to ensure
one reserve is always non-dust.

The races which make us dig into the reserves can't currently take from
the fundee's reserve, so either the fundee has sufficient reserves, or
it can't add HTLCs which means no race.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-04-16 23:26:34 +02:00
Janus
9d48f3e52f correct feature flagged message fields syntax, update structured.py to support feature flagged fields, print to right output in extract-formats.py 2018-04-11 07:08:18 +00:00
Pierre-Marie Padiou
8f36ee9880
BOLT 2: typo "it need" -> "it needs" (#391) 2018-03-20 13:37:34 +01:00
pm47
2cb41db4a2 consistency: option-data-loss-protect->option_data_loss_protect 2018-03-05 19:20:37 +00:00
pm47
7da77f0687 define initial value for data-loss fields
Clarify that field `channel_reestablish`.`your_last_per_commitment_secret`
should be set to an all-zero array when no `per_commitment_secret` has
been received yet.
2018-03-05 19:20:37 +00:00
Rusty Russell
4c8cb512d0 BOLT 2,3,5: always refer to shared/pubkey/private key.
Make it clear what kind of key we're talking about.  We use the abbreviation
pubkey for public key (as it's quite common to use in field names), but
generally spell out 'private'.

(I generally prefer 'secret' to 'private' but we use private far more often
already, and we use 'secret' for things which don't directly derive keys).

Fixes: #368
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-20 01:10:38 +00:00
Christian Decker
3e2d275471 BOLT02: Add rationale for 2^24 satoshi per channel limit
Fixes #353
2018-02-09 14:50:52 +01:00
Rusty Russell
120003e553 BOLT #2: bad update_fee after shutdown when all HTLCs cleared.
I got an unexpected update_fee message after `shutdown` exchange,
which is currently legal:

A: shutdown (no htlcs)
                          B: receive shutdown
                          B: reply with shutdown & closing_signed

A: send update_fee & commitment_signed
A: receive shutdown

Simplest to ban any updates (currently, just update_fee) from adding a
new commitment tx while we're at the end of shutdown.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-05 23:47:12 +00:00
Rusty Russell
90241d9cf6 BOLT 2: order closing-signed negotiation by making funder send first.
Fixes: #365
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-05 23:38:51 +00:00
practicalswift
4e3074ea5f Fix markdownlint warnings
Fixed warnings:

.copy-edit-stylesheet-checklist.md: 49: MD030/list-marker-space Spaces after list markers [Expected: 1; Actual: 0]
.copy-edit-stylesheet-checklist.md: 1: MD041/first-line-h1 First line in file should be a top level header [Context: "Basic checklist/stylesheet use..."]
02-peer-protocol.md: 161: MD018/no-missing-space-atx No space after hash on atx style header [Context: "#7](07-routing-gossip.md#bolt-..."]
2018-02-05 09:01:00 +00:00
practicalswift
2c3466a2af Remove trailing whitespace 2018-01-30 04:54:31 +00:00
Pierre-Marie Padiou
46c454cb56 clarify that nodes may support early mutual close 2018-01-22 20:14:38 +01:00
MeshCollider
4b5379b2ac Fix formatting of BOLT links 2018-01-22 14:02:01 +01:00
Rusty Russell
7ab1665b2a BOLT 2: clarify that feerate is in *satoshi* per ksipa.
We don't actually say that!

Closes: #336
Reported-by: Matt Corallo
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-01-09 03:06:29 +00:00
practicalswift
d5b5284b3b Use Markdown numbered list syntax ("1." instead of "1)") 2018-01-08 02:30:34 +00:00
Landon Mutch
641c6ab7b1 stylesheet update and apply to BOLT 2,3 2017-12-21 04:08:33 +00:00
Pierre-Marie Padiou
4e5ec11c4e add a check on counterparty's dust_limit value
Usually the counterparty would only hurt itself if it chooses too low a `dust_limit`, but in the specific scenario of a data loss, we want the counterparty's commitment tx to be relayed and confirmed on the network.
2017-12-11 23:01:34 +00:00
Landon Mutch
5db55df16a BOLT 1,2,3: apply updated stylesheet guidelines for list capitalization, punctuation 2017-12-07 02:36:10 +00:00
Rusty Russell
add074bd2a Typo fixes as suggested by Landon Mutch.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-04 05:41:03 +00:00
Rusty Russell
31f6f1e53a fixup! minor indentation
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-04 05:41:03 +00:00
Shannon Appelcline
8b7873631f Updates for comments on pull. 2017-12-04 05:41:03 +00:00
Shannon Appelcline
0d8a1a20c4 BOLT-2 Edit
Some slightly larger scale revisions for BOLT-2, notably including a reorganization of the "open_channel" function with the introduction of two missing arguments.

Also, the addition of MSAT to the glossary in BOLT-0.
2017-12-04 05:41:03 +00:00
Rusty Russell
ce4b0f1c9e BOLT 2: which->that
Reported-by: Shannon Appelcline
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-28 23:11:55 +00:00
Landon Mutch
7a8a5d88dd BOLT 2,3: fix changes requested 2017-11-28 23:11:55 +00:00
Landon Mutch
124626e693 BOLT 2: update stylesheet for numbers and amounts; 2017-11-28 23:11:55 +00:00
Landon Mutch
f23e3dd56b BOLT 1,2,3: first pass copy-edit;
BOLT 1,2: minor header spacing fixes
BOLT 3: first pass copy edit, according to capitalization, formatting stylesheet guidelines;
2017-11-28 23:11:55 +00:00
Landon Mutch
c00df17214 BOLT 0,2: update stylesheet, apply associated changes, 2nd pass copy-edit
BOLT 0: Update style sheet to reflect correct Bitcoin capitalizations
BOLT 2: Complete second pass copy-edit according to stylesheet guidelines
2017-11-28 23:11:55 +00:00
Rusty Russell
963b103113 BOLT 2: add precommitment to scriptpubkey for mutual close.
This is Fabrice's #243 "BOLT2, BOLT3: reduce attack surface", split
out with minor polishing:

- Made it an optional feature (we can insist on it if we choose even bit).
- Rename from "final_scriptpubkey" to "shutdown_scriptpubkey".
- Make requirements the same as shutdown's scriptpubkey, or zero-len.
- Leave shutdown's scriptpubkey, just make sure it's the same or fail.
- Add to accept_channel as well as open_channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-28 00:09:57 +00:00
Rusty Russell
072a69fe77 BOLT 2: require that undefined bits in open_channel must be set to 0.
We already say that receiver has to ignore them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-27 23:40:02 +00:00
Rusty Russell
3975a54a1c BOLT 2: note requirements for first_per_commitment_point.
Steal language from next_per_commitment_point requirements.

Closes: #277
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-27 23:40:02 +00:00
Rusty Russell
cb78c50b77 BOLT 2: fix terminal node ctlv_expiry calc.
It *is* 2R+G+S, which is 7, not six.  It's also identical to the previous one,
so just say that.

Reported-by: Shannon Appelcline <shannona@skotos.net>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-27 23:39:39 +00:00
landonmutch
04301add81
Merge branch 'master' into master 2017-11-15 03:33:36 -08:00
Landon Mutch
c89a54a7da BOLT 0,1,2: fix requested changes;
update stylesheet to reflect appropriate structure of Requirement sub-items and format of digits, numerations, and quantities;
copy edit BOLTs 0,1,2 to adhere to these changes;
2017-11-15 02:55:16 -08:00
Rusty Russell
4f91f0bb2a htlckey: new basepoint avoid holding the payment secret.
This is stolen from @sstone's #243 "reduce attack surface".

This breaks compatibility, as agreed at the 2017-11-13 meeting.
Note also that it does not update the test vectors.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-14 22:58:11 +00:00
Landon Mutch
24896d847d make spellcheck.sh happy 2017-11-13 19:18:09 -08:00
Landon Mutch
d99a410d5c BOLT 2: copy edit merged changes 2017-11-13 18:32:13 -08:00
landonmutch
3d67c79235
Merge branch 'master' into master 2017-11-13 17:48:03 -08:00
Rusty Russell
046f5acb16 BOLT 2: option-data-loss: limited data loss protection.
This is the best I could come up with.  You can't know future
revocation secrets, so if you send onw I know you're ahead of me
somehow.  That means I *MUST NOT* broadcast my latest commitment
transaction, but at least if you're not malicious I'll salvage
something.

We adapt BOLT 5 in a fairly trivial way to specify to say you should
try to handle as much as you can (in fact, you should always be able
to collect their commitment transaction's direct-to-you output).

Fixes: #209
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-13 11:10:32 -08:00
Landon Mutch
adb13bf689 BOLT 2: first pass copy edit done;
complete first pass copy edit, following .copy-edit-stylesheed-checklist guidelines;
2017-11-10 22:18:53 -08:00
Landon Mutch
03197f2959 BOLT 1, 2: copy edit
BOLT 1: minor list formatting fix;
BOLT 2: copy edit up to line 955;
2017-11-10 18:14:27 -08:00
Landon Mutch
b475639f48 BOLT 0, 1, 2: copy edit
add stylesheet item: prefer typed, not written numbers;
updated BOLT 0, 1 to reflect change;
copy edit BOLT 2 up to line 674;
2017-11-10 14:05:21 -08:00
Landon Mutch
1afc143cd1 BOLT 2: first pass copy edit continued;
Done first pass copy edit, up to line 576 of BOLT 2, according to .copy-edit-stylesheet-checklist.md guidelines;
2017-11-10 11:45:51 -08:00
Landon Mutch
93afa0db9a BOLT 2: first pass copy edit;
Done first pass copy edit, up to line 279 of BOLT 2, according to .copy-edit-stylesheet-checklist.md guidelines;
2017-11-10 00:56:38 -08:00
Rusty Russell
c93cd75d88
BOLT 2,4: allow an error for HTLCs which expire too far away. (#265)
Fixes: #261

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-10-31 00:21:58 +00:00
Rusty Russell
58d4d9bca3 BOLT 2: Details of HTLC Timeouts, ie. cltv_expiry_delta.
Complete rewrite, including a routing example and the new
min_final_cltv expirt.  I hope this makes it clear.

(Thanks to everyone who reviewed and gave feedback; you rock!)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-10-19 12:44:53 -07:00
Pierre-Marie Padiou
465a4cddaf Only cross-signed htlcs can be fulfilled/failed 2017-10-03 11:30:10 +10:30
Jim Posen
9073a5f3de multi: Fix a few typos and grammatical errors. 2017-09-25 12:34:30 +09:30
Rusty Russell
4bcf9dde7e BOLT 2: clarify HTLC handling, esp w/ on-chain.
1. We say you can't fail an HTLC until it's removed outgoing; make it clear
   that this could also be on-chain.
2. Insist that you fail an expired HTLC (we never actually said this!)
3. You MUST fulfill an incoming HTLC for which the output was fulfilled
   (otherwise you'll lose money), and of course, even if fulfilled on-chain.

Add an explanation paragraph to BOLT 5 as well, where it discusses on-chain
HTLC output cases (though the requirements about what to do about incoming
HTLCs is actually in BOLT 2).

[ Extra wording clarification thanks to roasbeef ]
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-22 09:59:47 +09:30
Olaoluwa Osuntokun
25fc33bfbb glossary: move definition of chain_hash to BOLT #0
This commit modifies the glossary to add a new entry which defines the
usage of `chain_hash` throughout the remainder of the documents.
Additionally, we now also specify which chain hash we expect for
Bitcoin within the glossary.

This commit also modifies BOLT #2 and #7 to omit the definition of the
expected `chain_hash` value for Bitcoin.
2017-08-08 10:06:21 +09:30
Rusty Russell
094a86ecdb BOLT 2: rework and specify exact shutdown retransmission semantics.
1. Change descriptions of closing tx construction to references to BOLT 3.
2. Recipient *should* check the fee offer has improved in closing_signed.
3. Therefore, sender *must* improve closing offer.
4. Offers do not persist across reconnection, so no state req'd, and
   also helps if fee has changed.
5. You don't need to re-send `shutdown` if you received `closing_signed`
   (implicit acknowledgement).
6. You don't have to accept a `channel_reestablish` which requests the last
   revoke_and_ack be retransmitted if you've already received `closing_signed`
   (which is an implicit acknowledgement).

Closes: #201
Closes: #199
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-08 10:05:18 +09:30
Rusty Russell
b574c18f24 BOLT 2: closing fee is based on final commitment "base fee" not actual fee.
The actual fee of the final tx may include eliminated outputs, which can
differ between one side and the other (since they have different thresholds).

Simplify this corner case by using our base fee calculation as the upper bound;
it should be close enough we don't care, but disagreement here could cause
negotiation breakdown.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-11 10:40:30 +09:30
Rusty Russell
83aaaedcd5 BOLT 2: make it clear that we set fee, *then* eliminate outputs.
You can't eliminate an output and also guarantee a certain fee, so
we need to define exactly how to do this.

Since the output is (presumably) dust, we might as well just discard it
(effectively increasing the fee).  This avoids the peer directly benefiting
from the elimination as well.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-11 10:40:30 +09:30
Rusty Russell
ac8b830598 BOLT 2: channel_reestablish message, retransmission simplification.
This adds a message for each channel reconnect (after we've
sent/received `funding_signed`, ie. when we rememeber the channel),
which says exactly how many `commitment_signed` and `revoke_and_ack`
we've received.  Really, we could use one bit for each (they could
only be missing the last one), but better to be clear.

This leaves the "rollback if didn't get commitment_signed"
requirement, but avoids any need to handle update duplicates or wonder
what update number a `commitment_signed` applies to after reconnect.

Many thanks to pm47 and roasbeef especially for constructive feedback
which made this far better than I originally had.

Closes: #172
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-06-28 06:46:26 +09:30
Rusty Russell
8424535e1f BOLT 2: don't insist we atomically send and commit to disk.
We can't do that, so allow "write, then send".  That fails on the side of
timing out, rather than having a channel which can't be used.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-06-28 06:46:26 +09:30
Olaoluwa Osuntokun
667ca1fdd6 BOLT 2: allow peers to conditionally signal channel announcement in open_channel
This commit gives peers the ability to signal their intent to make a
channel private in the `open_channel` message. This differs from the
current method as now peers are able to create multiple channels with
heterogeneous announcement policies _without_ disconnecting and
re-connecting in-between each channel funding. The prior requirement
for the nodes to re-connect was burdensome and unnecessary.

[ Minor tweaks from feedback folded in -- RR ]
2017-05-27 10:30:42 +09:30
Olaoluwa Osuntokun
38601f6edb BOLT 2: link to BOLT 7 when referring announcement_signature msg
This commit modifies the “Normal Operation” summarization by including
a link to BOLT #7 when mentioning the `announcement_signature` message.
Previously a reader would need to search other documents to figure out
what an `announcement_signature` was, and its purpose.
2017-05-27 10:30:42 +09:30
Rusty Russell
068b0bccf9 BOLT 2,4,7: use 8 bytes for amounts, restrict add_htlc for bitcoin only. (#175)
We had 4 byte fields for amounts because people have no ability to assess
risk, and this limited the damage to $70 at a time.

But then that means $1 maximum HTLCs on Litecoin, which isn't enough
for a cup of (decent) coffee.

Rather than have boutique hacks for Litecoin we enlarge the fields now,
and simply have a bitcoin-specific restriction that the upper 4 bytes be 0.

The ctlv_expiry field is moved down in update_add_htlc, to preserve alignment.

Suggested-by: Olaoluwa Osuntokun <laolu32@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-23 12:36:34 +09:30
EmelyanenkoK
032d55832d Delete obsolete reference to padding 2017-05-19 10:44:24 +09:30
Rusty Russell
5801656c6d BOLT 2: make opening retransmissions atomic and better specified.
1. Tell the node when to broadcast the funding tx (we didn't do this!).
2. Allow timeouts generally if no progress is made (originally this
   was just when waiting for funding_locked, but it applies generally).
3. Use `funding_signed` as the commitment point: before this, we forget,
   after this, we remember.  If lost, we'll timeout.
4. The core of the retransmission requirements now only applies to
   the normal and shutdown states, and will be revised separately
   depending on #172

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-18 09:49:19 +09:30
Rusty Russell
41790a9cd7 BOLT 2: add suggestion to retransmit errors, and rationale section.
Moves it together with the similarly-reasoned `closing_signed`
retransmission.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-18 09:49:19 +09:30
Olaoluwa Osuntokun
3a359c8e1e BOLT 2: correct sat/Kb to sat/Kw conversion to avoid over paying (#176)
This commit fixes an advisory error in the current spec draft. We
currently use `fee-per-kw` where `kw = 1000` weight to determine the
proper fee to pay for commitment transactions. Currently, the spec
advises implementer to take the typical sat/Kb at _multiply_ by 4. This
will result in implementations overpaying for commitment transactions
as the scaling should actually be in the _opposite_ direction. As the
weight is scaled up by 4, for fee-per-kw should be scaled down by 4.
So: sat/Kb * 1/4, instead of sat/Kb * 4.

[Minor fixup: "1/4th" to "1/4", better english, and doesn't trip spellcheck. -- RR]
2017-05-18 09:48:29 +09:30
Rusty Russell
f0da3978e9 Underscores for all terms, not just fields.
Plus a few more missing ones, and some consistency fixes in names
as pointed out by Roasbeed and Fabrice.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-15 12:54:53 -07:00
Rusty Russell
43b0b1c284 BOLT 2: sha256-of-onion -> sha256_of_onion in descriptions.
Missed this replacement.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-15 12:54:53 -07:00
Rusty Russell
44fe02edbf BOLT 2: underscores and backticks everywhere.
Many old fieldnames fixed up:
1. funding_amount -> funding_satoshis
2. max_htlc_value_in_flight -> max_htlc_value_in_flight_msat
3. update_commit -> commitment_signed
4. route -> onion_routing_packet

Typo fixes:
1. fee_rate -> feerate_per_kw
2. amount_sat -> amount_msat
3. script_pubkey -> scriptpubkey

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-11 11:20:36 +09:30
ZmnSCPxj
77c9272ed6 02-peer-protocol.md: Minor typo: update_htlc_add, verb should come first 2017-05-09 16:27:36 +09:30
Rusty Russell
8bc2304705 BOLT 2: remove requirement for missing field.
minimum-depth is no longer in the opening message.

Closes: #157
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-09 16:26:52 +09:30
EmelyanenkoK
85f4365c47 Fix typo
max-htlc-value-in-flight-msat had two different designations
2017-05-03 13:10:27 +09:30
Rusty Russell
c3b078bad2 BOLT 2: typo fixes.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-03 13:08:07 +09:30
Rusty Russell
8b29062f78 BOLT 4: Simplify onion format.
1. Only one per-hop thing, called `per-hop`, or `hops_data` when in aggregate.
2. Move HMAC to the end of stuff it covers, both of the packet itself, and the per-hop.
3. Use `channel-id` instead of RIPEMD(nodepubkey).
4. Use 4 byte amounts.
5. This is all for realm "0", we can have future realms.  We also have 16
   bytes of unused padding.
6. No longer need the `gamma` key, but document the `_um_` key used for
   errors.
7. Use normal 32-byte HMAC, not truncated 20-bytes, which more than eats
   up the room we saved.

The result is that the onion is now 1366 not 1254 bytes, but simpler.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-26 09:59:30 +09:30
Rusty Russell
809ad65ea0 BOLT 2: fix dangling sentence.
`channel-id` which identifies , which is derived
=>
	`channel-id` to identify the channel, which is derived

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-08 08:17:20 +09:30
Rusty Russell
9d29e98eec BOLT 2: htlc-cltv must be in blocks.
ie. < 500 million.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-30 12:04:20 +10:30
Rusty Russell
a39b236e80 BOLT 2: require that we don't fulfill close to timeout either.
It was never mentioned, but fulfilling a timedout HTLC means a race
between timing out and fulfilling, which is bad.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-24 12:10:24 +10:30
Olaoluwa Osuntokun
9e0a0e893d BOLT 02: add a chain-hash field to the open_channel msg (#135)
This commit adds a `chain-hash` field to message that commences a
funding workflow. This field is used to specify a _target_ chain for the
proposed channel. In order to uniquely identity blockchains in a manner
that doesn't require strict coordination between developers, the genesis
hash of the target chain is used. For channels opened on the Bitcoin
blockchain, the `chain-hash` field should _always_ be set to:
000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f.

Introducing this new field _immediately_ allows nodes within the network
to open a channel within any Satoshi-derived blockchain. Nodes can have
channels open across different blockchains globally, but also have many
channels open across distinct blockchains with the same peer.
2017-03-24 12:09:41 +10:30
Clark
351ea92a6b Fix typo
Instead of "ensure the blockchain," it should be "enter the blockchain"
2017-03-22 20:08:04 +01:00
Rusty Russell
41f400a378 BOLT 2: simplify shutdown constraints.
As per discussion in #115, we now allow `shutdown` immediately following
`commitment_signed`.

This means that revoke-and-ack doesn't *always* ack the shutdown.  Rather
than specify that a revoke-and-ack which is caused by an update-commit
following the shutdown acknowledges, we leave this unacknowledged until
we actually start closing.

This means we will retransmit it on every reconnect until then.  But
that's not all that wasteful, and fairly robust.

Suggested-by: Pierre-Marie Padiou <pm.padiou@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-22 11:38:04 +10:30
Rusty Russell
b18322e06e BOLT 2: change dust limit for closing to each use their own.
Using the receiver's dust limit implies a naive node can be fooled
(by a peer with massive dust limit) into not getting its own output.

Using our own opens the possibility of creating different transactions,
so we explicitly allow the tractable case, while accepting failure on
the case where disagreement is real.

Closes: #128
Reported-by: Pierre-Marie Padiou
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-22 11:37:39 +10:30
Rusty Russell
9a572ff0a3 BOLT 2: fix remaining commit_sig references.
Left over from 00a8e97a68, which purported
to change commit_sig -> commitment_signed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-21 10:28:18 +01:00
Pierre-Marie Padiou
373de09154 revoke_and_ack is acknowledged by closing_signed 2017-03-10 09:58:13 +10:30
Rusty Russell
0d7cf77970 BOLT 2: reduce HTLC maximum limit based on new penalty calculations.
We can no longer allow 511 each way; reduce it to match our calculations
so we can always create a single standard penalty transaction.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-08 05:50:44 +10:30
pm47
557db43378 make htlc outputs of the commitment tx spendable with revocation key
(Merge conflict in test vectors fixed by selecting Pierre's, will have to
 be re-evaluated).

Closes: #105
2017-03-07 09:21:40 +10:30
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