Skip to content

Expose full per-payment sending parameters#829

Open
benthecarman wants to merge 2 commits intolightningdevkit:mainfrom
benthecarman:config-retry-timeout
Open

Expose full per-payment sending parameters#829
benthecarman wants to merge 2 commits intolightningdevkit:mainfrom
benthecarman:config-retry-timeout

Conversation

@benthecarman
Copy link
Contributor

@benthecarman benthecarman commented Mar 16, 2026

Previously only route parameters could be overridden on a per-payment basis. This PR makes the full set of LDK's optional payment parameters available to callers, allowing per-payment control over retry strategy, custom TLVs, and multi-wallet MPP splits in addition to route configuration. BOLT11 and BOLT12 get separate parameter types since they expose different fields. The node-wide retry strategy is also made configurable via Config.

This was something I needed when getting ldk-server working with loop. Also needed for orange for exposing the MPP override

@benthecarman benthecarman requested review from tankyleo and tnull March 16, 2026 17:36
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Mar 16, 2026

👋 I see @tankyleo was un-assigned.
If you'd like another reviewer assignment, please click here.

Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

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

An alternative would be to expose the Retry completely to allow for attempts based version as well. However, the timeout is generally simpler and more in line with what people expect.

If we do it, I'd lean towards exposing retry_strategy: Retry in the config. Should be even pretty easy to handle in bindings, as uniffi should now expose tuple enum variants.

@benthecarman benthecarman force-pushed the config-retry-timeout branch from 5af55c9 to 4ddeb92 Compare March 17, 2026 16:59
@benthecarman
Copy link
Contributor Author

If we do it, I'd lean towards exposing retry_strategy: Retry in the config. Should be even pretty easy to handle in bindings, as uniffi should now expose tuple enum variants.

done

@benthecarman benthecarman changed the title Make payment retry timeout configurable via Config Expose full payment retry strategy via Config Mar 17, 2026
/// See [`Retry`] for details.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
pub enum PaymentRetryStrategy {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than duplicating the object here, can't we reuse LDK's Retry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No we can't re-export it to the bindings because of the Duration inside.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, then it would be likely preferable to expose a remote type for Duration, too, rather than duplicating a lot of code?

Copy link
Contributor

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Would be nice if this were configurable per-payment rather than only globally, IMO.

@tnull
Copy link
Collaborator

tnull commented Mar 18, 2026

Would be nice if this were configurable per-payment rather than only globally, IMO.

Hmm, what would be the use case for having some payments diverge from the overall retry strategy? FWIW, I considered that before but decided somewhat that it's not worth complicating the API for, but happy to be convinced otherwise.

Replace the `payment_retry_timeout_secs` field with a `PaymentRetryStrategy`
enum that mirrors LDK's `Retry` type, allowing users to choose between
timeout-based and attempt-count-based retry strategies. Defaults to a
10-second timeout to preserve existing behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@benthecarman benthecarman force-pushed the config-retry-timeout branch from 4ddeb92 to 9bb440f Compare March 18, 2026 16:51
@benthecarman
Copy link
Contributor Author

Would be nice if this were configurable per-payment rather than only globally, IMO.

Imo if we are gonna make it on per payment, would make sense to expose all of OptionalBolt11PaymentParams which is probably worth doing. But I think allowing to change the default timeout still makes sense as well.

@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Replace per-payment `Option<RouteParametersConfig>` with dedicated
`Bolt11SendingParameters` and `Bolt12SendingParameters` structs that
expose the full LDK optional payment params (retry strategy, route
parameters, custom TLVs, MPP override) on a per-payment basis.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@benthecarman benthecarman changed the title Expose full payment retry strategy via Config Expose full per-payment sending parameters Mar 19, 2026
@benthecarman
Copy link
Contributor Author

Made it so we expose all the bolt 11/12 send params. It's about the same api complexity (a single optional struct) and will be useful for things like the mpp override that we need for orange

@tnull tnull removed the request for review from tankyleo March 19, 2026 08:56
Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

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

Made it so we expose all the bolt 11/12 send params. It's about the same api complexity (a single optional struct) and will be useful for things like the mpp override that we need for orange

Hmm, I have to say I'm not loving this. In the past we spent quite a bit of time to clean up and align BOLT11 and BOLT12 APIs (also opened upstream PRs etc) around sending_parameters/RouteParametersConfig, so I'd prefer not to simply 'give up', expose everything under the sun and have the APIs diverge a lot just because AI tooling now makes it very easy to generate a bunch of additional structs. If we think we need additional parameters, can we please first at least try to iterate upstream to keep BOLT11 and BOLT12 interfaces aligned and maintain feature parity?

/// See [`Retry`] for details.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
pub enum PaymentRetryStrategy {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, then it would be likely preferable to expose a remote type for Duration, too, rather than duplicating a lot of code?

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.

4 participants