dualfund, bump: when bumping a channel make sure it's in ok state

If we disconnect, we lose the open_attempt record. Which is fine, but we
should prevent the user from starting another RBF if the last one isn't
done yet!
This commit is contained in:
niftynei 2023-10-31 16:34:37 -05:00 committed by Rusty Russell
parent dbcdfd7d66
commit f4b4f772f3

View file

@ -2497,6 +2497,7 @@ json_openchannel_bump(struct command *cmd,
struct wally_psbt *psbt;
u32 last_feerate_perkw, next_feerate_min, *feerate_per_kw_funding;
struct open_attempt *oa;
struct channel_inflight *inflight;
if (!param_check(cmd, buffer, params,
p_req("channel_id", param_channel_id, &cid),
@ -2599,9 +2600,22 @@ json_openchannel_bump(struct command *cmd,
"Only the channel opener can initiate an"
" RBF attempt");
inflight = channel_current_inflight(channel);
if (!inflight) {
return command_fail(cmd, FUNDING_STATE_INVALID,
"No inflight for this channel exists.");
}
if (!inflight->remote_tx_sigs) {
return command_fail(cmd, FUNDING_STATE_INVALID,
"Funding sigs for this channel not "
"secured, see `openchannel_signed`");
}
if (command_check_only(cmd))
return command_check_done(cmd);
/* Ok, we're kosher to start */
channel->open_attempt = oa = new_channel_open_attempt(channel);
oa->funding = *amount;