@@ -198,6 +198,34 @@ static void gossip_in(struct peer *peer, const u8 *msg)
198
198
wire_type_name (type ), tal_hex (msg , msg ));
199
199
}
200
200
201
+ /* Send a temporary `channel_announcement` and `channel_update`. These
202
+ * are unsigned and mainly used to tell gossip about the channel
203
+ * before we have reached the `announcement_depth`, not being signed
204
+ * means they will not be relayed, but we can already rely on them for
205
+ * our own outgoing payments */
206
+ static void send_temporary_announcement (struct peer * peer )
207
+ {
208
+ tal_t * tmpctx ;
209
+ u8 * msg ;
210
+
211
+ /* If we are supposed to send a real announcement, don't do a
212
+ * dummy one here, hence the check for announce_depth. */
213
+ if (peer -> announce_depth_reached || !peer -> funding_locked [LOCAL ] ||
214
+ !peer -> funding_locked [REMOTE ])
215
+ return ;
216
+
217
+ tmpctx = tal_tmpctx (peer );
218
+
219
+ msg = towire_gossip_local_add_channel (
220
+ tmpctx , & peer -> short_channel_ids [LOCAL ], & peer -> chain_hash ,
221
+ & peer -> node_ids [REMOTE ], 0 /* flags */ , peer -> cltv_delta ,
222
+ peer -> conf [REMOTE ].htlc_minimum_msat , peer -> fee_base ,
223
+ peer -> fee_per_satoshi );
224
+ wire_sync_write (GOSSIP_FD , take (msg ));
225
+
226
+ tal_free (tmpctx );
227
+ }
228
+
201
229
static void send_announcement_signatures (struct peer * peer )
202
230
{
203
231
/* First 2 + 256 byte are the signatures and msg type, skip them */
@@ -362,6 +390,8 @@ static void handle_peer_funding_locked(struct peer *peer, const u8 *msg)
362
390
take (towire_channel_normal_operation (peer )));
363
391
}
364
392
393
+ /* Send temporary or final announcements */
394
+ send_temporary_announcement (peer );
365
395
send_announcement_signatures (peer );
366
396
}
367
397
@@ -1801,12 +1831,14 @@ static void handle_funding_locked(struct peer *peer, const u8 *msg)
1801
1831
msg_enqueue (& peer -> peer_out , take (msg ));
1802
1832
peer -> funding_locked [LOCAL ] = true;
1803
1833
1804
- send_announcement_signatures (peer );
1805
-
1806
1834
if (peer -> funding_locked [REMOTE ]) {
1807
1835
wire_sync_write (MASTER_FD ,
1808
1836
take (towire_channel_normal_operation (peer )));
1809
1837
}
1838
+
1839
+ /* Send temporary or final announcements */
1840
+ send_temporary_announcement (peer );
1841
+ send_announcement_signatures (peer );
1810
1842
}
1811
1843
1812
1844
static void handle_funding_announce_depth (struct peer * peer , const u8 * msg )
0 commit comments