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

Expand InputType with new variant: Bolt12 offer #1121

Merged
merged 12 commits into from
Nov 19, 2024

Conversation

ok300
Copy link
Contributor

@ok300 ok300 commented Nov 10, 2024

This PR extends the input parsed in sdk-common to recognize Bolt12 offers.

@ok300
Copy link
Contributor Author

ok300 commented Nov 10, 2024

@hydra-yse your older PR #598 parses the offer to more detailed fields:

[Enum]
interface Amount {
Bitcoin(u64 amount_msat);
Currency(string iso4217_code, u64 fractional_amount);
};
dictionary LNOffer {
string bolt12;
sequence<string> chains;
string description;
string signing_pubkey;
Amount? amount;
u64? absolute_expiry;
string? issuer;
};
[Enum]
interface InputType {
BitcoinAddress(BitcoinAddressData address);
Bolt11(LNInvoice invoice);
Bolt12Offer(LNOffer offer);

As that PR is still in review, I'm not sure if that structure is final (LNOffer, InputType::Bolt12Offer(LNOffer offer)).

So would you say we need those fields as defined there? If so, I can integrate them in this PR.

@ok300 ok300 requested review from roeierez and hydra-yse November 10, 2024 10:16
@ok300 ok300 force-pushed the ok300-sdk-common-parse-bolt12-offer branch from 6508e80 to fa01549 Compare November 10, 2024 10:18
@ok300 ok300 requested a review from dangeross November 10, 2024 10:18
@dangeross
Copy link
Collaborator

So would you say we need those fields as defined there? If so, I can integrate them in this PR

I think they are needed, we need to parse the offer for the user. I also think our PR struct is out of date and I would suggest bumping the lightning/lightning-invoice dependencies. The current version doesn't parse offers according to the latest spec (e.g. the description field is now optional), which I think is not compatible with Phoenix

@JssDWt
Copy link
Contributor

JssDWt commented Nov 11, 2024

As that PR is still in review, I'm not sure if that structure is final (LNOffer, InputType::Bolt12Offer(LNOffer offer)).

So would you say we need those fields as defined there? If so, I can integrate them in this PR.

Also keep in mind there are invoice requests and invoices in bolt12, next to offers. We don't have to support them, but let's make the interface in such a way that we don't have to break anything to support them in the future.

@ok300
Copy link
Contributor Author

ok300 commented Nov 12, 2024

I tried to bump lightning and lightning-invoice as suggested above. Indeed we would need them to support optional descriptions, like in the Bolt12 invoices from Boltz.

However due to inter-dependencies between crates, this means also updating bech32, bip21, bitcoin crates. This results in two problems:

  • The change becomes huge (>100 individual errors) and it needs careful review and extensive tests because it touches critical places.
  • There appear to be unfixable conflicts with structs and methods used in node_api.rs, since it relies on the old (current) lightning, lightning_invoice and bitcoin versions to interface with gl-client.

(This is reflected in the last commit f0d19cc . Almost half the errors are fixed, but I stopped when realizing the node_api issue.)

The only way to avoid the above is to store the unparsed Bolt12 option as String in the InputParser::Bolt12 variant.

Another option is to ask GL to update their lightning, lightning-invoice and bitcoin crates to the newer ones we would use, but I don't know how feasible that is.

Am I missing something? Do you see a simpler way to bump lightning and lightning-invoice?

@ok300 ok300 force-pushed the ok300-sdk-common-parse-bolt12-offer branch from f0d19cc to a8a7057 Compare November 13, 2024 08:40
@ok300
Copy link
Contributor Author

ok300 commented Nov 13, 2024

As discussed, this is adding a simple Bolt12Offer { offer: String } variant, until gl-client supports the newer lightning and lightning-invoice crates.

In addition, Liquid SDK will attempt to parse the offer locally.

@ok300 ok300 force-pushed the ok300-sdk-common-parse-bolt12-offer branch from a8a7057 to c7abd3d Compare November 13, 2024 13:13
libs/sdk-common/src/invoice.rs Show resolved Hide resolved
libs/sdk-common/src/invoice.rs Show resolved Hide resolved
libs/sdk-common/src/invoice.rs Outdated Show resolved Hide resolved
@ok300 ok300 requested a review from dangeross November 14, 2024 13:33
Copy link
Collaborator

@dangeross dangeross left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@hydra-yse hydra-yse left a comment

Choose a reason for hiding this comment

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

Should we also add parsing for recurrence- and quantity based fields, or are those outside the scope of what will be used? Perhaps they can be added later as they seem useless for now. Besides that, looking good! 👍

@ok300
Copy link
Contributor Author

ok300 commented Nov 18, 2024

IMO it's best to add them when they will also be tested and used.

This helps circumvent an uniffi issue where sequence<LNOfferBlindedPath> fails to parse but sequence<LnOfferBlindedPath> is fine.
@ok300 ok300 merged commit 5955216 into main Nov 19, 2024
9 checks passed
erdemyerebasmaz pushed a commit that referenced this pull request Nov 26, 2024
Expand InputType with new variant: Bolt12 offer
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.

5 participants