Skip to content

feat: allow overriding route hints in BOLT11 invoice creation - #1

Merged
kaloudis merged 2 commits into
ZeusLN:lsps7-for-ldk-node-close-fixfrom
ajaysehwal:feat/custom-routing-hints
Jul 27, 2026
Merged

feat: allow overriding route hints in BOLT11 invoice creation#1
kaloudis merged 2 commits into
ZeusLN:lsps7-for-ldk-node-close-fixfrom
ajaysehwal:feat/custom-routing-hints

Conversation

@ajaysehwal

@ajaysehwal ajaysehwal commented Jul 23, 2026

Copy link
Copy Markdown

Summary

Adds route_hints_override to Bolt11InvoiceParameters, allowing callers of ChannelManager::create_bolt11_invoice to control which route hints are embedded in a BOLT11 invoice.
Today, create_bolt11_invoice always derives route hints automatically from local channels via sort_and_filter_channels. That works for the common case, but leaves no way to:

  • supply custom or multi-hop route hints,
  • pin a specific inbound channel (e.g. a preferred LSP),
  • or omit route hints entirely when the payer already knows how to reach the node.
    This change adds an optional override while preserving existing default behavior.

Changes

  • Add route_hints_override: Option<Vec<RouteHint>> to Bolt11InvoiceParameters.
  • Update create_bolt11_invoice to branch on the new field:
    • None — existing behavior: select hints from eligible local channels via sort_and_filter_channels.
    • Some(vec![]) — include no route hints in the invoice.
    • Some(hints) — use the provided hints as-is.
  • Import RouteHint in channelmanager.rs.

API

let params = Bolt11InvoiceParameters {
    amount_msats: Some(10_000),
    route_hints_override: Some(vec![custom_hint]),
    ..Default::default()
};
let invoice = channel_manager.create_bolt11_invoice(params)?;
When route_hints_override is unset (the default), behavior is unchanged from before this PR.

Backward compatibility
Fully backward compatible. route_hints_override defaults to None, and existing callers using Bolt11InvoiceParameters::default() or ..Default::default() continue to get automatic route hint selection with no code changes.

@ajaysehwal
ajaysehwal marked this pull request as ready for review July 23, 2026 14:05

@kaloudis kaloudis left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Logic looks correct. The three states (None / Some(vec![]) / Some(hints)) are handled cleanly and default behavior is preserved. Note the CI failures are all pre-existing on the base branch (lsps7 rustfmt/clippy, runner issues); nothing flags this diff, and the stable builds pass.

Could you add test coverage for the three states? e.g. None -> auto hints unchanged, Some(vec![]) -> no private routes in the invoice, Some(custom) -> invoice contains exactly the provided hints.

Comment thread lightning/src/ln/channelmanager.rs Outdated
Comment thread lightning/src/ln/channelmanager.rs Outdated
@ajaysehwal
ajaysehwal force-pushed the feat/custom-routing-hints branch from bb5ea58 to 2bd906e Compare July 25, 2026 15:19
@ajaysehwal
ajaysehwal requested a review from kaloudis July 25, 2026 15:19
@kaloudis
kaloudis merged commit a7fa715 into ZeusLN:lsps7-for-ldk-node-close-fix Jul 27, 2026
5 of 17 checks passed
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.

2 participants