Skip to content

Commit 5c31700

Browse files
Make create_blinded_payment_paths methods amount optional.
Useful for creating payment paths for static invoices which are typically amount-less.
1 parent c6738c1 commit 5c31700

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl Router for FuzzRouter {
127127

128128
fn create_blinded_payment_paths<T: secp256k1::Signing + secp256k1::Verification>(
129129
&self, _recipient: PublicKey, _first_hops: Vec<ChannelDetails>, _tlvs: ReceiveTlvs,
130-
_amount_msats: u64, _secp_ctx: &Secp256k1<T>,
130+
_amount_msats: Option<u64>, _secp_ctx: &Secp256k1<T>,
131131
) -> Result<Vec<BlindedPaymentPath>, ()> {
132132
unreachable!()
133133
}

fuzz/src/full_stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl Router for FuzzRouter {
162162

163163
fn create_blinded_payment_paths<T: secp256k1::Signing + secp256k1::Verification>(
164164
&self, _recipient: PublicKey, _first_hops: Vec<ChannelDetails>, _tlvs: ReceiveTlvs,
165-
_amount_msats: u64, _secp_ctx: &Secp256k1<T>,
165+
_amount_msats: Option<u64>, _secp_ctx: &Secp256k1<T>,
166166
) -> Result<Vec<BlindedPaymentPath>, ()> {
167167
unreachable!()
168168
}

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9748,7 +9748,7 @@ where
97489748
Ok((payment_hash, payment_secret)) => {
97499749
let payment_context = PaymentContext::Bolt12Refund(Bolt12RefundContext {});
97509750
let payment_paths = self.create_blinded_payment_paths(
9751-
amount_msats, payment_secret, payment_context
9751+
Some(amount_msats), payment_secret, payment_context
97529752
)
97539753
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
97549754

@@ -10055,7 +10055,7 @@ where
1005510055
/// Creates multi-hop blinded payment paths for the given `amount_msats` by delegating to
1005610056
/// [`Router::create_blinded_payment_paths`].
1005710057
fn create_blinded_payment_paths(
10058-
&self, amount_msats: u64, payment_secret: PaymentSecret, payment_context: PaymentContext
10058+
&self, amount_msats: Option<u64>, payment_secret: PaymentSecret, payment_context: PaymentContext
1005910059
) -> Result<Vec<BlindedPaymentPath>, ()> {
1006010060
let secp_ctx = &self.secp_ctx;
1006110061

@@ -11585,7 +11585,7 @@ where
1158511585
invoice_request: invoice_request.fields(),
1158611586
});
1158711587
let payment_paths = match self.create_blinded_payment_paths(
11588-
amount_msats, payment_secret, payment_context
11588+
Some(amount_msats), payment_secret, payment_context
1158911589
) {
1159011590
Ok(payment_paths) => payment_paths,
1159111591
Err(()) => {

lightning/src/routing/router.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: Deref, S: Deref, SP: Size
9595
T: secp256k1::Signing + secp256k1::Verification
9696
> (
9797
&self, recipient: PublicKey, first_hops: Vec<ChannelDetails>, tlvs: ReceiveTlvs,
98-
amount_msats: u64, secp_ctx: &Secp256k1<T>
98+
amount_msats: Option<u64>, secp_ctx: &Secp256k1<T>
9999
) -> Result<Vec<BlindedPaymentPath>, ()> {
100100
// Limit the number of blinded paths that are computed.
101101
const MAX_PAYMENT_PATHS: usize = 3;
@@ -120,9 +120,9 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: Deref, S: Deref, SP: Size
120120

121121
let paths = first_hops.into_iter()
122122
.filter(|details| details.counterparty.features.supports_route_blinding())
123-
.filter(|details| amount_msats <= details.inbound_capacity_msat)
124-
.filter(|details| amount_msats >= details.inbound_htlc_minimum_msat.unwrap_or(0))
125-
.filter(|details| amount_msats <= details.inbound_htlc_maximum_msat.unwrap_or(u64::MAX))
123+
.filter(|details| amount_msats.unwrap_or(0) <= details.inbound_capacity_msat)
124+
.filter(|details| amount_msats.unwrap_or(u64::MAX) >= details.inbound_htlc_minimum_msat.unwrap_or(0))
125+
.filter(|details| amount_msats.unwrap_or(0) <= details.inbound_htlc_maximum_msat.unwrap_or(u64::MAX))
126126
// Limit to peers with announced channels unless the recipient is unannounced.
127127
.filter(|details| network_graph
128128
.node(&NodeId::from_pubkey(&details.counterparty.node_id))
@@ -218,7 +218,7 @@ pub trait Router {
218218
T: secp256k1::Signing + secp256k1::Verification
219219
> (
220220
&self, recipient: PublicKey, first_hops: Vec<ChannelDetails>, tlvs: ReceiveTlvs,
221-
amount_msats: u64, secp_ctx: &Secp256k1<T>
221+
amount_msats: Option<u64>, secp_ctx: &Secp256k1<T>
222222
) -> Result<Vec<BlindedPaymentPath>, ()>;
223223
}
224224

lightning/src/util/test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl<'a> Router for TestRouter<'a> {
251251
T: secp256k1::Signing + secp256k1::Verification
252252
>(
253253
&self, recipient: PublicKey, first_hops: Vec<ChannelDetails>, tlvs: ReceiveTlvs,
254-
amount_msats: u64, secp_ctx: &Secp256k1<T>,
254+
amount_msats: Option<u64>, secp_ctx: &Secp256k1<T>,
255255
) -> Result<Vec<BlindedPaymentPath>, ()> {
256256
let mut expected_paths = self.next_blinded_payment_paths.lock().unwrap();
257257
if expected_paths.is_empty() {

0 commit comments

Comments
 (0)