From a573d42777df2599ae46ab7e49bdf7314ece25d1 Mon Sep 17 00:00:00 2001 From: niftynei Date: Thu, 20 May 2021 17:51:15 -0500 Subject: [PATCH] dual-fund: we were double-broadcasting the funding tx On a reconnect after a restart, node will re-broadcast the funding tx. This isn't terrible but there's no reason to do it. --- lightningd/dual_open_control.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index 015068624966..27fdd8d60b02 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -1707,6 +1707,7 @@ static void handle_peer_tx_sigs_msg(struct subd *dualopend, struct lightningd *ld = dualopend->ld; struct channel *channel = dualopend->channel; struct channel_inflight *inflight; + bool had_sigs; if (!fromwire_dualopend_funding_sigs(tmpctx, msg, &psbt)) { channel_internal_error(channel, @@ -1724,10 +1725,6 @@ static void handle_peer_tx_sigs_msg(struct subd *dualopend, return; } - /* Save that we've gotten their sigs. Sometimes - * the peer doesn't send any sigs (no inputs), otherwise - * we could just check the PSBT was finalized */ - inflight->remote_tx_sigs = true; psbt_txid(NULL, psbt, &txid, NULL); if (!bitcoin_txid_eq(&txid, &inflight->funding->txid)) { channel_internal_error(channel, @@ -1756,13 +1753,21 @@ static void handle_peer_tx_sigs_msg(struct subd *dualopend, return; } tal_wally_end(inflight->funding_psbt); + + /* Save that we've gotten their sigs. Sometimes + * the peer doesn't send any sigs (no inputs), otherwise + * we could just check the PSBT was finalized */ + had_sigs = inflight->remote_tx_sigs; + inflight->remote_tx_sigs = true; wallet_inflight_save(ld->wallet, inflight); /* It's possible we haven't sent them our (empty) tx-sigs yet, * but we should be sending it soon... */ if (psbt_finalize(cast_const(struct wally_psbt *, inflight->funding_psbt)) - && !inflight->tx_broadcast) { + && !inflight->tx_broadcast + && !had_sigs) { + inflight->tx_broadcast = true; /* Saves the now finalized version of the psbt */