Skip to content

Commit cf63465

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 73b20e2 commit cf63465

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
@@ -2648,13 +2648,12 @@ where
26482648
}
26492649
},
26502650
hash_map::Entry::Vacant(_) => {
2651-
// If we reach this point, it means that the channel_id either refers to an unfunded channel or
2652-
// it does not exist for this peer. Either way, we can attempt to force-close it.
2653-
//
2654-
// An appropriate error will be returned for non-existence of the channel if that's the case.
2655-
mem::drop(peer_state_lock);
2656-
mem::drop(per_peer_state);
2657-
return self.force_close_channel_with_peer(&channel_id, counterparty_node_id, None, false).map(|_| ())
2651+
return Err(APIError::ChannelUnavailable {
2652+
err: format!(
2653+
"Channel with id {} not found for the passed counterparty node_id {}",
2654+
channel_id, counterparty_node_id,
2655+
)
2656+
});
26582657
},
26592658
}
26602659
}

0 commit comments

Comments
 (0)