Repository navigation
Conversation
`Bolt12Invoice::offer_id`, `Bolt12Invoice::payer_metadata`, and `Bolt11Invoice::payment_metadata` were only available to Rust users, so bindings users had to decode invoices themselves to associate them with offers or inspect their metadata. Expose these values through the existing invoice objects. Co-Authored-By: Codex
The bindings' `StaticInvoice` only exposed the amount, so bindings users receiving one with a successful payment could not inspect its offer identity, description, expiry, chain, or fallback addresses. Expose these fields along with the issuer, metadata, creation time, and signing keys, following the existing invoice getters. Co-Authored-By: Codex
Offer, refund, and invoice feature sets were only available to Rust users, so bindings users could not inspect their protocol capabilities or distinguish required features from optional ones. Expose the four feature contexts through UniFFI objects, using the same byte helpers and feature checks as the existing feature wrappers. Co-Authored-By: Codex
Bindings users could check whether an offer expects a quantity but could not discover its upper bound or distinguish an unbounded offer from one with a limit. Expose supported quantities on offers, BOLT12 invoices, and static invoices via an `OfferQuantity` enum. Preserve the distinction between an offer for one item and an explicit quantity limit of one. Co-Authored-By: Codex
|
👋 Thanks for assigning @ajaysehwal as a reviewer! |
e13a9cc to
1fe9efe
Compare
`Bolt12Invoice::is_for_offer`, `is_for_refund`, and `signature` were only available to Rust users, so bindings users could not directly classify an invoice or verify its signature despite having access to the signable hash and signing public key. Bindings users also lacked access to `StaticInvoice::signature`, despite being able to inspect its signing public key. Expose the origin checks and both invoice signatures through the existing invoice objects. Co-Authored-By: Codex
1fe9efe to
488e5be
Compare
| } | ||
|
|
||
| /// The chain that must be used when paying the invoice, as a chain hash. | ||
| pub fn chain(&self) -> Vec<u8> { |
There was a problem hiding this comment.
StaticInvoice::chain returns the raw chain hash bytes (like the existing Bolt12Invoice::chain), while Offer::chains/Refund::chain return Network. Would it be worth returning Option (or adding a network() helper) on the invoice types so that binding users get a typed value everywhere?
There was a problem hiding this comment.
Thank you see the commits below, I added fn network() -> Option<Network> to both invoice types, and made further cleanups to the bindings API
The same chain terminology means network enums on some bindings objects and raw hashes on others. Callers must learn each object's conventions just to identify its network. Typed network access should be predictable, without hiding chain identifiers the library does not recognize. Co-Authored-By: Codex
BOLT11 uses the same currency for Testnet and Testnet4, so its network getter cannot distinguish them. Without this limitation in the wrapper's documentation, callers may mistake the result for an exact network identification. Co-Authored-By: Codex
| } | ||
|
|
||
| /// The chains that may be used when paying a requested invoice, as chain hashes. | ||
| pub fn chains(&self) -> Vec<Vec<u8>> { |
There was a problem hiding this comment.
In v0.7.x, Offer::chains() returned sequence<Network> and Refund::chain() returned Network?. Here, the same methods now return raw chain hashes, with the old behavior moved to networks() and network().
For Swift/Kotlin, this causes a compile error, but in Python the change is silent. For example, Network.BITCOIN in offer.chains() or refund.chain() == Network.BITCOIN will now evaluate to false, so existing code could start rejecting valid offers or refunds without any obvious error.
I think chain = hash and network = Network is a good naming convention, but could we avoid reusing the old method names for a different return type? For example, use chain_hashes() and chain_hash() for the raw hash values, while keeping chains() and chain() backward-compatible. Was this rename intentional?
There was a problem hiding this comment.
Yes it was intentional, I prefer to break users in favor of a clean and predictable API across all types shipped in bindings. We can document the break clearly in the release notes.
| #[uniffi::export] | ||
| impl Refund { | ||
| /// Features pertaining to requesting an invoice for the refund. | ||
| pub fn features(&self) -> Arc<InvoiceRequestFeatures> { |
There was a problem hiding this comment.
I noticed that the other BOLT12 feature getters are named after what they return (offer_features, invoice_request_features, invoice_features). Since this also returns InvoiceRequestFeatures, would invoice_request_features() be clearer for users of the bindings than a generic features()? Happy to keep features() if matching LDK's naming is preferred.
There was a problem hiding this comment.
Yes I prefer to have the bindings closely follow the upstream code.
Bindings users could not inspect several offer and invoice properties already available to Rust users.