Skip to content

Commit 5fe90d1

Browse files
committed
Introduce SendingParameters struct
`SendingParameters` allows users to override opinionated values while routing a payment such as `max_total_routing_fees`, `max_path_count` `max_total_cltv_delta`, and `max_channel_saturation_power_of_half` Updated docs for `max_channel_saturation_power_of_half` for clarity.
1 parent e233188 commit 5fe90d1

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

bindings/ldk_node.udl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,13 @@ dictionary PaymentDetails {
319319
u64 latest_update_timestamp;
320320
};
321321

322+
dictionary SendingParameters {
323+
u64? max_total_routing_fee_msat;
324+
u32? max_total_cltv_expiry_delta;
325+
u8? max_path_count;
326+
u8? max_channel_saturation_power_of_half;
327+
};
328+
322329
[NonExhaustive]
323330
enum Network {
324331
"Bitcoin",

src/payment/mod.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,52 @@ pub use onchain::OnchainPayment;
1313
pub use spontaneous::SpontaneousPayment;
1414
pub use store::{LSPFeeLimits, PaymentDetails, PaymentDirection, PaymentKind, PaymentStatus};
1515
pub use unified_qr::{QrPaymentResult, UnifiedQrPayment};
16+
17+
/// Represents information used to route a payment.
18+
#[derive(Clone, Debug, PartialEq)]
19+
pub struct SendingParameters {
20+
/// The maximum total fees, in millisatoshi, that may accrue during route finding.
21+
///
22+
/// This limit also applies to the total fees that may arise while retrying failed payment
23+
/// paths.
24+
///
25+
/// Note that values below a few sats may result in some paths being spuriously ignored.
26+
pub max_total_routing_fee_msat: Option<u64>,
27+
28+
/// The maximum total CLTV delta we accept for the route.
29+
///
30+
/// Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`].
31+
///
32+
/// [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]: lightning::routing::router::DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA
33+
pub max_total_cltv_expiry_delta: Option<u32>,
34+
35+
/// The maximum number of paths that may be used by (MPP) payments.
36+
///
37+
/// Defaults to [`DEFAULT_MAX_PATH_COUNT`].
38+
///
39+
/// [`DEFAULT_MAX_PATH_COUNT`]: lightning::routing::router::DEFAULT_MAX_PATH_COUNT
40+
pub max_path_count: Option<u8>,
41+
42+
/// Selects the maximum share of a channel's total capacity which will be sent over a channel,
43+
/// as a power of 1/2.
44+
///
45+
/// A higher value prefers to send the payment using more MPP parts whereas
46+
/// a lower value prefers to send larger MPP parts, potentially saturating channels and
47+
/// increasing failure probability for those paths.
48+
///
49+
/// Note that this restriction will be relaxed during pathfinding after paths which meet this
50+
/// restriction have been found. While paths which meet this criteria will be searched for, it
51+
/// is ultimately up to the scorer to select them over other paths.
52+
///
53+
/// Examples:
54+
///
55+
/// | Value | Max Proportion of Channel Capacity Used |
56+
/// |-------|-----------------------------------------|
57+
/// | 0 | Up to 100% of the channel’s capacity |
58+
/// | 1 | Up to 50% of the channel’s capacity |
59+
/// | 2 | Up to 25% of the channel’s capacity |
60+
/// | 3 | Up to 12.5% of the channel’s capacity |
61+
///
62+
/// Default value: 2
63+
pub max_channel_saturation_power_of_half: Option<u8>,
64+
}

src/uniffi_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
pub use crate::graph::{ChannelInfo, ChannelUpdateInfo, NodeAnnouncementInfo, NodeInfo};
77
pub use crate::payment::store::{LSPFeeLimits, PaymentDirection, PaymentKind, PaymentStatus};
8-
pub use crate::payment::QrPaymentResult;
8+
pub use crate::payment::{QrPaymentResult, SendingParameters};
99

1010
pub use lightning::events::{ClosureReason, PaymentFailureReason};
1111
pub use lightning::ln::{ChannelId, PaymentHash, PaymentPreimage, PaymentSecret};

0 commit comments

Comments
 (0)