Skip to content

Commit 5db34c5

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 80f9d50 commit 5db34c5

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
@@ -2678,13 +2678,12 @@ where
26782678
}
26792679
},
26802680
hash_map::Entry::Vacant(_) => {
2681-
// If we reach this point, it means that the channel_id either refers to an unfunded channel or
2682-
// it does not exist for this peer. Either way, we can attempt to force-close it.
2683-
//
2684-
// An appropriate error will be returned for non-existence of the channel if that's the case.
2685-
mem::drop(peer_state_lock);
2686-
mem::drop(per_peer_state);
2687-
return self.force_close_channel_with_peer(&channel_id, counterparty_node_id, None, false).map(|_| ())
2681+
return Err(APIError::ChannelUnavailable {
2682+
err: format!(
2683+
"Channel with id {} not found for the passed counterparty node_id {}",
2684+
channel_id, counterparty_node_id,
2685+
)
2686+
});
26882687
},
26892688
}
26902689
}

0 commit comments

Comments
 (0)