Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BOLT12 support to bLIP-51 / LSPS1 #3649

Merged

Conversation

tnull
Copy link
Contributor

@tnull tnull commented Mar 6, 2025

Previously, bLIP-51 / LSPS1 only supported BOLT11 and onchain payment options. Here we add the necessary fields to allow to pay the LSP via BOLT12 offers.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Mar 6, 2025

👋 Thanks for assigning @arik-so as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@tnull tnull marked this pull request as draft March 6, 2025 13:28
@tnull tnull marked this pull request as ready for review March 6, 2025 14:28
@ldk-reviews-bot ldk-reviews-bot requested a review from arik-so March 6, 2025 14:28
arik-so
arik-so previously approved these changes Mar 6, 2025
@ldk-reviews-bot
Copy link

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

TheBlueMatt
TheBlueMatt previously approved these changes Mar 10, 2025
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

I imagine there's a part 2 to this where the messages get used somehow?

@tnull tnull dismissed stale reviews from TheBlueMatt and arik-so via 8505474 March 13, 2025 09:51
@tnull tnull force-pushed the 2025-03-add-bolt12-support-for-blip-51 branch from 7674b73 to 8505474 Compare March 13, 2025 09:51
@tnull
Copy link
Contributor Author

tnull commented Mar 13, 2025

I imagine there's a part 2 to this where the messages get used somehow?

Yes, we'll just add support for it when we finally add LSPS1 service side. On the client side we simply expose LSPS1PaymentInfo to the user as they need to choose their preferred payment method.

I now realized I missed adding the actual bolt12 field on LSPS1PaymentInfo (and tests didn't catch it as serde ignores unknown fields by default). Now force-pushed the fix:

> git diff-tree -U2 7674b739d 3274dbf5a
diff --git a/lightning-liquidity/src/lsps1/msgs.rs b/lightning-liquidity/src/lsps1/msgs.rs
index 7a4366ff7..0d9a6cec2 100644
--- a/lightning-liquidity/src/lsps1/msgs.rs
+++ b/lightning-liquidity/src/lsps1/msgs.rs
@@ -153,4 +153,6 @@ pub struct LSPS1PaymentInfo {
        /// A Lightning payment using BOLT 11.
        pub bolt11: Option<LSPS1Bolt11PaymentInfo>,
+       /// A Lightning payment using BOLT 12.
+       pub bolt12: Option<LSPS1Bolt12PaymentInfo>,
        /// An onchain payment.
        pub onchain: Option<LSPS1OnchainPaymentInfo>,
@@ -452,5 +454,8 @@ mod tests {
                        }
                }"#;
-               let _payment: LSPS1PaymentInfo = serde_json::from_str(json_str).unwrap();
+               let payment: LSPS1PaymentInfo = serde_json::from_str(json_str).unwrap();
+               assert!(payment.bolt11.is_some());
+               assert!(payment.bolt12.is_some());
+               assert!(payment.onchain.is_some());

                let json_str = r#"{
@@ -493,6 +498,9 @@ mod tests {
                        "channel": null
                }"#;
-               let _create_order_response: LSPS1CreateOrderResponse =
+               let create_order_response: LSPS1CreateOrderResponse =
                        serde_json::from_str(json_str).unwrap();
+               assert!(create_order_response.payment.bolt11.is_some());
+               assert!(create_order_response.payment.bolt12.is_some());
+               assert!(create_order_response.payment.onchain.is_some());

                let json_str = r#"{

Previously, bLIP-51 / LSPS1 only supported BOLT11 and onchain payment
options. Here we add the necessary fields to allow to pay the LSP via
BOLT12 offers.
@tnull tnull force-pushed the 2025-03-add-bolt12-support-for-blip-51 branch from 8505474 to 3274dbf Compare March 13, 2025 09:55
@tnull tnull requested review from TheBlueMatt and arik-so March 17, 2025 08:33
Copy link
Contributor

@arik-so arik-so left a comment

Choose a reason for hiding this comment

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

thanks for the bolt12 field check addition!

@tnull
Copy link
Contributor Author

tnull commented Mar 18, 2025

thanks for the bolt12 field check addition!

Sure! Going to land this, as ~trivial and the diff to previously-ACKed version is minimal.

@tnull tnull merged commit 9626561 into lightningdevkit:main Mar 18, 2025
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants