Skip to content

Commit

Permalink
inflights: add checks that there's actually an inflight
Browse files Browse the repository at this point in the history
  • Loading branch information
niftynei committed May 18, 2021
1 parent 7464fec commit 476aead
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lightningd/dual_open_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,12 @@ openchannel2_sign_hook_cb(struct openchannel2_psbt_payload *payload STEALS)
}

inflight = channel_current_inflight(channel);
if (!inflight) {
log_broken(channel->log,
"No current channel inflight");
msg = towire_dualopend_fail(NULL, "No current channel inflight");
goto send_msg;
}

/* Check that we've got the same / correct PSBT */
psbt_txid(NULL, payload->psbt, &txid, NULL);
Expand Down Expand Up @@ -1398,6 +1404,13 @@ static void handle_peer_tx_sigs_sent(struct subd *dualopend,
}

inflight = channel_current_inflight(channel);
if (!inflight) {
channel_internal_error(channel,
"No inflight found for channel %s",
type_to_string(tmpctx, struct channel,
channel));
return;
}

/* Once we've sent our sigs to the peer, we're fine
* to broadcast the transaction, even if they haven't
Expand Down Expand Up @@ -1723,6 +1736,14 @@ static void handle_peer_tx_sigs_msg(struct subd *dualopend,
}

inflight = channel_current_inflight(channel);
if (!inflight) {
channel_internal_error(channel,
"No inflight found for channel %s",
type_to_string(tmpctx, struct channel,
channel));
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 */
Expand Down Expand Up @@ -2906,11 +2927,14 @@ void peer_restart_dualopend(struct peer *peer,
&min_effective_htlc_capacity);

inflight = channel_current_inflight(channel);
assert(inflight);

/* Get the first inflight to figure out the original feerate
* for this channel. It's fine if it's the same as the current */
first_inflight = list_top(&channel->inflights,
struct channel_inflight,
list);
assert(first_inflight);
msg = towire_dualopend_reinit(NULL,
chainparams,
peer->ld->our_features,
Expand Down

0 comments on commit 476aead

Please sign in to comment.