Skip to content

Commit ad6b10c

Browse files
committed
channel: Send local_add_channel to gossip on funding_locked
Signed-off-by: Christian Decker <[email protected]>
1 parent 13cf5b1 commit ad6b10c

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

channeld/channel.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,34 @@ static void gossip_in(struct peer *peer, const u8 *msg)
198198
wire_type_name(type), tal_hex(msg, msg));
199199
}
200200

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+
201229
static void send_announcement_signatures(struct peer *peer)
202230
{
203231
/* 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)
362390
take(towire_channel_normal_operation(peer)));
363391
}
364392

393+
/* Send temporary or final announcements */
394+
send_temporary_announcement(peer);
365395
send_announcement_signatures(peer);
366396
}
367397

@@ -1801,12 +1831,14 @@ static void handle_funding_locked(struct peer *peer, const u8 *msg)
18011831
msg_enqueue(&peer->peer_out, take(msg));
18021832
peer->funding_locked[LOCAL] = true;
18031833

1804-
send_announcement_signatures(peer);
1805-
18061834
if (peer->funding_locked[REMOTE]) {
18071835
wire_sync_write(MASTER_FD,
18081836
take(towire_channel_normal_operation(peer)));
18091837
}
1838+
1839+
/* Send temporary or final announcements */
1840+
send_temporary_announcement(peer);
1841+
send_announcement_signatures(peer);
18101842
}
18111843

18121844
static void handle_funding_announce_depth(struct peer *peer, const u8 *msg)

0 commit comments

Comments
 (0)