-
Notifications
You must be signed in to change notification settings - Fork 19
LSPS2: ability to signal channel open failure #137
LSPS2: ability to signal channel open failure #137
Conversation
494a03c
to
8a7886c
Compare
8a7886c
to
b82779c
Compare
There was a problem hiding this 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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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>)> { |
There was a problem hiding this comment.
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 InterceptedHTLC
s. Why not just use InterceptedHTLC::payment_hash
instead? If you're worried about duplicates, could just use dedup
or collect a HashSet
?
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? |
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 |
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. |
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.