Skip to content

Commit c34c596

Browse files
Support including invreqs when paying to a route.
1 parent 8ba5b01 commit c34c596

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4044,14 +4044,14 @@ where
40444044
let _lck = self.total_consistency_lock.read().unwrap();
40454045
self.send_payment_along_path(SendAlongPathArgs {
40464046
path, payment_hash, recipient_onion: &recipient_onion, total_value,
4047-
cur_height, payment_id, keysend_preimage, session_priv_bytes
4047+
cur_height, payment_id, keysend_preimage, invoice_request: None, session_priv_bytes
40484048
})
40494049
}
40504050

40514051
fn send_payment_along_path(&self, args: SendAlongPathArgs) -> Result<(), APIError> {
40524052
let SendAlongPathArgs {
40534053
path, payment_hash, recipient_onion, total_value, cur_height, payment_id, keysend_preimage,
4054-
session_priv_bytes
4054+
invoice_request, session_priv_bytes
40554055
} = args;
40564056
// The top-level caller should hold the total_consistency_lock read lock.
40574057
debug_assert!(self.total_consistency_lock.try_write().is_err());
@@ -4060,7 +4060,7 @@ where
40604060

40614061
let (onion_packet, htlc_msat, htlc_cltv) = onion_utils::create_payment_onion(
40624062
&self.secp_ctx, &path, &session_priv, total_value, recipient_onion, cur_height,
4063-
payment_hash, keysend_preimage, None, prng_seed
4063+
payment_hash, keysend_preimage, invoice_request, prng_seed
40644064
).map_err(|e| {
40654065
let logger = WithContext::from(&self.logger, Some(path.hops.first().unwrap().pubkey), None, Some(*payment_hash));
40664066
log_error!(logger, "Failed to build an onion for path for payment hash {}", payment_hash);

lightning/src/ln/outbound_payment.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ pub(super) struct SendAlongPathArgs<'a> {
687687
pub cur_height: u32,
688688
pub payment_id: PaymentId,
689689
pub keysend_preimage: &'a Option<PaymentPreimage>,
690+
pub invoice_request: Option<&'a InvoiceRequest>,
690691
pub session_priv_bytes: [u8; 32],
691692
}
692693

@@ -734,7 +735,7 @@ impl OutboundPayments {
734735
F: Fn(SendAlongPathArgs) -> Result<(), APIError>
735736
{
736737
let onion_session_privs = self.add_new_pending_payment(payment_hash, recipient_onion.clone(), payment_id, None, route, None, None, entropy_source, best_block_height)?;
737-
self.pay_route_internal(route, payment_hash, &recipient_onion, None, payment_id, None,
738+
self.pay_route_internal(route, payment_hash, &recipient_onion, None, None, payment_id, None,
738739
onion_session_privs, node_signer, best_block_height, &send_payment_along_path)
739740
.map_err(|e| { self.remove_outbound_if_all_failed(payment_id, &e); e })
740741
}
@@ -779,7 +780,7 @@ impl OutboundPayments {
779780
let onion_session_privs = self.add_new_pending_payment(payment_hash, recipient_onion.clone(),
780781
payment_id, Some(preimage), &route, None, None, entropy_source, best_block_height)?;
781782

782-
match self.pay_route_internal(route, payment_hash, &recipient_onion, Some(preimage),
783+
match self.pay_route_internal(route, payment_hash, &recipient_onion, Some(preimage), None,
783784
payment_id, None, onion_session_privs, node_signer, best_block_height, &send_payment_along_path
784785
) {
785786
Ok(()) => Ok(payment_hash),
@@ -904,7 +905,7 @@ impl OutboundPayments {
904905
}
905906

906907
let result = self.pay_route_internal(
907-
&route, payment_hash, &recipient_onion, None, payment_id,
908+
&route, payment_hash, &recipient_onion, None, None, payment_id,
908909
Some(route_params.final_value_msat), onion_session_privs, node_signer,
909910
best_block_height, &send_payment_along_path
910911
);
@@ -1180,7 +1181,7 @@ impl OutboundPayments {
11801181
})?;
11811182

11821183
let res = self.pay_route_internal(&route, payment_hash, &recipient_onion,
1183-
keysend_preimage, payment_id, None, onion_session_privs, node_signer,
1184+
keysend_preimage, None, payment_id, None, onion_session_privs, node_signer,
11841185
best_block_height, &send_payment_along_path);
11851186
log_info!(logger, "Sending payment with id {} and hash {} returned {:?}",
11861187
payment_id, payment_hash, res);
@@ -1344,7 +1345,7 @@ impl OutboundPayments {
13441345
}
13451346
};
13461347
let res = self.pay_route_internal(&route, payment_hash, &recipient_onion, keysend_preimage,
1347-
payment_id, Some(total_msat), onion_session_privs, node_signer, best_block_height,
1348+
None, payment_id, Some(total_msat), onion_session_privs, node_signer, best_block_height,
13481349
&send_payment_along_path);
13491350
log_info!(logger, "Result retrying payment id {}: {:?}", &payment_id, res);
13501351
if let Err(e) = res {
@@ -1456,7 +1457,8 @@ impl OutboundPayments {
14561457

14571458
let recipient_onion_fields = RecipientOnionFields::spontaneous_empty();
14581459
match self.pay_route_internal(&route, payment_hash, &recipient_onion_fields,
1459-
None, payment_id, None, onion_session_privs, node_signer, best_block_height, &send_payment_along_path
1460+
None, None, payment_id, None, onion_session_privs, node_signer, best_block_height,
1461+
&send_payment_along_path
14601462
) {
14611463
Ok(()) => Ok((payment_hash, payment_id)),
14621464
Err(e) => {
@@ -1565,9 +1567,9 @@ impl OutboundPayments {
15651567

15661568
fn pay_route_internal<NS: Deref, F>(
15671569
&self, route: &Route, payment_hash: PaymentHash, recipient_onion: &RecipientOnionFields,
1568-
keysend_preimage: Option<PaymentPreimage>, payment_id: PaymentId, recv_value_msat: Option<u64>,
1569-
onion_session_privs: Vec<[u8; 32]>, node_signer: &NS, best_block_height: u32,
1570-
send_payment_along_path: &F
1570+
keysend_preimage: Option<PaymentPreimage>, invoice_request: Option<&InvoiceRequest>,
1571+
payment_id: PaymentId, recv_value_msat: Option<u64>, onion_session_privs: Vec<[u8; 32]>,
1572+
node_signer: &NS, best_block_height: u32, send_payment_along_path: &F
15711573
) -> Result<(), PaymentSendFailure>
15721574
where
15731575
NS::Target: NodeSigner,
@@ -1620,7 +1622,7 @@ impl OutboundPayments {
16201622
for (path, session_priv_bytes) in route.paths.iter().zip(onion_session_privs.into_iter()) {
16211623
let mut path_res = send_payment_along_path(SendAlongPathArgs {
16221624
path: &path, payment_hash: &payment_hash, recipient_onion, total_value,
1623-
cur_height, payment_id, keysend_preimage: &keysend_preimage,
1625+
cur_height, payment_id, keysend_preimage: &keysend_preimage, invoice_request,
16241626
session_priv_bytes
16251627
});
16261628
match path_res {
@@ -1705,7 +1707,7 @@ impl OutboundPayments {
17051707
F: Fn(SendAlongPathArgs) -> Result<(), APIError>,
17061708
{
17071709
self.pay_route_internal(route, payment_hash, &recipient_onion,
1708-
keysend_preimage, payment_id, recv_value_msat, onion_session_privs,
1710+
keysend_preimage, None, payment_id, recv_value_msat, onion_session_privs,
17091711
node_signer, best_block_height, &send_payment_along_path)
17101712
.map_err(|e| { self.remove_outbound_if_all_failed(payment_id, &e); e })
17111713
}

0 commit comments

Comments
 (0)