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 21, 2021
1 parent 6383a72 commit ffdd029
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 @@ -1712,6 +1712,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 @@ -1729,10 +1730,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;
tal_wally_start();
if (wally_psbt_combine(inflight->funding_psbt, psbt) != WALLY_OK) {
channel_internal_error(channel,
Expand All @@ -1747,13 +1744,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 ffdd029

Please sign in to comment.