diff --git a/channeld/channel_wire.csv b/channeld/channel_wire.csv index b1f14b9a8..373f8434e 100644 --- a/channeld/channel_wire.csv +++ b/channeld/channel_wire.csv @@ -67,6 +67,7 @@ msgdata,channel_init,upfront_shutdown_script_len,u16, msgdata,channel_init,upfront_shutdown_script,u8,upfront_shutdown_script_len msgdata,channel_init,remote_ann_node_sig,?secp256k1_ecdsa_signature, msgdata,channel_init,remote_ann_bitcoin_sig,?secp256k1_ecdsa_signature, +msgdata,channel_init,announce_delay,u32, # master->channeld funding hit new depth(funding locked if >= lock depth) msgtype,channel_funding_depth,1002 diff --git a/channeld/channeld.c b/channeld/channeld.c index e7df12412..a500aeb89 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -110,6 +110,9 @@ struct peer { u64 commit_timer_attempts; u32 commit_msec; + /* How long to delay before broadcasting announcement? */ + u32 announce_delay; + /* Are we expecting a pong? */ bool expecting_pong; @@ -500,7 +503,10 @@ static void channel_announcement_negotiate(struct peer *peer) &peer->announcement_node_sigs[REMOTE], &peer->announcement_bitcoin_sigs[REMOTE]))); - announce_channel(peer); + /* Give other nodes time to notice new block. */ + notleak(new_reltimer(&peer->timers, peer, + time_from_sec(peer->announce_delay), + announce_channel, peer)); } } @@ -2904,7 +2910,8 @@ static void init_channel(struct peer *peer) &peer->localfeatures, &peer->remote_upfront_shutdown_script, &remote_ann_node_sig, - &remote_ann_bitcoin_sig)) { + &remote_ann_bitcoin_sig, + &peer->announce_delay)) { master_badmsg(WIRE_CHANNEL_INIT, msg); } /* stdin == requests, 3 == peer, 4 = gossip, 5 = gossip_store, 6 = HSM */ diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index f98cd3c06..aa9337ee2 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -424,7 +424,10 @@ void peer_start_channeld(struct channel *channel, channel->peer->localfeatures, channel->remote_upfront_shutdown_script, remote_ann_node_sig, - remote_ann_bitcoin_sig); + remote_ann_bitcoin_sig, + /* Delay announce by 60 seconds after + * seeing block (adjustable if dev) */ + ld->topology->poll_seconds * 2); /* We don't expect a response: we are triggered by funding_depth_cb. */ subd_send_msg(channel->owner, take(initmsg));