Add BOLT12 support to LSPS2 flow#817
Open
tnull wants to merge 4 commits into
Open
Conversation
|
🎉 This PR is now ready for review! |
c62ca3a to
b0eef7c
Compare
2210e23 to
db9b5ae
Compare
f894fad to
2fb92ba
Compare
Point the Rust Lightning dependency overrides at the unmerged LSPS2 PR revisions and carry the temporary API updates needed for LDK Node to compile against them. Co-Authored-By: HAL 9000
Encode LSPS2 parameters in a shared payment metadata type so both BOLT11 invoices and BOLT12 payment contexts can carry the fee limits needed when handling intercepted payments. Co-Authored-By: HAL 9000
Route BOLT12 payments through the LSPS2-aware router and expose JIT-channel receive flows so offers can carry the LSP invoice parameters needed for intercepted payments. Co-Authored-By: HAL 9000
Exercise fixed, variable, and async BOLT12 receive flows with LSPS2 JIT channels so the payment metadata and fee-limit handling remain covered. Co-Authored-By: HAL 9000
2fb92ba to
fc22dd0
Compare
jkczyz
reviewed
Jun 9, 2026
jkczyz
left a comment
Contributor
There was a problem hiding this comment.
Doesn't look like HAL 9000 likes to wrap commit messages.
|
|
||
| impl LSPS2Bolt12PaymentMetadataDecoder for LdkNodeLSPS2Bolt12PaymentMetadataDecoder { | ||
| fn decode_lsps2_invoice_parameters( | ||
| &self, payment_metadata: &BTreeMap<u64, Vec<u8>>, |
Contributor
There was a problem hiding this comment.
Maybe have LdkNodeLSPS2Bolt12PaymentMetadataDecoder wrap &BTreeMap<u64, Vec<u8>>?
Comment on lines
+40
to
+45
| payment_metadata | ||
| .get(&LDK_NODE_BOLT12_PAYMENT_METADATA_KEY) | ||
| .and_then(|encoded| PaymentMetadata::read(&mut &encoded[..]).ok()) | ||
| .and_then(|metadata| metadata.lsps2_bolt12_invoice_parameters) | ||
| .into_iter() | ||
| .collect() |
Contributor
There was a problem hiding this comment.
I assume this wants to return a Vec to support multiple LSPs? How do we plan to support that in PaymentMetadata?
Comment on lines
+319
to
+342
| let mut offer_builder = if let Some(payment_metadata) = payment_metadata { | ||
| self.channel_manager.create_offer_builder_using_router(PaymentMetadataMessageRouter { | ||
| inner: Arc::clone(&self.message_router), | ||
| payment_metadata, | ||
| }) | ||
| } else { | ||
| self.channel_manager.create_offer_builder() | ||
| } | ||
| .map_err(|e| { | ||
| log_error!(self.logger, "Failed to create offer builder: {:?}", e); | ||
| Error::OfferCreationFailed | ||
| })?; | ||
|
|
||
| if let Some(expiry_secs) = expiry_secs { | ||
| let absolute_expiry = (SystemTime::now() + Duration::from_secs(expiry_secs as u64)) | ||
| .duration_since(UNIX_EPOCH) | ||
| .unwrap(); | ||
| offer_builder = offer_builder.absolute_expiry(absolute_expiry); | ||
| } | ||
|
|
||
| offer_builder.description(description.to_string()).build().map_err(|e| { | ||
| log_error!(self.logger, "Failed to create offer: {:?}", e); | ||
| Error::OfferCreationFailed | ||
| }) |
| Arc<Logger>, | ||
| Arc<KeysManager>, | ||
| >; | ||
| pub(crate) type MessageRouter = InnerMessageRouter; |
Contributor
There was a problem hiding this comment.
Why not PaymentMetadataMessageRouter?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on lightningdevkit/rust-lightning#4463
We implement the LSPS2 flow for BOLT12 and async payments.