diff --git a/lightningd/channel/channel.c b/lightningd/channel/channel.c index 0f7ab6433..05c60b471 100644 --- a/lightningd/channel/channel.c +++ b/lightningd/channel/channel.c @@ -1545,7 +1545,7 @@ again: /* 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 @@ -1614,9 +1614,11 @@ again: /* 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 diff --git a/lightningd/closing/closing.c b/lightningd/closing/closing.c index 0769412ef..7a0d8597b 100644 --- a/lightningd/closing/closing.c +++ b/lightningd/closing/closing.c @@ -135,7 +135,7 @@ again: /* 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 @@ -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); @@ -231,11 +233,8 @@ 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, @@ -243,10 +242,12 @@ int main(int argc, char *argv[]) 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, @@ -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, @@ -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, @@ -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; @@ -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`. */ diff --git a/lightningd/keyset.c b/lightningd/keyset.c index 81fb18baa..735686590 100644 --- a/lightningd/keyset.c +++ b/lightningd/keyset.c @@ -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, diff --git a/lightningd/sphinx.h b/lightningd/sphinx.h index 376f17076..6a4506104 100644 --- a/lightningd/sphinx.h +++ b/lightningd/sphinx.h @@ -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`] diff --git a/wire/peer_wire.h b/wire/peer_wire.h index bfb0c9e39..b9160ff59 100644 --- a/wire/peer_wire.h +++ b/wire/peer_wire.h @@ -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.