Skip to content

Conversation

@chuksys
Copy link
Contributor

@chuksys chuksys commented Oct 16, 2025

This PR is a continuation of #607 which was closed mistakenly when the develop base branch was deleted.

This PR introduces a unified.rs module (which is a refactor of the unified_qr.rs module) - this refactor allows us to use this module as a single API for sending payments to BIP 21/321 URIs as well as BIP 353 HRNs, creating a simpler interface for users.

https://github.com/rust-bitcoin/bitcoin-payment-instructions is used to parse BIP 21/321 URIs as well as the BIP 353 HRNs.

Changes

  • The unified_qr.rs module has been renamed to unified.rs.
  • The UnifiedQrPayment struct has been renamed to UnifiedPayment.
  • The QRPaymentResult enum has been renamed to UnifiedPaymentResult.
  • The send method in unified.rs now supports sending to both BIP 21/321 URIs as well as BIP 353 HRNs.
  • The integration tests for the module have been updated accordingly.

This PR closes #521 and #435

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Oct 16, 2025

I've assigned @tnull 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.

@ldk-reviews-bot ldk-reviews-bot requested a review from tnull October 16, 2025 14:09
@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 2nd Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 3rd Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 4th Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 5th Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 6th Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

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.

This needs a rebase by now, sorry!

@chuksys chuksys force-pushed the refactor/adopt-bitcoin-payment-instructions branch 2 times, most recently from 1e7d616 to 3e30347 Compare November 2, 2025 22:28
@tnull
Copy link
Collaborator

tnull commented Nov 3, 2025

This need a rebase now.

@chuksys chuksys force-pushed the refactor/adopt-bitcoin-payment-instructions branch 2 times, most recently from a8ed274 to 4abb530 Compare November 15, 2025 12:29
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.

Alright, now that we published v0.7.0-rc.0 and branched off release/0.7 we should ready to move forward with this as soon as bitcoin-payment-instructions supporting the new LDK version is released.

To this end, please rebase this PR and clean up the commit history. In particular, please avoid line wrapping for the first line in the commit description and also clearly describe the what, how and why for each change in the commit descriptions. Please refer to https://cbea.ms/git-commit/ for guidance on how to write good commit messages.

src/ffi/types.rs Outdated
pub use crate::payment::QrPaymentResult;
pub use crate::payment::UnifiedPaymentResult;

pub use lightning::onion_message::dns_resolution::HumanReadableName as LdkHumanReadableName;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we want to expose the LdkHumanReadableName variant, this is just an internal type alias, no?

src/ffi/types.rs Outdated
}

impl HumanReadableName {
pub fn into_inner(&self) -> LdkHumanReadableName {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This shouldn't be pub, and I think we can simply inline this into impl From<HumanReadableName> for LdkHumanReadableName?

self.inner.clone()
}

pub fn from_encoded(encoded: &str) -> Result<Self, Error> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please provide docs on all public methods. Feel free to copy them over from the LDK counterpart.

pub fn send_using_amount(
&self, offer: &Offer, amount_msat: u64, quantity: Option<u64>, payer_note: Option<String>,
route_parameters: Option<RouteParametersConfig>,
route_parameters: Option<RouteParametersConfig>, hrn: Option<HumanReadableName>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we should change the public API here. Please create a pub(crate) send_using_amount_inner method that you can use here and that is simply used with None for the hrn parameter here in send_using_amount.

},
};

if let Some(PaymentMethod::LightningBolt12(offer)) =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not simply use a match instead of if let Some(..) = .. matches!`?

@tnull tnull added this to the 0.8 milestone Nov 19, 2025
Rename the source file for the Unified QR payment logic from
unified_qr.rs to unified.rs. This change is made in preparation
for expanding the module's scope beyond just QR code payment
processing.
Rename the primary payment handler struct from UnifiedQRPayment to
UnifiedPayment. Also rename QRPaymentResult to
UnifiedPaymentResult. This change aligns with the prior module rename
and reflects that the component handles a broader range of payment inputs.
Introduce the bitcoin-payment-instructions library as a dependency
in Cargo.toml. This library provides the necessary types and parsing logic
to handle BIP 21 URIs and BIP 353 HRNs.
Introduce the hrn_resolver dependency into the main Node struct and
plumb it through to the UnifiedPayment component. This is necessary to
allow the node to resolve offers presented via a Human-Readable Name (HRN).
Restructure the payment initiation logic in unified.rs to handle both BIP 21
URIs and BIP 353 Human-Readable Names (HRNs) as input sources. This
provides a single, unified entry point for initiating payments.
Correct a minor typo in the unified_payment send test. The test name is
also updated to be more descriptive of the behavior being validated.
Switch the module tests within unified.rs to use explicit use statements
instead of glob imports (*). This improves code clarity by clearly indicating
which items are being brought into scope.
@chuksys chuksys force-pushed the refactor/adopt-bitcoin-payment-instructions branch from 4abb530 to ac99cf6 Compare November 25, 2025 17:29
Adopt the upstream LDK change to use the dedicated
pay_for_offer_from_hrn method when initiating a payment for an offer
resolved via a Human-Readable Name (HRN). This ensures better alignment
with LDK best practices.
@chuksys chuksys force-pushed the refactor/adopt-bitcoin-payment-instructions branch from ac99cf6 to ed451bb Compare November 25, 2025 17:37
@chuksys
Copy link
Contributor Author

chuksys commented Nov 25, 2025

Just pushed some changes. Currently fixing the issue that's making CI fail.

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.

Switch to use bitcoin-payment-instructions

3 participants