mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-10 01:24:30 +01:00
lightningd/channel_control: fix reached_announce_depth counting in peer_start_channeld
Fixes a corner case when reconnecting (which restarts channeld) at depth=6 where we didn't correctly send/respond with announce_signatures. NOTE: A complete restart of node may initialize channeld with unupdated height because of an unfinished rescan. But when rescan is finished, funding tx_watch is fired (at least once), which then tells channeld the latest depth.
This commit is contained in:
committed by
Christian Decker
parent
a3b646be31
commit
a9dd69002e
@@ -286,7 +286,7 @@ void peer_start_channeld(struct channel *channel,
|
||||
enum side *fulfilled_sides;
|
||||
const struct failed_htlc **failed_htlcs;
|
||||
enum side *failed_sides;
|
||||
struct short_channel_id funding_channel_id;
|
||||
struct short_channel_id scid;
|
||||
u64 num_revocations;
|
||||
struct lightningd *ld = channel->peer->ld;
|
||||
const struct config *cfg = &ld->config;
|
||||
@@ -326,16 +326,16 @@ void peer_start_channeld(struct channel *channel,
|
||||
&fulfilled_sides, &failed_htlcs, &failed_sides);
|
||||
|
||||
if (channel->scid) {
|
||||
funding_channel_id = *channel->scid;
|
||||
reached_announce_depth
|
||||
= (short_channel_id_blocknum(&funding_channel_id)
|
||||
+ ANNOUNCE_MIN_DEPTH <= get_block_height(ld->topology));
|
||||
scid = *channel->scid;
|
||||
/* Subtle: depth=1 at funding height. */
|
||||
reached_announce_depth = get_block_height(ld->topology) + 1 >=
|
||||
short_channel_id_blocknum(&scid) + ANNOUNCE_MIN_DEPTH;
|
||||
log_debug(channel->log, "Already have funding locked in%s",
|
||||
reached_announce_depth
|
||||
? " (and ready to announce)" : "");
|
||||
} else {
|
||||
log_debug(channel->log, "Waiting for funding confirmations");
|
||||
memset(&funding_channel_id, 0, sizeof(funding_channel_id));
|
||||
memset(&scid, 0, sizeof(scid));
|
||||
reached_announce_depth = false;
|
||||
}
|
||||
|
||||
@@ -411,7 +411,7 @@ void peer_start_channeld(struct channel *channel,
|
||||
failed_htlcs, failed_sides,
|
||||
channel->scid != NULL,
|
||||
channel->remote_funding_locked,
|
||||
&funding_channel_id,
|
||||
&scid,
|
||||
reconnected,
|
||||
channel->state == CHANNELD_SHUTTING_DOWN,
|
||||
channel->remote_shutdown_scriptpubkey != NULL,
|
||||
|
||||
Reference in New Issue
Block a user