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

128 Commits

Author SHA1 Message Date
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