mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
closingd: retransmit shutdown on reconnect.
The spec says so, and it's right: with the right pattern of packet loss (thanks Travis!) the other end can still be in channeld, waiting for our `shutdown` message. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
d4f164eb39
commit
1935614979
@@ -25,6 +25,8 @@ closing_init,,next_index_remote,u64
|
||||
closing_init,,revocations_received,u64
|
||||
closing_init,,channel_reestablish_len,u16
|
||||
closing_init,,channel_reestablish,channel_reestablish_len*u8
|
||||
closing_init,,final_scriptpubkey_len,u16
|
||||
closing_init,,final_scriptpubkey,final_scriptpubkey_len*u8
|
||||
|
||||
# We received an offer, save signature.
|
||||
closing_received_signature,2002
|
||||
|
||||
|
@@ -103,7 +103,8 @@ static void do_reconnect(struct crypto_state *cs,
|
||||
const struct channel_id *channel_id,
|
||||
const u64 next_index[NUM_SIDES],
|
||||
u64 revocations_received,
|
||||
const u8 *channel_reestablish)
|
||||
const u8 *channel_reestablish,
|
||||
const u8 *final_scriptpubkey)
|
||||
{
|
||||
u8 *msg;
|
||||
struct channel_id their_channel_id;
|
||||
@@ -147,6 +148,17 @@ static void do_reconnect(struct crypto_state *cs,
|
||||
next_local_commitment_number,
|
||||
next_remote_revocation_number);
|
||||
|
||||
/* BOLT #2:
|
||||
*
|
||||
* A node:
|
||||
*...
|
||||
* - upon reconnection:
|
||||
* - if it has sent a previous `shutdown`:
|
||||
* - MUST retransmit `shutdown`.
|
||||
*/
|
||||
msg = towire_shutdown(NULL, channel_id, final_scriptpubkey);
|
||||
sync_crypto_write(cs, PEER_FD, take(msg));
|
||||
|
||||
/* FIXME: Spec says to re-xmit funding_locked here if we haven't
|
||||
* done any updates. */
|
||||
}
|
||||
@@ -429,7 +441,7 @@ int main(int argc, char *argv[])
|
||||
u64 min_fee_to_accept, commitment_fee, offer[NUM_SIDES];
|
||||
struct feerange feerange;
|
||||
enum side funder;
|
||||
u8 *scriptpubkey[NUM_SIDES], *funding_wscript;
|
||||
u8 *scriptpubkey[NUM_SIDES], *funding_wscript, *final_scriptpubkey;
|
||||
struct channel_id channel_id;
|
||||
bool reconnected;
|
||||
u64 next_index[NUM_SIDES], revocations_received;
|
||||
@@ -459,7 +471,8 @@ int main(int argc, char *argv[])
|
||||
&next_index[LOCAL],
|
||||
&next_index[REMOTE],
|
||||
&revocations_received,
|
||||
&channel_reestablish))
|
||||
&channel_reestablish,
|
||||
&final_scriptpubkey))
|
||||
master_badmsg(WIRE_CLOSING_INIT, msg);
|
||||
|
||||
status_trace("satoshi_out = %"PRIu64"/%"PRIu64,
|
||||
@@ -475,7 +488,7 @@ int main(int argc, char *argv[])
|
||||
if (reconnected)
|
||||
do_reconnect(&cs, &channel_id,
|
||||
next_index, revocations_received,
|
||||
channel_reestablish);
|
||||
channel_reestablish, final_scriptpubkey);
|
||||
|
||||
peer_billboard(true, "Negotiating closing fee between %"PRIu64
|
||||
" and %"PRIu64" satoshi (ideal %"PRIu64")",
|
||||
|
||||
@@ -236,7 +236,9 @@ void peer_start_closingd(struct channel *channel,
|
||||
channel->next_index[LOCAL],
|
||||
channel->next_index[REMOTE],
|
||||
num_revocations,
|
||||
channel_reestablish);
|
||||
channel_reestablish,
|
||||
p2wpkh_for_keyidx(tmpctx, ld,
|
||||
channel->final_key_idx));
|
||||
|
||||
/* We don't expect a response: it will give us feedback on
|
||||
* signatures sent and received, then closing_complete. */
|
||||
|
||||
Reference in New Issue
Block a user