Skip to content

Preserve AddInvoiceData fields across invoice wrappers#268

Merged
starius merged 6 commits intolightninglabs:masterfrom
starius:addinvoice-hints
Apr 18, 2026
Merged

Preserve AddInvoiceData fields across invoice wrappers#268
starius merged 6 commits intolightninglabs:masterfrom
starius:addinvoice-hints

Conversation

@starius
Copy link
Copy Markdown
Contributor

@starius starius commented Apr 14, 2026

Summary

lightningClient.AddInvoice was silently dropping several fields from invoicesrpc.AddInvoiceData when building the outgoing lnrpc.Invoice request. That meant callers who set RouteHints, FallbackAddr, Amp, or BlindedPathCfg could get an invoice that ignored those settings.

This branch fixes AddInvoice to forward all applicable fields on the standard invoice path:

  • RouteHints
  • FallbackAddr
  • Amp
  • BlindedPathCfg (for the overlapping subset supported by the RPC)

It also cleans up hold-invoice semantics on that path. Hash and HodlInvoice are hold-invoice-specific inputs, so lightningClient now warns when they are passed and no longer forwards Hash into lnrpc.Invoice.RHash, which lnd documents as output-only.

For BlindedPathCfg, only MinNumPathHops can be represented through the standard RPC, so it is mapped to lnrpc.BlindedPathConfig.NumHops. Other blinded-path tuning fields (RoutePolicyIncrMultiplier, RoutePolicyDecrMultiplier, DefaultDummyHopPolicy) have no counterpart in the RPC proto, so the wrapper logs a warning and lnd falls back to its defaults for those.

As a follow-up for existing asymmetry, invoicesClient.AddHoldInvoice now also warns when callers pass Amp or BlindedPathCfg, since the hold-invoice RPC has no fields for them.

Test Plan

  • Extend TestLightningClientAddInvoice with direct regression coverage for: fallback address, AMP, hash/hodl inputs being ignored on the standard invoice path, blinded invoices, blinded invoices with MinNumPathHops == 0, and route hints.
  • Keep assertAddInvoiceArgs for field-by-field verification of the outgoing lnrpc.Invoice request.
  • Extend TestInvoiceClientAddInvoiceParity to compare all shared explicit fields between AddInvoice and AddHoldInvoice: Memo, ValueMsat, DescriptionHash, Expiry, FallbackAddr, CltvExpiry, Private, and RouteHints.
  • Use path-specific parity fixtures so Preimage and Hash are no longer set together in the same AddInvoiceData.
  • Add TestInvoicesClientAddHoldInvoiceIgnoresUnsupportedFields to document that AddHoldInvoice still forwards the supported request fields unchanged when unsupported Amp / BlindedPathCfg inputs are present.

Pull Request Checklist

  • PR is opened against correct version branch.
  • Version compatibility matrix in the README and minimal required version
    in lnd_services.go are updated.
  • Update macaroon_recipes.go if your PR adds a new method that is called
    differently than the RPC method it invokes.

starius added 6 commits April 14, 2026 18:49
Marshal explicit route hints in lightningClient.AddInvoice so the
standard invoice path matches AddHoldInvoice.

Add regression coverage for direct AddInvoice route hint encoding and
for route hint parity between AddInvoice and AddHoldInvoice.
Set FallbackAddr on the standard AddInvoice RPC request so the
lightning client preserves explicit on-chain fallback addresses.

Extend the existing invoice tests with direct AddInvoice coverage and
parity checks against AddHoldInvoice.
Set IsAmp on the standard AddInvoice RPC request so callers can
request AMP invoices through lightningClient.AddInvoice.

Extend the existing AddInvoice unit test to assert AMP invoice
requests preserve the flag on the outgoing RPC payload.
Stop forwarding Hash on the standard AddInvoice path and warn when
Hash or HodlInvoice are provided, since callers should use
InvoicesClient.AddHoldInvoice for hold invoices.

Extend the existing AddInvoice test to assert the standard invoice
request omits hold-invoice-only arguments.
Translate BlindedPathCfg into the standard AddInvoice RPC by setting
IsBlinded and forwarding MinNumPathHops as the compatible NumHops
override.

Warn when non-overlapping blinded path settings are provided, and
extend the AddInvoice unit test to assert blinded invoice requests
preserve the translated RPC fields.
Warn when AddHoldInvoice is called with Amp or BlindedPathCfg,
since the hold-invoice RPC cannot represent those inputs.

Add coverage to document that the wrapper still forwards the supported
request fields unchanged when those unsupported inputs are present.
@starius starius requested a review from hieblmi April 14, 2026 23:56
starius added a commit to starius/loop that referenced this pull request Apr 15, 2026
Include lightninglabs/lndclient#268
Preserve AddInvoiceData fields across invoice wrappers

TODO: remove go replace.
Copy link
Copy Markdown
Contributor

@hieblmi hieblmi left a comment

Choose a reason for hiding this comment

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

LGTM, the warnfs keep the changes backwards compatible!

Copy link
Copy Markdown
Member

@bhandras bhandras left a comment

Choose a reason for hiding this comment

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

LGTM, thank you! 🎉

@starius starius merged commit 1be689d into lightninglabs:master Apr 18, 2026
1 check passed
@starius starius deleted the addinvoice-hints branch April 18, 2026 02:29
@starius
Copy link
Copy Markdown
Contributor Author

starius commented Apr 18, 2026

Pushed tag v0.20.0-8 with this fix.

starius added a commit to starius/loop that referenced this pull request Apr 18, 2026
Include lightninglabs/lndclient#268
Preserve AddInvoiceData fields across invoice wrappers
hieblmi pushed a commit to hieblmi/loop that referenced this pull request May 5, 2026
Include lightninglabs/lndclient#268
Preserve AddInvoiceData fields across invoice wrappers
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.

3 participants