Skip to content

Commit 83e0e7f

Browse files
Support including invreqs when paying to a route.
1 parent e7f7423 commit 83e0e7f

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
@@ -4005,14 +4005,14 @@ where
40054005
let _lck = self.total_consistency_lock.read().unwrap();
40064006
self.send_payment_along_path(SendAlongPathArgs {
40074007
path, payment_hash, recipient_onion: &recipient_onion, total_value,
4008-
cur_height, payment_id, keysend_preimage, session_priv_bytes
4008+
cur_height, payment_id, keysend_preimage, invoice_request: None, session_priv_bytes
40094009
})
40104010
}
40114011

40124012
fn send_payment_along_path(&self, args: SendAlongPathArgs) -> Result<(), APIError> {
40134013
let SendAlongPathArgs {
40144014
path, payment_hash, recipient_onion, total_value, cur_height, payment_id, keysend_preimage,
4015-
session_priv_bytes
4015+
invoice_request, session_priv_bytes
40164016
} = args;
40174017
// The top-level caller should hold the total_consistency_lock read lock.
40184018
debug_assert!(self.total_consistency_lock.try_write().is_err());
@@ -4021,7 +4021,7 @@ where
40214021

40224022
let (onion_packet, htlc_msat, htlc_cltv) = onion_utils::create_payment_onion(
40234023
&self.secp_ctx, &path, &session_priv, total_value, recipient_onion, cur_height,
4024-
payment_hash, keysend_preimage, None, prng_seed
4024+
payment_hash, keysend_preimage, invoice_request, prng_seed
40254025
).map_err(|e| {
40264026
let logger = WithContext::from(&self.logger, Some(path.hops.first().unwrap().pubkey), None, Some(*payment_hash));
40274027
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
@@ -702,6 +702,7 @@ pub(super) struct SendAlongPathArgs<'a> {
702702
pub cur_height: u32,
703703
pub payment_id: PaymentId,
704704
pub keysend_preimage: &'a Option<PaymentPreimage>,
705+
pub invoice_request: Option<&'a InvoiceRequest>,
705706
pub session_priv_bytes: [u8; 32],
706707
}
707708

@@ -749,7 +750,7 @@ impl OutboundPayments {
749750
F: Fn(SendAlongPathArgs) -> Result<(), APIError>
750751
{
751752
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)?;
752-
self.pay_route_internal(route, payment_hash, &recipient_onion, None, payment_id, None,
753+
self.pay_route_internal(route, payment_hash, &recipient_onion, None, None, payment_id, None,
753754
onion_session_privs, node_signer, best_block_height, &send_payment_along_path)
754755
.map_err(|e| { self.remove_outbound_if_all_failed(payment_id, &e); e })
755756
}
@@ -794,7 +795,7 @@ impl OutboundPayments {
794795
let onion_session_privs = self.add_new_pending_payment(payment_hash, recipient_onion.clone(),
795796
payment_id, Some(preimage), &route, None, None, entropy_source, best_block_height)?;
796797

797-
match self.pay_route_internal(route, payment_hash, &recipient_onion, Some(preimage),
798+
match self.pay_route_internal(route, payment_hash, &recipient_onion, Some(preimage), None,
798799
payment_id, None, onion_session_privs, node_signer, best_block_height, &send_payment_along_path
799800
) {
800801
Ok(()) => Ok(payment_hash),
@@ -912,7 +913,7 @@ impl OutboundPayments {
912913
}
913914

914915
let result = self.pay_route_internal(
915-
&route, payment_hash, &recipient_onion, None, payment_id,
916+
&route, payment_hash, &recipient_onion, None, None, payment_id,
916917
Some(route_params.final_value_msat), onion_session_privs, node_signer,
917918
best_block_height, &send_payment_along_path
918919
);
@@ -1154,7 +1155,7 @@ impl OutboundPayments {
11541155
})?;
11551156

11561157
let res = self.pay_route_internal(&route, payment_hash, &recipient_onion,
1157-
keysend_preimage, payment_id, None, onion_session_privs, node_signer,
1158+
keysend_preimage, None, payment_id, None, onion_session_privs, node_signer,
11581159
best_block_height, &send_payment_along_path);
11591160
log_info!(logger, "Sending payment with id {} and hash {} returned {:?}",
11601161
payment_id, payment_hash, res);
@@ -1318,7 +1319,7 @@ impl OutboundPayments {
13181319
}
13191320
};
13201321
let res = self.pay_route_internal(&route, payment_hash, &recipient_onion, keysend_preimage,
1321-
payment_id, Some(total_msat), onion_session_privs, node_signer, best_block_height,
1322+
None, payment_id, Some(total_msat), onion_session_privs, node_signer, best_block_height,
13221323
&send_payment_along_path);
13231324
log_info!(logger, "Result retrying payment id {}: {:?}", &payment_id, res);
13241325
if let Err(e) = res {
@@ -1430,7 +1431,8 @@ impl OutboundPayments {
14301431

14311432
let recipient_onion_fields = RecipientOnionFields::spontaneous_empty();
14321433
match self.pay_route_internal(&route, payment_hash, &recipient_onion_fields,
1433-
None, payment_id, None, onion_session_privs, node_signer, best_block_height, &send_payment_along_path
1434+
None, None, payment_id, None, onion_session_privs, node_signer, best_block_height,
1435+
&send_payment_along_path
14341436
) {
14351437
Ok(()) => Ok((payment_hash, payment_id)),
14361438
Err(e) => {
@@ -1539,9 +1541,9 @@ impl OutboundPayments {
15391541

15401542
fn pay_route_internal<NS: Deref, F>(
15411543
&self, route: &Route, payment_hash: PaymentHash, recipient_onion: &RecipientOnionFields,
1542-
keysend_preimage: Option<PaymentPreimage>, payment_id: PaymentId, recv_value_msat: Option<u64>,
1543-
onion_session_privs: Vec<[u8; 32]>, node_signer: &NS, best_block_height: u32,
1544-
send_payment_along_path: &F
1544+
keysend_preimage: Option<PaymentPreimage>, invoice_request: Option<&InvoiceRequest>,
1545+
payment_id: PaymentId, recv_value_msat: Option<u64>, onion_session_privs: Vec<[u8; 32]>,
1546+
node_signer: &NS, best_block_height: u32, send_payment_along_path: &F
15451547
) -> Result<(), PaymentSendFailure>
15461548
where
15471549
NS::Target: NodeSigner,
@@ -1594,7 +1596,7 @@ impl OutboundPayments {
15941596
for (path, session_priv_bytes) in route.paths.iter().zip(onion_session_privs.into_iter()) {
15951597
let mut path_res = send_payment_along_path(SendAlongPathArgs {
15961598
path: &path, payment_hash: &payment_hash, recipient_onion, total_value,
1597-
cur_height, payment_id, keysend_preimage: &keysend_preimage,
1599+
cur_height, payment_id, keysend_preimage: &keysend_preimage, invoice_request,
15981600
session_priv_bytes
15991601
});
16001602
match path_res {
@@ -1679,7 +1681,7 @@ impl OutboundPayments {
16791681
F: Fn(SendAlongPathArgs) -> Result<(), APIError>,
16801682
{
16811683
self.pay_route_internal(route, payment_hash, &recipient_onion,
1682-
keysend_preimage, payment_id, recv_value_msat, onion_session_privs,
1684+
keysend_preimage, None, payment_id, recv_value_msat, onion_session_privs,
16831685
node_signer, best_block_height, &send_payment_along_path)
16841686
.map_err(|e| { self.remove_outbound_if_all_failed(payment_id, &e); e })
16851687
}

0 commit comments

Comments
 (0)