Skip to content

Commit

Permalink
dual-fund: we were double-broadcasting the funding tx
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
niftynei committed May 20, 2021
1 parent 4efd2d4 commit a573d42
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lightningd/dual_open_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit a573d42

Please sign in to comment.