Skip to content

HRN: Emit new event type when Offer has been received and validated #3779

Closed

Description

@tnull

Currently, when using the ChannelManager::pay_for_offer_from_human_readable_name API, the user gets no access to the offer data retrieved. It would be great to add a new event type that is emitted when the offer has been retrieved and validated, e.g. here:

if let Some((completed_requests, mut offer)) = offer_opt {

Activity

  1. added
    good first issue
    on May 15, 2025
  2. TheBlueMatt commented on May 15, 2025

    @TheBlueMatt
    Collaborator

    Hmm, is there a reason you need the Offer directly or can you just access the offer fields via the Bolt12Invoice when the payment ultimately completes (which I believe was added upstream but is not in 0.1)?

  3. tnull commented on May 15, 2025

    @tnull
    ContributorAuthor

    Hmm, is there a reason you need the Offer directly or can you just access the offer fields via the Bolt12Invoice when the payment ultimately completes (which I believe was added upstream but is not in 0.1)?

    Hmm, IIUC, PaymentSent would only give us the Bolt12Invoice, which doesn't even expose OfferId, for instance. But more generally: the payment might very well fail and we'd still like to be able to fill in some of the metadata fields and maybe even retry using the Offer, which would save us multiple RTTs for resolving/retrieving the offer once more.

  4. chuksys commented on May 16, 2025

    @chuksys
    Contributor

    I'd like to pick this up.

  5. tnull commented on May 19, 2025

    @tnull
    ContributorAuthor

    I'd like to pick this up.

    Sure, go for it!

  6. TheBlueMatt commented on May 19, 2025

    @TheBlueMatt
    Collaborator

    Hmm, IIUC, PaymentSent would only give us the Bolt12Invoice, which doesn't even expose OfferId, for instance.

    that's easy to fix, though, and likely it should :).

    But more generally: the payment might very well fail and we'd still like to be able to fill in some of the metadata fields

    Hmm? Like what? I'm not really sure there's much to fill in from an Offer derived from an HRN - its really just a blinded path to request an Invoice?

    maybe even retry using the Offer, which would save us multiple RTTs for resolving/retrieving the offer once more.

    That's one RTT, but I guess I'm not clear on the point of that? Like, DNS should move pretty quick, hopefully, and if an Offer request times out its probably already retried a few times and we've waited a while. Adding one RTT on top of the retry seems perfectly fine?

  7. tnull commented on May 20, 2025

    @tnull
    ContributorAuthor

    That's one RTT, but I guess I'm not clear on the point of that? Like, DNS should move pretty quick, hopefully, and if an Offer request times out its probably already retried a few times and we've waited a while. Adding one RTT on top of the retry seems perfectly fine?

    The point is that we already retrieved the offer and still would have an entirely blank entry in the payment store even though we could provide the user additional metadata.

  8. TheBlueMatt commented on May 22, 2025

    @TheBlueMatt
    Collaborator

    Right, I guess I'm missing what that metadata is? Like, we can give the user an OfferId, but I'm not really sure if they care? They certainly care about OfferIds when they sent an offer and can use it to track the payment, but here they can't (they have to use the HRN - multiple HRNs can even resolve to the same Offer!). The Offer won't have an amount or much in it, or certainly shouldn't, so there shouldn't be any fields they care about in it.

  9. tnull commented on May 23, 2025

    @tnull
    ContributorAuthor

    Right, I guess I'm missing what that metadata is?

    Well, in LDK it would be all the fields of PaymentKind::Bolt12Offer, plus the actual Offer storage, which we're about to add support for currently.

    Like, we can give the user an OfferId, but I'm not really sure if they care? They certainly care about OfferIds when they sent an offer and can use it to track the payment, but here they can't (they have to use the HRN - multiple HRNs can even resolve to the same Offer!). The Offer won't have an amount or much in it, or certainly shouldn't, so there shouldn't be any fields they care about in it.

    Honestly, I'm not quite following why this is controversial at all? LDK retrieves the offer from DNS, why can't we give the user a way to access what we retrieved? FWIW, pay_for_offer_from_human_readable_name currently returns Result<(), ()> which gives the user 0 semantic feedback about what happend, what immediately succeeded/failed, what the OfferId is, etc. Of course, all of the protocol steps are happening async in the background, so we can only provide more information by emitting an event.

  10. TheBlueMatt commented on May 23, 2025

    @TheBlueMatt
    Collaborator

    its a question of what the API should look like so that there's a consistent view of what's going on - paying a BIP 353 isn't strictly just paying an offer, and to some extent I regret having a "pay for offer from BIP 353" method because a BIP 353 can also be on-chain but could also be silent payments or cashu or...

    Having an API where someone pastes in a human readable name and then expects to get back an OfferId or really any additional offer metadata seems really wrong to me - its just a payment, for an amount, with a fee. There may be some additional metadata, but tying it to offers specifically just feels totally wrong.

    I do kinda wonder if ldk-node shouldn't instead by using https://docs.rs/bitcoin-payment-instructions/ to parse these (which hopefully post-LDK-0.2 will support doing the DNS lookup over onion messages for privacy).

  11. tnull commented on May 26, 2025

    @tnull
    ContributorAuthor

    Having an API where someone pastes in a human readable name and then expects to get back an OfferId or really any additional offer metadata seems really wrong to me - its just a payment, for an amount, with a fee. There may be some additional metadata, but tying it to offers specifically just feels totally wrong.

    Well, I'd argue it's the other way around: we def. need to track the concrete payment, including all metadata the kind of payment supports (including things like Txid, OfferId, payment hash, etc., depending on what we use). So yes, assuming an HRN always resolves to an offer is wrong, but in LDK Node we'd track the concrete payment and attach the HRN metadata if the payment happens to be the result of a HRN resolution.

    I do kinda wonder if ldk-node shouldn't instead by using https://docs.rs/bitcoin-payment-instructions/ to parse these (which hopefully post-LDK-0.2 will support doing the DNS lookup over onion messages for privacy).

    Hmm, that might indeed make more sense, at least if we're then also committed to drop the pay_for_offer_from_hrn API from core LDK? And how would we deal with it in the meantime?

  12. ouchennnn commented on May 29, 2025

    @ouchennnn

    can I take this ?

  13. chuksys commented on May 29, 2025

    @chuksys
    Contributor

    can I take this ?

    Appreciate you looking into this! I've been monitoring this issue too, but I'm currently waiting for the maintainers to wrap up their discussion before starting any work. Happy to coordinate once they give the green light!

  14. tnull commented on May 30, 2025

    @tnull
    ContributorAuthor

    can I take this ?

    Thanks for your interest, but as @chuksys mentioned the discussion is just pending a final resolution, at which point it's already assigned to him. So feel free to look around for another open issue.

  15. TheBlueMatt commented on May 30, 2025

    @TheBlueMatt
    Collaborator

    Well, I'd argue it's the other way around: we def. need to track the concrete payment, including all metadata the kind of payment supports (including things like Txid, OfferId, payment hash, etc., depending on what we use). So yes, assuming an HRN always resolves to an offer is wrong, but in LDK Node we'd track the concrete payment and attach the HRN metadata if the payment happens to be the result of a HRN resolution.

    But what's the point of an id that only appears after the payment is halfway done? Txids obviously need to be tracked because the user will want to see them to get a link to a block explorer, similar to some extent with payment hash/preimage, but "offer ids" are an LDK-specific concept. IOW we need a "proof of payment" fetching API, but I'm not sure I see why someone would want a hash of the offer?

    Obviously there's a need for "payment ids" but in order to be useful they need to be static for the lifetime of the payment, not there halfway through.

  16. TheBlueMatt commented on May 30, 2025

    @TheBlueMatt
    Collaborator

    Hmm, that might indeed make more sense, at least if we're then also committed to drop the pay_for_offer_from_hrn API from core LDK? And how would we deal with it in the meantime?

    Don't think we're at a point where we're likely to drop that (maybe eventually but it'll be a while, incl we need the payment instructions crate to be able to use onion messages to resolve the DNS entry).

  17. tnull commented on Jun 3, 2025

    @tnull
    ContributorAuthor

    But what's the point of an id that only appears after the payment is halfway done?

    It won't be when it's half way done, it will be there when it's not even attempted yet.

    but "offer ids" are an LDK-specific concept.

    Yes, and they are the only way how user can associate payment (attempts) with offers.

    there's a need for "payment ids" but in order to be useful they need to be static for the lifetime of the payment

    We have that concept in place, but retrieving metadata/resolving the HRN is different from attempting the payment.

    I really think we should expose ways for users to access the current state across all the individual steps. We had the same conversation with BOLT12 to begin with, where the initially locked-down API was just insufficient. Going forward, we will need to be able to resolve the HRN, and then handle whatever it resolved to differently. So we need to expose whatever we resolved the HRN to to the user. As that thing is not part of the payment, it's the thing we need to start the payment. I guess if we won't expose that intermediate step in LDK raw, I might be tempted to reimplement HRN resolution in LDK Node itself.

  18. TheBlueMatt commented on Jun 13, 2025

    @TheBlueMatt
    Collaborator

    I really think we should expose ways for users to access the current state across all the individual steps. We had the same conversation with BOLT12 to begin with, where the initially locked-down API was just insufficient. Going forward, we will need to be able to resolve the HRN, and then handle whatever it resolved to differently. So we need to expose whatever we resolved the HRN to to the user. As that thing is not part of the payment, it's the thing we need to start the payment. I guess if we won't expose that intermediate step in LDK raw, I might be tempted to reimplement HRN resolution in LDK Node itself.

    Right, okay, so this is a somewhat separate usecase then I was thinking. IMO we should kinda rip the HRN -> offer stuff out of ChannelManager because, to your point, its too locked down to be useful. Rather than telling the user what the HRN resolves to, we should have them resolve it. I have some old code somewhere that would let bitcoin-payment-instructions do resolution over onion messages but it was blocked on some upstream changes I've long since lost. We should revive that work and encourage folks to use bitcoin-payment-instructions to resolve HRNs and then decide how to pay on their own.

  19. tnull commented on Jun 18, 2025

    @tnull
    ContributorAuthor

    Right, okay, so this is a somewhat separate usecase then I was thinking. IMO we should kinda rip the HRN -> offer stuff out of ChannelManager because, to your point, its too locked down to be useful. Rather than telling the user what the HRN resolves to, we should have them resolve it. I have some old code somewhere that would let bitcoin-payment-instructions do resolution over onion messages but it was blocked on some upstream changes I've long since lost. We should revive that work and encourage folks to use bitcoin-payment-instructions to resolve HRNs and then decide how to pay on their own.

    Hmm, okay. What does that mean concretely? Should I open a PR removing all the HRN-related stuff from lightning? If we would have resolution happen outside of lightning, what would be the interface to still make use of LDK's onion messenger for bLIP-32 though? Given this seems to be all a bunch of work, how would we bridge the time until all of this lands everywhere? Are we fine with intermittently not offering our users any way to resolve HRNs?

  20. tnull commented on Jun 25, 2025

    @tnull
    ContributorAuthor

    Gentle ping here, @TheBlueMatt

  21. tnull commented on Jul 1, 2025

    @tnull
    ContributorAuthor

    We now decided on not exposing additional information via a new event, but rather leveraging the changes in rust-bitcoin/bitcoin-payment-instructions#6 to allow LDK Node to use bitcoin-payment-instructions directly to resolve HRNs, and then take action depending on what they resolve to. I.e., we won't be using LDK's pay_for_offer_from_human_readable_name API for LDK Node HRN integration.

    Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

good first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions