Skip to content

Add support for sending to human-readable names (BIP 353) #528

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

chuksys
Copy link

@chuksys chuksys commented Apr 22, 2025

This PR is a first step to add support for human-readable names as outlined in BIP 353 and implemented in LDK 0.1.

Refs #435

Changes

  1. A send_to_human_readable_name function was added under Bolt12Payment.
  2. A HrnBolt12Offer PaymentKind variant was added.
  3. A HrnParsingFailed Error variant was added.
  4. These new enum variants were added to the uniffi bindings.

I plan to follow up with a PR for #436 and another PR that will add HRN sending for on-chain payments.

chuksys added 4 commits April 21, 2025 11:20
…2 Offers

BIP 353 introduced human-readable names which has been implemented in LDK (0.1). This commit adds support for sending to HRNs that resolve to Bolt12 Offers by using the LDK pay_for_offer_from_human_readable_name method in ChannelManager.
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Apr 22, 2025

👋 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 ldk-reviews-bot requested a review from jkczyz April 22, 2025 00:52
Comment on lines +272 to +274
pub fn send_to_human_readable_name(
&self, name: &str, amount_msat: u64, dns_resolvers: Vec<Destination>,
) -> Result<PaymentId, Error> {
Copy link
Author

Choose a reason for hiding this comment

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

I should probably expose this method to uniffi bindings?

Also, for dns_resolvers maybe I should add a method in graph.rs which helps find all nodes that have a certain feature flag. This could make it simpler for the user to find all dns_resolver nodes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I should probably expose this method to uniffi bindings?

Yes, you'll need to expose this method and all types it requires.

Also, for dns_resolvers maybe I should add a method in graph.rs which helps find all nodes that have a certain feature flag. This could make it simpler for the user to find all dns_resolver nodes.

Yes, populating the list of default Destinations (see above) from the network graph is probably a good idea.

@tnull tnull requested review from tnull and removed request for jkczyz April 22, 2025 17:06
@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.

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.

Thanks for looking into this, and please excuse the delay here!

/// [HumanReadableName]: crate::lightning::onion_message::dns_resolution::HumanReadableName
/// [BIP 353]: https://github.com/bitcoin/bips/blob/master/bip-0353.mediawiki
/// [bLIP 32]: https://github.com/lightning/blips/blob/master/blip-0032.md
HrnBolt12Offer {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I'm not sure we want to add a separate PaymentKind variant for this. Likely it should just be a Bolt12Offer? In the upcoming 'payment metadata store' (see #425), we might then store the HRN as associated metadata though.

/// These nodes can be found by running a search through the `NetworkGraph` to find nodes that announce the
/// `dns_resolver` feature flag.
pub fn send_to_human_readable_name(
&self, name: &str, amount_msat: u64, dns_resolvers: Vec<Destination>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think rather then replicating LDK's API and have the user give the Destination for each send, in LDK Node we should probably allow users to set default DNS resolvers via the Builder and/or the Config. Here, we'd then error-out if the user didn't configure them upfront, and in the future we might be able to supply some default values.

Comment on lines +272 to +274
pub fn send_to_human_readable_name(
&self, name: &str, amount_msat: u64, dns_resolvers: Vec<Destination>,
) -> Result<PaymentId, Error> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I should probably expose this method to uniffi bindings?

Yes, you'll need to expose this method and all types it requires.

Also, for dns_resolvers maybe I should add a method in graph.rs which helps find all nodes that have a certain feature flag. This could make it simpler for the user to find all dns_resolver nodes.

Yes, populating the list of default Destinations (see above) from the network graph is probably a good idea.

@@ -429,6 +430,18 @@ impl UniffiCustomTypeConverter for DateTime {
}
}

impl UniffiCustomTypeConverter for HumanReadableName {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's avoid introducing yet another UniffiCustomTypeConverter for this, as we're actually currently working towards removing them for Bolt11Invoice, Offer, etc.

So we should just expose the HumanReadableName as a Uniffi interface, and if we find its API can't fully exposed, we'll need to create a type wrapper in uniffi_types.rs for it that is switched based on the uniffi flag (see #522 for reference).

@chuksys
Copy link
Author

chuksys commented Apr 30, 2025

Thank you for the feedback @tnull. I will address the comments and push the updated changes as soon as possible.

@sangbida
Copy link

sangbida commented May 5, 2025

Had a quick look at why some of the CI tests could be failing. I think the cln test is potentially failing because of the dnssec addition. The test env may need to be configured to support dnssec?

EDIT: Nevermind, I think this is the CLN issue: #527 The test seems to be flaky.

@chuksys
Copy link
Author

chuksys commented May 10, 2025

I will address the comments and push the updated changes as soon as possible.

Still actively working on this. Will push updates once I'm done (likely within the next week).

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