Skip to content

Commit

Permalink
BOLT: Update text to latest commit.
Browse files Browse the repository at this point in the history
This brings us up to 955e874 in
https://github.com/lightningnetwork/lightning-rfc

This doesn't actually change anything; the only actual change is held back
for the next commit.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Aug 22, 2017
1 parent 1ffb9f0 commit fea412d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 29 deletions.
8 changes: 5 additions & 3 deletions lightningd/channel/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ static void peer_reconnect(struct peer *peer)
/* BOLT #2:
*
* If `next_remote_revocation_number` is equal to the commitment
* number of the last `revoke_and_ack` the receiving node has sent, it
* number of the last `revoke_and_ack` the receiving node has sent and the receiving node has not already received a `closing_signed`, it
* MUST re-send the `revoke_and_ack`, otherwise if
* `next_remote_revocation_number` is not equal to one greater than
* the commitment number of the last `revoke_and_ack` the receiving
Expand Down Expand Up @@ -1614,9 +1614,11 @@ static void peer_reconnect(struct peer *peer)

/* BOLT #2:
*
* On reconnection if the node has sent a previous `shutdown` it MUST
* retransmit it
* On reconnection if the node has sent a previous `closing_signed` it
* MUST send another `closing_signed`, otherwise if the node has sent
* a previous `shutdown` it MUST retransmit it.
*/
/* If we had sent `closing_signed`, we'd be in closingd. */
maybe_send_shutdown(peer);

/* Corner case: we didn't send shutdown before because update_add_htlc
Expand Down
46 changes: 27 additions & 19 deletions lightningd/closing/closing.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static void do_reconnect(struct crypto_state *cs,
/* BOLT #2:
*
* On reconnection if the node has sent a previous `closing_signed` it
* MUST then retransmit the last `closing_signed`
* MUST send another `closing_signed`
*/

/* Since we always transmit closing_signed immediately, if
Expand Down Expand Up @@ -218,10 +218,12 @@ int main(int argc, char *argv[])
* Nodes SHOULD send a `closing_signed` message after `shutdown` has
* been received and no HTLCs remain in either commitment transaction.
*/

/* BOLT #2:
*
* On reconnection, ... if the node has sent a previous
* `closing_signed` it MUST then retransmit the last `closing_signed`.
* `closing_signed` it MUST send another `closing_signed`, otherwise
* if the node has sent a previous `shutdown` it MUST retransmit it.
*/
for (;;) {
const tal_t *tmpctx = tal_tmpctx(ctx);
Expand All @@ -231,22 +233,21 @@ int main(int argc, char *argv[])
/* BOLT #2:
*
* The sender MUST set `signature` to the Bitcoin signature of
* the close transaction with the node responsible for paying
* the bitcoin fee paying `fee_satoshis`, then removing any
* output which is below its own `dust_limit_satoshis`. The
* sender MAY then also eliminate its own output from the
* mutual close transaction.
* the close transaction as specified in [BOLT
* #3](03-transactions.md#closing-transaction).
*/
tx = close_tx(tmpctx, scriptpubkey,
&funding_txid,
funding_txout,
funding_satoshi,
satoshi_out, funder, sent_fee, our_dust_limit);

/* BOLT #2:
/* BOLT #3:
*
* The sender MAY then also eliminate its own output from the
* mutual close transaction.
* ## Closing Transaction
*...
* Each node offering a signature... MAY also eliminate its
* own output.
*/
/* (We don't do this). */
sign_tx_input(tx, 0, NULL, funding_wscript,
Expand Down Expand Up @@ -310,11 +311,10 @@ int main(int argc, char *argv[])

/* BOLT #2:
*
* The receiver MUST check `signature` is valid for either the
* close transaction with the given `fee_satoshis` as detailed
* above and its own `dust_limit_satoshis` OR that same
* transaction with the sender's output eliminated, and MUST
* fail the connection if it is not.
* The receiver MUST check `signature` is valid for either
* variant of close transaction specified in [BOLT
* #3](03-transactions.md#closing-transaction), and MUST fail
* the connection if it is not.
*/
tx = close_tx(tmpctx, scriptpubkey,
&funding_txid,
Expand All @@ -334,6 +334,14 @@ int main(int argc, char *argv[])
trimming_satoshi_out[REMOTE] = 0;
trimming_satoshi_out[LOCAL] = satoshi_out[LOCAL];

/* BOLT #3:
*
* Each node offering a signature MUST subtract the
* fee given by `fee_satoshis` from the output to the
* funder; it MUST then remove any output below its
* own `dust_limit_satoshis`, and MAY also eliminate
* its own output.
*/
trimmed = close_tx(tmpctx, scriptpubkey,
&funding_txid,
funding_txout,
Expand Down Expand Up @@ -392,9 +400,9 @@ int main(int argc, char *argv[])

/* BOLT #2:
*
* Once a node has sent or received a `closing_signed` with
* matching `fee_satoshis` it SHOULD close the connection and
* SHOULD sign and broadcast the final closing transaction.
* If `fee_satoshis` is equal to its previously sent
* `fee_satoshis`, the receiver SHOULD sign and broadcast the
* final closing transaction and MAY close the connection.
*/
if (received_fee == sent_fee)
break;
Expand Down Expand Up @@ -433,7 +441,7 @@ int main(int argc, char *argv[])

/* BOLT #2:
*
* ...otherwise it SHOULD propose a value strictly between the
* ...otherwise it MUST propose a value strictly between the
* received `fee_satoshis` and its previously-sent
* `fee_satoshis`.
*/
Expand Down
5 changes: 0 additions & 5 deletions lightningd/keyset.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ bool derive_keyset(const struct pubkey *per_commitment_point,
* a new commitment for a remote node, it uses its own
* `revocation_basepoint` and the remote node's `per_commitment_point`
* to derive a new `revocationkey` for the commitment.
*
* per_commitment_point... is used to derive the revocation key from
* the remote node's `revocation_basepoint`:
*
* revocationkey = revocation_basepoint * SHA256(revocation_basepoint || per_commitment_point) + per_commitment_point*SHA256(per_commitment_point || revocation_basepoint)
*/
if (!derive_revocation_key(other_revocation_basepoint,
per_commitment_point,
Expand Down
2 changes: 1 addition & 1 deletion lightningd/sphinx.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ enum route_next_case {
*
* 1. type: `per_hop` (for `realm` 0)
* 2. data:
* * [`8`:`channel_id`]
* * [`8`:`short_channel_id`]
* * [`8`:`amt_to_forward`]
* * [`4`:`outgoing_cltv_value`]
* * [`12`:`padding`]
Expand Down
2 changes: 1 addition & 1 deletion wire/peer_wire.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool is_gossip_msg(const u8 *cursor);
* to perform an initial sync by setting the `initial_routing_sync`
* flags in the `init` message. The endpoint SHOULD set the
* `initial_routing_sync` flag if it requires a full copy of the other
* endpoint's routing state. Upon receiving an init message with the
* endpoint's routing state. Upon receiving an `init` message with the
* `initial_routing_sync` flag set the node sends `channel_announcement`s,
* `channel_update`s and `node_announcement`s for all known channels and
* nodes as if they were just received.
Expand Down

0 comments on commit fea412d

Please sign in to comment.