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