Skip to content

Refactor unified_qr.rs to use bitcoin-payment-instructions - #666

Merged
tnull merged 1 commit into
lightningdevkit:mainfrom
chuksys:refactor/adopt-bitcoin-payment-instructions
Jan 6, 2026
Merged

Refactor unified_qr.rs to use bitcoin-payment-instructions#666
tnull merged 1 commit into
lightningdevkit:mainfrom
chuksys:refactor/adopt-bitcoin-payment-instructions

Conversation

@chuksys

@chuksyschuksys commented Oct 16, 2025

Copy link
Copy Markdown
Contributor

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

ldk-reviews-bot commented Oct 16, 2025

Copy link
Copy Markdown

👋 Thanks for assigning @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

Copy link
Copy Markdown

🔔 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
Copy Markdown

🔔 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
Copy Markdown

🔔 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
Copy Markdown

🔔 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
Copy Markdown

🔔 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
Copy Markdown

🔔 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.

@tnulltnull left a comment

Copy link
Copy Markdown
Collaborator

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
chuksysforce-pushed the refactor/adopt-bitcoin-payment-instructions branch 2 times, most recently from 1e7d616 to 3e30347CompareNovember 2, 2025 22:28
@tnull

tnull commented Nov 3, 2025

Copy link
Copy Markdown
Collaborator

This need a rebase now.

@chuksys
chuksysforce-pushed the refactor/adopt-bitcoin-payment-instructions branch 2 times, most recently from a8ed274 to 4abb530CompareNovember 15, 2025 12:29

@tnulltnull left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment threadsrc/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
Copy Markdown
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?

Comment threadsrc/ffi/types.rs Outdated
}

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

Copy link
Copy Markdown
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?

Comment threadsrc/ffi/types.rs
self.inner.clone()
}

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

Copy link
Copy Markdown
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.

Comment threadsrc/payment/bolt12.rs
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
Copy Markdown
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.

Comment threadsrc/payment/unified.rs Outdated
},
};

if let Some(PaymentMethod::LightningBolt12(offer)) =

