Skip to content

Commit

Permalink
fix: Only consider non-final dlc channels
Browse files Browse the repository at this point in the history
The user might have multiple non signed dlc channels. We do not care about those.
  • Loading branch information
holzeis committed Jan 17, 2024
1 parent e7078a2 commit 79196f0
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion mobile/native/src/dlc_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,26 @@ impl DlcHandler {
}

pub fn on_connect(&self, peer: PublicKey) -> Result<()> {
if let Some(channel) = self.node.list_dlc_channels()?.first() {
let dlc_channels: Vec<Channel> = self
.node
.list_dlc_channels()?
.into_iter()
.filter(|c| {
// Filter all dlc channels that have reached a somewhat final state.
!matches!(
c,
Channel::Closed(_)
| Channel::Closing(_)
| Channel::CounterClosed(_)
| Channel::ClosedPunished(_)
| Channel::CollaborativelyClosed(_)
| Channel::FailedAccept(_)
| Channel::FailedSign(_)
)
})
.collect();

if let Some(channel) = dlc_channels.first() {
match channel {
Channel::Offered(OfferedChannel {
temporary_channel_id,
Expand Down

0 comments on commit 79196f0

Please sign in to comment.