Skip to content

Commit fc99d76

Browse files
cdeckerrustyrussell
authored andcommitted
channel: Send local_add_channel to gossip on funding_locked
Signed-off-by: Christian Decker <[email protected]>
1 parent 9493c05 commit fc99d76

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
@@ -199,6 +199,34 @@ static void gossip_in(struct peer *peer, const u8 *msg)
199199
wire_type_name(type), tal_hex(msg, msg));
200200
}
201201

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

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

@@ -1808,12 +1838,14 @@ static void handle_funding_locked(struct peer *peer, const u8 *msg)
18081838
msg_enqueue(&peer->peer_out, take(msg));
18091839
peer->funding_locked[LOCAL] = true;
18101840

1811-
send_announcement_signatures(peer);
1812-
18131841
if (peer->funding_locked[REMOTE]) {
18141842
wire_sync_write(MASTER_FD,
18151843
take(towire_channel_normal_operation(peer)));
18161844
}
1845+
1846+
/* Send temporary or final announcements */
1847+
send_temporary_announcement(peer);
1848+
send_announcement_signatures(peer);
18171849
}
18181850

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

0 commit comments

Comments
 (0)