From 19f8ed3fe1ee5a65975a8b052a3f679772e41586 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 31 May 2022 23:40:59 +0200 Subject: [PATCH] channeld: Explicitly use the first commitment point on reconnect The spec explicitly asks for the first point, while we were using the most recent one. This worked fine before zeroconf, but with zeroconf it can happen. --- channeld/channeld.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/channeld/channeld.c b/channeld/channeld.c index af0f20988..2ee4fec50 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -3217,6 +3217,7 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg) u32 depth; struct short_channel_id *scid, *alias_local; struct tlv_funding_locked_tlvs *tlvs; + struct pubkey point; if (!fromwire_channeld_funding_depth(tmpctx, msg, @@ -3253,9 +3254,13 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg) tlvs = tlv_funding_locked_tlvs_new(tmpctx); tlvs->alias = alias_local; - msg = towire_funding_locked( - NULL, &peer->channel_id, - &peer->next_local_per_commit, tlvs); + /* Need to retrieve the first point again, even if we + * moved on, as funding_locked explicitly includes the + * first one. */ + get_per_commitment_point(1, &point, NULL); + + msg = towire_funding_locked(NULL, &peer->channel_id, + &point, tlvs); peer_write(peer->pps, take(msg)); peer->funding_locked[LOCAL] = true;