Skip to content

Commit d546ffb

Browse files
Add utils for creating blinded PaymentParameters
1 parent 6b6d549 commit d546ffb

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

lightning/src/routing/router.rs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,32 @@ impl PaymentParameters {
634634
.expect("PaymentParameters::from_node_id should always initialize the payee as unblinded")
635635
}
636636

637-
/// Includes the payee's features. Errors if the parameters were initialized with blinded payment
638-
/// paths.
637+
/// Creates parameters for paying to a blinded payee.
638+
pub fn blinded(blinded_route_hints: Vec<(BlindedPayInfo, BlindedPath)>) -> Self {
639+
Self {
640+
payee: Payee::Blinded { route_hints: blinded_route_hints, features: None },
641+
expiry_time: None,
642+
max_total_cltv_expiry_delta: DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA,
643+
max_path_count: DEFAULT_MAX_PATH_COUNT,
644+
max_channel_saturation_power_of_half: 2,
645+
previously_failed_channels: Vec::new(),
646+
}
647+
}
648+
649+
/// Includes the payee's features. Errors if the parameters were not initialized with
650+
/// [`PaymentParameters::blinded`].
651+
///
652+
/// This is not exported to bindings users since bindings don't support move semantics
653+
pub fn with_bolt12_features(self, features: Bolt12InvoiceFeatures) -> Result<Self, ()> {
654+
match self.payee {
655+
Payee::Clear { .. } => Err(()),
656+
Payee::Blinded { route_hints, .. } =>
657+
Ok(Self { payee: Payee::Blinded { route_hints, features: Some(features) }, ..self })
658+
}
659+
}
660+
661+
/// Includes the payee's features. Errors if the parameters were initialized with
662+
/// [`PaymentParameters::blinded`].
639663
///
640664
/// This is not exported to bindings users since bindings don't support move semantics
641665
pub fn with_bolt11_features(self, features: InvoiceFeatures) -> Result<Self, ()> {
@@ -651,7 +675,7 @@ impl PaymentParameters {
651675
}
652676

653677
/// Includes hints for routing to the payee. Errors if the parameters were initialized with
654-
/// blinded payment paths.
678+
/// [`PaymentParameters::blinded`].
655679
///
656680
/// This is not exported to bindings users since bindings don't support move semantics
657681
pub fn with_route_hints(self, route_hints: Vec<RouteHint>) -> Result<Self, ()> {

0 commit comments

Comments
 (0)