|
@ -89,14 +89,20 @@ static void do_reconnect(struct crypto_state *cs, |
|
|
|
|
|
|
|
|
/* BOLT #2:
|
|
|
/* BOLT #2:
|
|
|
* |
|
|
* |
|
|
* On reconnection, a node MUST transmit `channel_reestablish` for |
|
|
* - upon reconnection: |
|
|
* each channel, and MUST wait for to receive the other node's |
|
|
* - if a channel is in an error state: |
|
|
* `channel_reestablish` message before sending any other messages for |
|
|
* - SHOULD retransmit the error packet and ignore any other packets for |
|
|
* that channel. The sending node MUST set |
|
|
* that channel. |
|
|
* `next_local_commitment_number` to the commitment number of the next |
|
|
* - otherwise: |
|
|
* `commitment_signed` it expects to receive, and MUST set |
|
|
* - MUST transmit `channel_reestablish` for each channel. |
|
|
* `next_remote_revocation_number` to the commitment number of the |
|
|
* - MUST wait to receive the other node's `channel_reestablish` |
|
|
* next `revoke_and_ack` message it expects to receive. |
|
|
* message before sending any other messages for that channel. |
|
|
|
|
|
* |
|
|
|
|
|
* The sending node: |
|
|
|
|
|
* - MUST set `next_local_commitment_number` to the commitment number |
|
|
|
|
|
* of the next `commitment_signed` it expects to receive. |
|
|
|
|
|
* - MUST set `next_remote_revocation_number` to the commitment number |
|
|
|
|
|
* of the next `revoke_and_ack` message it expects to receive. |
|
|
*/ |
|
|
*/ |
|
|
msg = towire_channel_reestablish(NULL, channel_id, |
|
|
msg = towire_channel_reestablish(NULL, channel_id, |
|
|
next_index[LOCAL], |
|
|
next_index[LOCAL], |
|
@ -130,16 +136,6 @@ static void do_reconnect(struct crypto_state *cs, |
|
|
|
|
|
|
|
|
/* FIXME: Spec says to re-xmit funding_locked here if we haven't
|
|
|
/* FIXME: Spec says to re-xmit funding_locked here if we haven't
|
|
|
* done any updates. */ |
|
|
* done any updates. */ |
|
|
|
|
|
|
|
|
/* BOLT #2:
|
|
|
|
|
|
* |
|
|
|
|
|
* On reconnection if the node has sent a previous `closing_signed` it |
|
|
|
|
|
* MUST send another `closing_signed` |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
/* Since we always transmit closing_signed immediately, if
|
|
|
|
|
|
* we're reconnecting we consider ourselves to have transmitted once, |
|
|
|
|
|
* and we'll immediately do the retransmit now anyway. */ |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void send_offer(struct crypto_state *cs, |
|
|
static void send_offer(struct crypto_state *cs, |
|
@ -162,9 +158,9 @@ static void send_offer(struct crypto_state *cs, |
|
|
|
|
|
|
|
|
/* BOLT #2:
|
|
|
/* BOLT #2:
|
|
|
* |
|
|
* |
|
|
* The sender MUST set `signature` to the Bitcoin signature of |
|
|
* - MUST set `signature` to the Bitcoin signature of the close |
|
|
* the close transaction as specified in [BOLT |
|
|
* transaction, as specified in [BOLT |
|
|
* #3](03-transactions.md#closing-transaction). |
|
|
* #3](03-transactions.md#closing-transaction). |
|
|
*/ |
|
|
*/ |
|
|
tx = close_tx(tmpctx, cs, channel_id, |
|
|
tx = close_tx(tmpctx, cs, channel_id, |
|
|
scriptpubkey, |
|
|
scriptpubkey, |
|
@ -178,7 +174,7 @@ static void send_offer(struct crypto_state *cs, |
|
|
* |
|
|
* |
|
|
* ## Closing Transaction |
|
|
* ## Closing Transaction |
|
|
*... |
|
|
*... |
|
|
* Each node offering a signature... MAY also eliminate its |
|
|
* Each node offering a signature... MAY eliminate its |
|
|
* own output. |
|
|
* own output. |
|
|
*/ |
|
|
*/ |
|
|
/* (We don't do this). */ |
|
|
/* (We don't do this). */ |
|
@ -241,17 +237,16 @@ static uint64_t receive_offer(struct crypto_state *cs, |
|
|
|
|
|
|
|
|
/* BOLT #2:
|
|
|
/* BOLT #2:
|
|
|
* |
|
|
* |
|
|
* On reconnection, a node MUST ignore a redundant |
|
|
* - upon reconnection: |
|
|
* `funding_locked` if it receives one. |
|
|
* - MUST ignore any redundant `funding_locked` it receives. |
|
|
*/ |
|
|
*/ |
|
|
/* This should only happen if we've made no commitments, but
|
|
|
/* This should only happen if we've made no commitments, but
|
|
|
* we don't have to check that: it's their problem. */ |
|
|
* we don't have to check that: it's their problem. */ |
|
|
if (msg && fromwire_peektype(msg) == WIRE_FUNDING_LOCKED) |
|
|
if (msg && fromwire_peektype(msg) == WIRE_FUNDING_LOCKED) |
|
|
msg = tal_free(msg); |
|
|
msg = tal_free(msg); |
|
|
/* BOLT #2:
|
|
|
/* BOLT #2:
|
|
|
* |
|
|
* - if it has sent a previous `shutdown`: |
|
|
* ...if the node has sent a previous `shutdown` it MUST |
|
|
* - MUST retransmit `shutdown`. |
|
|
* retransmit it. |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
else if (msg && fromwire_peektype(msg) == WIRE_SHUTDOWN) |
|
|
else if (msg && fromwire_peektype(msg) == WIRE_SHUTDOWN) |
|
|
msg = tal_free(msg); |
|
|
msg = tal_free(msg); |
|
@ -265,10 +260,10 @@ static uint64_t receive_offer(struct crypto_state *cs, |
|
|
|
|
|
|
|
|
/* BOLT #2:
|
|
|
/* BOLT #2:
|
|
|
* |
|
|
* |
|
|
* The receiver MUST check `signature` is valid for either |
|
|
* The receiving node: |
|
|
* variant of close transaction specified in [BOLT |
|
|
* - if the `signature` is not valid for either variant of close |
|
|
* #3](03-transactions.md#closing-transaction), and MUST fail |
|
|
* transaction specified in [BOLT #3](03-transactions.md#closing-transaction): |
|
|
* the connection if it is not. |
|
|
* - MUST fail the connection. |
|
|
*/ |
|
|
*/ |
|
|
tx = close_tx(tmpctx, cs, channel_id, |
|
|
tx = close_tx(tmpctx, cs, channel_id, |
|
|
scriptpubkey, |
|
|
scriptpubkey, |
|
@ -291,10 +286,13 @@ static uint64_t receive_offer(struct crypto_state *cs, |
|
|
|
|
|
|
|
|
/* BOLT #3:
|
|
|
/* BOLT #3:
|
|
|
* |
|
|
* |
|
|
* Each node offering a signature MUST subtract the fee given |
|
|
* Each node offering a signature: |
|
|
* by `fee_satoshis` from the output to the funder; it MUST |
|
|
* - MUST round each output down to whole satoshis. |
|
|
* then remove any output below its own `dust_limit_satoshis`, |
|
|
* - MUST subtract the fee given by `fee_satoshis` from the |
|
|
* and MAY also eliminate its own output. |
|
|
* output to the funder. |
|
|
|
|
|
* - MUST remove any output below its own |
|
|
|
|
|
* `dust_limit_satoshis`. |
|
|
|
|
|
* - MAY eliminate its own output. |
|
|
*/ |
|
|
*/ |
|
|
trimmed = close_tx(tmpctx, cs, channel_id, |
|
|
trimmed = close_tx(tmpctx, cs, channel_id, |
|
|
scriptpubkey, |
|
|
scriptpubkey, |
|
@ -383,8 +381,8 @@ static void adjust_feerange(struct crypto_state *cs, |
|
|
|
|
|
|
|
|
/* BOLT #2:
|
|
|
/* BOLT #2:
|
|
|
* |
|
|
* |
|
|
* ...otherwise it MUST propose a value strictly between the received |
|
|
* - MUST propose a value "strictly between" the received |
|
|
* `fee_satoshis` and its previously-sent `fee_satoshis`. |
|
|
* `fee_satoshis` and its previously-sent `fee_satoshis`. |
|
|
*/ |
|
|
*/ |
|
|
if (side == feerange->higher_side) |
|
|
if (side == feerange->higher_side) |
|
|
feerange->max = offer - 1; |
|
|
feerange->max = offer - 1; |
|
|