Skip to content

Commit 3ca42ff

Browse files
committed
Rename sending_paramters_config field to sending_parameters
1 parent 4235a19 commit 3ca42ff

File tree

5 files changed

+22
-34
lines changed

5 files changed

+22
-34
lines changed

bindings/ldk_node.udl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dictionary Config {
1616
u64 probing_liquidity_limit_multiplier;
1717
LogLevel log_level;
1818
AnchorChannelsConfig? anchor_channels_config;
19-
SendingParameters? sending_parameters_config;
19+
SendingParameters? sending_parameters;
2020
};
2121

2222
dictionary AnchorChannelsConfig {

src/config.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ pub(crate) const WALLET_KEYS_SEED_LEN: usize = 64;
8888
/// | `probing_liquidity_limit_multiplier` | 3 |
8989
/// | `log_level` | Debug |
9090
/// | `anchor_channels_config` | Some(..) |
91-
/// | `sending_parameters_config` | None |
91+
/// | `sending_parameters` | None |
9292
///
93-
/// See [`AnchorChannelsConfig`] for more information on its respective default values.
93+
/// See [`AnchorChannelsConfig`] and [`SendingParameters`] for more information regarding their
94+
/// respective default values.
9495
///
9596
/// [`Node`]: crate::Node
9697
pub struct Config {
@@ -150,12 +151,14 @@ pub struct Config {
150151
/// closure. We *will* however still try to get the Anchor spending transactions confirmed
151152
/// on-chain with the funds available.
152153
pub anchor_channels_config: Option<AnchorChannelsConfig>,
153-
154154
/// Configuration options for payment routing and pathfinding.
155155
///
156156
/// Setting the `SendingParameters` provides flexibility to customize how payments are routed,
157157
/// including setting limits on routing fees, CLTV expiry, and channel utilization.
158-
pub sending_parameters_config: Option<SendingParameters>,
158+
///
159+
/// **Note:** If unset, default parameters will be used, and you will be able to override the
160+
/// parameters on a per-payment basis in the corresponding method calls.
161+
pub sending_parameters: Option<SendingParameters>,
159162
}
160163

161164
impl Default for Config {
@@ -173,7 +176,7 @@ impl Default for Config {
173176
probing_liquidity_limit_multiplier: DEFAULT_PROBING_LIQUIDITY_LIMIT_MULTIPLIER,
174177
log_level: DEFAULT_LOG_LEVEL,
175178
anchor_channels_config: Some(AnchorChannelsConfig::default()),
176-
sending_parameters_config: None,
179+
sending_parameters: None,
177180
}
178181
}
179182
}

src/payment/bolt11.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ impl Bolt11Payment {
7171

7272
/// Send a payment given an invoice.
7373
///
74-
/// If [`SendingParameters`] are provided they will override the node's default routing parameters
75-
/// on a per-field basis. Each field in `SendingParameters` that is set replaces the corresponding
76-
/// default value. Fields that are not set fall back to the node's configured defaults. If no
77-
/// `SendingParameters` are provided, the method fully relies on these defaults.
74+
/// If `sending_parameters` are provided they will override the default as well as the
75+
/// node-wide parameters configured via [`Config::sending_parameters`] on a per-field basis.
7876
pub fn send(
7977
&self, invoice: &Bolt11Invoice, sending_parameters: Option<SendingParameters>,
8078
) -> Result<PaymentId, Error> {
@@ -99,9 +97,7 @@ impl Bolt11Payment {
9997
}
10098

10199
if let Some(user_set_params) = sending_parameters {
102-
if let Some(mut default_params) =
103-
self.config.sending_parameters_config.as_ref().cloned()
104-
{
100+
if let Some(mut default_params) = self.config.sending_parameters.as_ref().cloned() {
105101
default_params.max_total_routing_fee_msat = user_set_params
106102
.max_total_routing_fee_msat
107103
.or(default_params.max_total_routing_fee_msat);
@@ -122,7 +118,7 @@ impl Bolt11Payment {
122118
route_params.payment_params.max_channel_saturation_power_of_half =
123119
default_params.max_channel_saturation_power_of_half.unwrap_or_default();
124120
}
125-
} else if let Some(default_params) = &self.config.sending_parameters_config {
121+
} else if let Some(default_params) = &self.config.sending_parameters {
126122
route_params.max_total_routing_fee_msat = default_params.max_total_routing_fee_msat;
127123
route_params.payment_params.max_total_cltv_expiry_delta =
128124
default_params.max_total_cltv_expiry_delta.unwrap_or_default();
@@ -197,10 +193,8 @@ impl Bolt11Payment {
197193
/// This can be used to pay a so-called "zero-amount" invoice, i.e., an invoice that leaves the
198194
/// amount paid to be determined by the user.
199195
///
200-
/// If [`SendingParameters`] are provided they will override the node's default routing parameters
201-
/// on a per-field basis. Each field in `SendingParameters` that is set replaces the corresponding
202-
/// default value. Fields that are not set fall back to the node's configured defaults. If no
203-
/// `SendingParameters` are provided, the method fully relies on these defaults.
196+
/// If `sending_parameters` are provided they will override the default as well as the
197+
/// node-wide parameters configured via [`Config::sending_parameters`] on a per-field basis.
204198
pub fn send_using_amount(
205199
&self, invoice: &Bolt11Invoice, amount_msat: u64,
206200
sending_parameters: Option<SendingParameters>,
@@ -248,9 +242,7 @@ impl Bolt11Payment {
248242
RouteParameters::from_payment_params_and_value(payment_params, amount_msat);
249243

250244
if let Some(user_set_params) = sending_parameters {
251-
if let Some(mut default_params) =
252-
self.config.sending_parameters_config.as_ref().cloned()
253-
{
245+
if let Some(mut default_params) = self.config.sending_parameters.as_ref().cloned() {
254246
default_params.max_total_routing_fee_msat = user_set_params
255247
.max_total_routing_fee_msat
256248
.or(default_params.max_total_routing_fee_msat);
@@ -271,7 +263,7 @@ impl Bolt11Payment {
271263
route_params.payment_params.max_channel_saturation_power_of_half =
272264
default_params.max_channel_saturation_power_of_half.unwrap_or_default();
273265
}
274-
} else if let Some(default_params) = &self.config.sending_parameters_config {
266+
} else if let Some(default_params) = &self.config.sending_parameters {
275267
route_params.max_total_routing_fee_msat = default_params.max_total_routing_fee_msat;
276268
route_params.payment_params.max_total_cltv_expiry_delta =
277269
default_params.max_total_cltv_expiry_delta.unwrap_or_default();

src/payment/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub use spontaneous::SpontaneousPayment;
1414
pub use store::{LSPFeeLimits, PaymentDetails, PaymentDirection, PaymentKind, PaymentStatus};
1515
pub use unified_qr::{QrPaymentResult, UnifiedQrPayment};
1616

17-
/// Represents information used to route a payment.
17+
/// Represents information used to send a payment.
1818
#[derive(Clone, Debug, PartialEq)]
1919
pub struct SendingParameters {
2020
/// The maximum total fees, in millisatoshi, that may accrue during route finding.
@@ -24,21 +24,18 @@ pub struct SendingParameters {
2424
///
2525
/// Note that values below a few sats may result in some paths being spuriously ignored.
2626
pub max_total_routing_fee_msat: Option<u64>,
27-
2827
/// The maximum total CLTV delta we accept for the route.
2928
///
3029
/// Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`].
3130
///
3231
/// [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]: lightning::routing::router::DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA
3332
pub max_total_cltv_expiry_delta: Option<u32>,
34-
3533
/// The maximum number of paths that may be used by (MPP) payments.
3634
///
3735
/// Defaults to [`DEFAULT_MAX_PATH_COUNT`].
3836
///
3937
/// [`DEFAULT_MAX_PATH_COUNT`]: lightning::routing::router::DEFAULT_MAX_PATH_COUNT
4038
pub max_path_count: Option<u8>,
41-
4239
/// Selects the maximum share of a channel's total capacity which will be sent over a channel,
4340
/// as a power of 1/2.
4441
///

src/payment/spontaneous.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ impl SpontaneousPayment {
4444

4545
/// Send a spontaneous aka. "keysend", payment.
4646
///
47-
/// If [`SendingParameters`] are provided they will override the node's default routing parameters
48-
/// on a per-field basis. Each field in `SendingParameters` that is set replaces the corresponding
49-
/// default value. Fields that are not set fall back to the node's configured defaults. If no
50-
/// `SendingParameters` are provided, the method fully relies on these defaults.
47+
/// If `sending_parameters` are provided they will override the default as well as the
48+
/// node-wide parameters configured via [`Config::sending_parameters`] on a per-field basis.
5149
pub fn send(
5250
&self, amount_msat: u64, node_id: PublicKey, sending_parameters: Option<SendingParameters>,
5351
) -> Result<PaymentId, Error> {
@@ -75,9 +73,7 @@ impl SpontaneousPayment {
7573
);
7674

7775
if let Some(user_set_params) = sending_parameters {
78-
if let Some(mut default_params) =
79-
self.config.sending_parameters_config.as_ref().cloned()
80-
{
76+
if let Some(mut default_params) = self.config.sending_parameters.as_ref().cloned() {
8177
default_params.max_total_routing_fee_msat = user_set_params
8278
.max_total_routing_fee_msat
8379
.or(default_params.max_total_routing_fee_msat);
@@ -98,7 +94,7 @@ impl SpontaneousPayment {
9894
route_params.payment_params.max_channel_saturation_power_of_half =
9995
default_params.max_channel_saturation_power_of_half.unwrap_or_default();
10096
}
101-
} else if let Some(default_params) = &self.config.sending_parameters_config {
97+
} else if let Some(default_params) = &self.config.sending_parameters {
10298
route_params.max_total_routing_fee_msat = default_params.max_total_routing_fee_msat;
10399
route_params.payment_params.max_total_cltv_expiry_delta =
104100
default_params.max_total_cltv_expiry_delta.unwrap_or_default();

0 commit comments

Comments
 (0)