Skip to content

Commit

Permalink
dualfund: add switch for if the incoming channel is "too early"
Browse files Browse the repository at this point in the history
If we get an error on a channel that doesn't have commitments yet,
we can just delete it.
  • Loading branch information
niftynei authored and rustyrussell committed Nov 2, 2023
1 parent d575057 commit 7114a03
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lightningd/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,9 @@ void channel_fail_permanent(struct channel *channel,
reason,
why);

if (channel_state_open_uncommitted(channel->state))
delete_channel(channel);

tal_free(why);
}

Expand Down
25 changes: 25 additions & 0 deletions lightningd/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,31 @@ static inline bool channel_state_wants_onchain_fail(enum channel_state state)
abort();
}

static inline bool channel_state_open_uncommitted(enum channel_state state)
{
switch (state) {
case DUALOPEND_OPEN_INIT:
case DUALOPEND_OPEN_COMMIT_READY:
return true;
case CLOSINGD_COMPLETE:
case AWAITING_UNILATERAL:
case FUNDING_SPEND_SEEN:
case ONCHAIN:
case CLOSED:
case CHANNELD_AWAITING_LOCKIN:
case DUALOPEND_OPEN_COMMITTED:
case DUALOPEND_AWAITING_LOCKIN:
case CHANNELD_NORMAL:
case CHANNELD_AWAITING_SPLICE:
case CLOSINGD_SIGEXCHANGE:
case CHANNELD_SHUTTING_DOWN:
return false;
}

abort();
}


void channel_set_owner(struct channel *channel, struct subd *owner);

/* Channel has failed, but can try again. Usually, set disconnect to true. */
Expand Down
6 changes: 6 additions & 0 deletions lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,12 @@ void drop_to_chain(struct lightningd *ld, struct channel *channel,
log_broken(channel->log,
"Cannot broadcast our commitment tx:"
" they have a future one");
} else if (channel_state_open_uncommitted(channel->state)) {
/* There's no commitment transaction, we can
* safely forget this channel */
log_info(channel->log,
"Initialized channel (v2) received error"
", we're deleting the channel");
} else if (invalid_last_tx(channel->last_tx)) {
log_broken(channel->log,
"Cannot broadcast our commitment tx:"
Expand Down

0 comments on commit 7114a03

Please sign in to comment.