Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

LSPS2: ability to signal channel open failure #137

Conversation

johncantrell97
Copy link
Contributor

Closes lightningdevkit/rust-lightning#3479

There are a number of reasons a channel open might fail or be abandoned by the LSP. This adds a way for the LSP to signal back to the library that this has happened.

All pending payments are failed backwards and the channel state is reset to PendingInitialPayment as per the spec. This allows the payer to try again.

@johncantrell97 johncantrell97 changed the title ability to signal channel open failure LSPS2: ability to signal channel open failure May 17, 2024
@johncantrell97 johncantrell97 force-pushed the signal-channel-open-failure branch from 494a03c to 8a7886c Compare May 17, 2024 14:06
@johncantrell97 johncantrell97 force-pushed the signal-channel-open-failure branch from 8a7886c to b82779c Compare May 17, 2024 15:43
Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excuse the delay here!

LGTM, mod some minor questions/nits.

///
/// Should be called in response to receiving a [`LSPS2ServiceEvent::OpenChannel`] event.
///
/// The JIT channel state is reset such that the payer can attempt payment again.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we also expose a "abandon" variant that doesn't reset, but just prunes all state related to the channel open?

@@ -898,6 +904,79 @@ where
Ok(())
}

/// Used by LSP to fail intercepted htlcs backwards when the channel open fails for any reason.
///
/// Should be called in response to receiving a [`LSPS2ServiceEvent::OpenChannel`] event.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is a bit misleading. It should be called after we get the event, but of course only if the channel open failed?

@@ -49,8 +49,8 @@ impl PaymentQueue {
position.map(|position| self.payments.remove(position))
}

pub(crate) fn clear(&mut self) -> Vec<InterceptedHTLC> {
self.payments.drain(..).map(|(_k, v)| v).flatten().collect()
pub(crate) fn clear(&mut self) -> Vec<(PaymentHash, Vec<InterceptedHTLC>)> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Not sure this change is worth as it makes things more complex and you only make use of it in one place where you then have to map to get rid of the InterceptedHTLCs. Why not just use InterceptedHTLC::payment_hash instead? If you're worried about duplicates, could just use dedup or collect a HashSet?

@tnull
Copy link
Collaborator

tnull commented Nov 28, 2024

Any intentions to pick this back up?

@johncantrell97
Copy link
Contributor Author

Any intentions to pick this back up?

Yeah probably, though I'm not really sure what the status of the whole LSPS project is? Wasn't the latest to transition to a liquidity ads based solution?

@tnull
Copy link
Collaborator

tnull commented Dec 3, 2024

Yeah probably, though I'm not really sure what the status of the whole LSPS project is? Wasn't the latest to transition to a liquidity ads based solution?

Well, we still intend to finish LSPS1/LSPS2 work, even though future iterations will be based on Liquidity Ads.

Cool to hear you might be interested in getting the open PRs landed. Note however that we're finally about to move lightning-liquidity into rust-lightning, so you might need to reopen them there once that is done.

@tnull
Copy link
Collaborator

tnull commented Jan 6, 2025

Closing this as I'm about to archive this repository in favor of https://github.com/lightningdevkit/rust-lightning/tree/main/lightning-liquidity.

Please re-open the PR over there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LSPS2: Fail intercepted htlcs if lsp open channel fails for whatever reason
2 participants