Skip to content

Commit

Permalink
chore: allow opening channel from rejected state
Browse files Browse the repository at this point in the history
We need to treat the SubChannelState::Rejected same as `OffChainClosed` as otherwise we won't be able to open a new subchannel if an offer was rejected.
  • Loading branch information
bonomat committed Dec 8, 2023
1 parent 60c3012 commit e3c3602
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dlc-manager/src/sub_channel_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ where
.get_sub_channel(channel_details.channel_id)?
{
Some(mut s) => match s.state {
SubChannelState::OffChainClosed => {
SubChannelState::OffChainClosed | SubChannelState::Rejected => {
s.is_offer = true;
s.update_idx -= 1;

Expand Down Expand Up @@ -1585,7 +1585,7 @@ where
.get_sub_channel(channel_details.channel_id)?
{
Some(mut s) => match s.state {
SubChannelState::OffChainClosed => {
SubChannelState::OffChainClosed | SubChannelState::Rejected => {
s.is_offer = false;
s.update_idx -= 1;
Some(s)
Expand Down
23 changes: 23 additions & 0 deletions dlc-manager/tests/ln_dlc_channel_execution_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,29 @@ fn ln_dlc_rejected_offer() {
reject_offer(&test_params);
}


#[test]
#[ignore]
fn ln_dlc_rejected_offer_then_new_offer_and_accept_offer() {
let test_params = test_init();
make_ln_payment(&test_params.alice_node, &test_params.bob_node, 900000);

reject_offer(&test_params);

offer_sub_channel_internal(&test_params, false);

assert_sub_channel_state!(
test_params.alice_node.sub_channel_manager,
&test_params.channel_id,
Signed
);
assert_sub_channel_state!(
test_params.bob_node.sub_channel_manager,
&test_params.channel_id,
Signed
);
}

#[test]
#[ignore]
fn ln_dlc_rejected_close() {
Expand Down

0 comments on commit e3c3602

Please sign in to comment.