Skip to content

Commit 3f6e29b

Browse files
committed
Immediately error in close_channel_internal if there is no chan
Previously, unfunded channels would be stored outside of `PeerState::channel_by_id`, and thus if there is no channel when we look in `PeerState::channel_by_id`, `close_channel_internal` called `force_close_channel_with_peer` to hunt for unfunded channels. However, that is no longer the case, so the call is redundant, and we can simply return an error instead.
1 parent 0d30005 commit 3f6e29b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2707,13 +2707,12 @@ where
27072707
}
27082708
},
27092709
hash_map::Entry::Vacant(_) => {
2710-
// If we reach this point, it means that the channel_id either refers to an unfunded channel or
2711-
// it does not exist for this peer. Either way, we can attempt to force-close it.
2712-
//
2713-
// An appropriate error will be returned for non-existence of the channel if that's the case.
2714-
mem::drop(peer_state_lock);
2715-
mem::drop(per_peer_state);
2716-
return self.force_close_channel_with_peer(&channel_id, counterparty_node_id, None, false).map(|_| ())
2710+
return Err(APIError::ChannelUnavailable {
2711+
err: format!(
2712+
"Channel with id {} not found for the passed counterparty node_id {}",
2713+
channel_id, counterparty_node_id,
2714+
)
2715+
});
27172716
},
27182717
}
27192718
}

0 commit comments

Comments
 (0)