Copy link
Copy Markdown
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!`?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Seems this wasn't addressed?

@tnulltnull added this to the 0.8 milestone Nov 19, 2025
@chuksys
chuksysforce-pushed the refactor/adopt-bitcoin-payment-instructions branch 2 times, most recently from ac99cf6 to ed451bbCompareNovember 25, 2025 17:37
@chuksys

Copy link
Copy Markdown
ContributorAuthor

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

@chuksys
chuksysforce-pushed the refactor/adopt-bitcoin-payment-instructions branch 3 times, most recently from 9afbd37 to 71d7ef6CompareNovember 30, 2025 02:09
@chuksys

Copy link
Copy Markdown
ContributorAuthor

Currently fixing the issue that's making CI fail.

Fixed the issue. Current CI failure seems to be unrelated.

@chuksys
chuksys requested a review from tnullNovember 30, 2025 02:36
@ldk-reviews-bot

Copy link
Copy Markdown

🔔 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.

@chuksys
chuksysforce-pushed the refactor/adopt-bitcoin-payment-instructions branch from 71d7ef6 to 4265a63CompareDecember 3, 2025 13:13
@ldk-reviews-bot

Copy link
Copy Markdown

🔔 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
Copy Markdown

🔔 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
Copy Markdown

🔔 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
Copy Markdown

🔔 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.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 7th 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.

@tnulltnull left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this is finally unblocked. Please rebase and update the bitcoin-payment-instructions dependency.

Comment threadCargo.toml Outdated

vss-client = { package = "vss-client-ng", version = "0.4" }
prost = { version = "0.11.6", default-features = false}
#bitcoin-payment-instructions = { version = "0.5" }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

bitcoin-payment-instructions v0.6 has been released last week, please bump the dependency here and remove your fork.

Comment threadsrc/payment/unified.rs Outdated
//! [BIP 353]: https://github.com/bitcoin/bips/blob/master/bip-0353.mediawiki
//! [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md
//! [BOLT 12]: https://github.com/lightning/bolts/blob/master/12-offer-encoding.md
use crate::error::Error;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All these import reordering changes seem unrelated. Please drop them.

Comment threadsrc/payment/unified.rs Outdated
//! Holds a payment handler allowing to create [BIP 21] URIs with on-chain, [BOLT 11], and [BOLT 12] payment
//! options.
//!
//! Also allows to send payments using these URIs as well as [BIP 353] HRNs.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This sentence has a double 'also'/'as well as'. Should it just say 'Also allows to pay to [BIP 353] human readable names'?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This seems still unaddressed. Please spell out 'human readable names'.

Comment threadsrc/payment/unified.rs Outdated
/// Should be retrieved by calling [`Node::unified_qr_payment`]
/// Should be retrieved by calling [`Node::unified_payment`]
///
/// This handler allows you to send payments to these URIs as well as [BIP 353] HRNs.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same here, see comment above.

Comment threadsrc/payment/unified.rs Outdated
let uri: bip21::Uri<NetworkUnchecked, Extras> =
uri_str.parse().map_err(|_| Error::InvalidUri)?;

let _resolver = &self.hrn_resolver;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This seems unused?

Comment threadsrc/types.rs Outdated

use bitcoin::secp256k1::PublicKey;
use bitcoin::OutPoint;
use bitcoin_payment_instructions::onion_message_resolver::LDKOnionMessageDNSSECHrnResolver;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: Please maintain the import grouping here.

Comment threadsrc/payment/unified.rs Outdated
},
};

if let Some(PaymentMethod::LightningBolt12(offer)) =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Seems this wasn't addressed?

@chuksys
chuksysforce-pushed the refactor/adopt-bitcoin-payment-instructions branch 3 times, most recently from 4c098ca to 60b938bCompareDecember 16, 2025 13:12
@chuksys
chuksys requested a review from tnullDecember 18, 2025 11:08
@ldk-reviews-bot

Copy link
Copy Markdown

🔔 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
Copy Markdown

🔔 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
Copy Markdown

🔔 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
Copy Markdown

🔔 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
Copy Markdown

🔔 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
Copy Markdown

🔔 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.

@ldk-reviews-bot

Copy link
Copy Markdown

🔔 7th 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
Copy Markdown

🔔 8th 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.

@tnulltnull left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Generally looks good, but it seems some changes were squashed into entirely unrelated commits. Please either rewrite the commit history, or, as a last resort, just squash all in one commit to get this ready to be merged.

Comment threadsrc/payment/unified.rs Outdated
//! Holds a payment handler allowing to create [BIP 21] URIs with on-chain, [BOLT 11], and [BOLT 12] payment
//! options.
//!
//! Also allows to send payments using these URIs as well as [BIP 353] HRNs.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This seems still unaddressed. Please spell out 'human readable names'.

@chuksys
chuksysforce-pushed the refactor/adopt-bitcoin-payment-instructions branch 2 times, most recently from 6afa631 to b12347fCompareJanuary 5, 2026 20:36
@chuksys
chuksys requested a review from tnullJanuary 5, 2026 22:29

@tnulltnull left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There are still a few changes happening in the wrong/follow-up commits. Mind just squashing all into one so we can land this? I'll then address some of my outstanding minor comments myself in a quick follow-up PR if you don't mind.

//! Holds a payment handler allowing to create [BIP 21] URIs with on-chain, [BOLT 11], and [BOLT 12] payment
//! options.
//!
//! It also supports sending payments to these URIs as well as to [BIP 353] Human-Readable Names.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm confused: this was updated, but (here and elsewhere) still has the redundant "also .. to these URIs as well as" parts in it? The new changes also happen in the wrong (i.e., following commits).

Comment threadsrc/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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This still first exposes this as pub, only to change it again in a follow-up commit.

Comment threadtests/integration_tests_rust.rs Outdated

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn unified_qr_send_receive() {
async fn unified_send_receive_qr_uri() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not quite sure if that test name is much of an improvement? Do we even still want to refer to QR codes here if we otherwise stopped doing so?

}
}

/// Represents the result of a payment made using a [BIP 21] QR code.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure why this was dropped entirely instead of adjusting it to reflect the new role?

@chuksys
chuksysforce-pushed the refactor/adopt-bitcoin-payment-instructions branch from b12347f to ab230d6CompareJanuary 6, 2026 09:17
Refactor the unified_qr.rs module into unified.rs to provide a single
API for sending payments to BIP 21/321 URIs and BIP 353 HRNs. This
change simplifies the user interface by leveraging the
bitcoin-payment-instructions library for parsing.
Key changes:
- Rename UnifiedQrPayment to UnifiedPayment.
- Rename QRPaymentResult to UnifiedPaymentResult.
- Update the send method to support both URIs and HRNs.
- Update integration tests to match the new unified flow.
@chuksys
chuksysforce-pushed the refactor/adopt-bitcoin-payment-instructions branch from ab230d6 to d47958aCompareJanuary 6, 2026 09:20
@chuksys

Copy link
Copy Markdown
ContributorAuthor

There are still a few changes happening in the wrong/follow-up commits. Mind just squashing all into one so we can land this? I'll then address some of my outstanding minor comments myself in a quick follow-up PR if you don't mind.

Done! I've squashed the history into a single clean commit and updated the commit message to reflect the final state of the refactor. Ready for another look/merge.

CI failure seems unrelated

@chuksys
chuksys requested a review from tnullJanuary 6, 2026 09:41
@tnull
tnull merged commit 690d1f4 into lightningdevkit:mainJan 6, 2026
17 of 19 checks passed
@tnulltnull mentioned this pull request Jan 6, 2026
tnull added a commit that referenced this pull request Jan 9, 2026
Sign up for freeto 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

@chuksys@ldk-reviews-bot@tnull