Skip to content

Commit e7f7423

Browse files
Support including invreqs when building payment onions.
1 parent a186fa4 commit e7f7423

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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, prng_seed
4024+
payment_hash, keysend_preimage, None, 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/max_payment_path_len_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fn large_payment_metadata() {
111111
let secp_ctx = Secp256k1::signing_only();
112112
route_0_1.paths[0].hops[0].fee_msat = MIN_FINAL_VALUE_ESTIMATE_WITH_OVERPAY;
113113
route_0_1.paths[0].hops[0].cltv_expiry_delta = DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA;
114-
let err = onion_utils::create_payment_onion(&secp_ctx, &route_0_1.paths[0], &test_utils::privkey(42), MIN_FINAL_VALUE_ESTIMATE_WITH_OVERPAY, &recipient_onion_too_large_md, nodes[0].best_block_info().1 + DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA, &payment_hash, &None, [0; 32]).unwrap_err();
114+
let err = onion_utils::create_payment_onion(&secp_ctx, &route_0_1.paths[0], &test_utils::privkey(42), MIN_FINAL_VALUE_ESTIMATE_WITH_OVERPAY, &recipient_onion_too_large_md, nodes[0].best_block_info().1 + DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA, &payment_hash, &None, None, [0; 32]).unwrap_err();
115115
match err {
116116
APIError::InvalidRoute { err } => {
117117
assert_eq!(err, "Route size too large considering onion data");
@@ -312,7 +312,7 @@ fn blinded_path_with_custom_tlv() {
312312
let secp_ctx = Secp256k1::signing_only();
313313
route.paths[0].hops[0].fee_msat = MIN_FINAL_VALUE_ESTIMATE_WITH_OVERPAY;
314314
route.paths[0].hops[0].cltv_expiry_delta = DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA;
315-
let err = onion_utils::create_payment_onion(&secp_ctx, &route.paths[0], &test_utils::privkey(42), MIN_FINAL_VALUE_ESTIMATE_WITH_OVERPAY, &recipient_onion_too_large_custom_tlv, nodes[0].best_block_info().1 + DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA, &payment_hash, &None, [0; 32]).unwrap_err();
315+
let err = onion_utils::create_payment_onion(&secp_ctx, &route.paths[0], &test_utils::privkey(42), MIN_FINAL_VALUE_ESTIMATE_WITH_OVERPAY, &recipient_onion_too_large_custom_tlv, nodes[0].best_block_info().1 + DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA, &payment_hash, &None, None, [0; 32]).unwrap_err();
316316
match err {
317317
APIError::InvalidRoute { err } => {
318318
assert_eq!(err, "Route size too large considering onion data");

lightning/src/ln/onion_payment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ mod tests {
564564

565565
let (onion, amount_msat, cltv_expiry) = create_payment_onion(
566566
&secp_ctx, &path, &session_priv, total_amt_msat, &recipient_onion,
567-
cur_height, &payment_hash, &Some(preimage), prng_seed
567+
cur_height, &payment_hash, &Some(preimage), None, prng_seed
568568
).unwrap();
569569

570570
let msg = make_update_add_msg(amount_msat, cltv_expiry, payment_hash, onion);

lightning/src/ln/onion_utils.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,8 @@ where
11641164
pub fn create_payment_onion<T: secp256k1::Signing>(
11651165
secp_ctx: &Secp256k1<T>, path: &Path, session_priv: &SecretKey, total_msat: u64,
11661166
recipient_onion: &RecipientOnionFields, cur_block_height: u32, payment_hash: &PaymentHash,
1167-
keysend_preimage: &Option<PaymentPreimage>, prng_seed: [u8; 32],
1167+
keysend_preimage: &Option<PaymentPreimage>, invoice_request: Option<&InvoiceRequest>,
1168+
prng_seed: [u8; 32],
11681169
) -> Result<(msgs::OnionPacket, u64, u32), APIError> {
11691170
let onion_keys = construct_onion_keys(&secp_ctx, &path, &session_priv).map_err(|_| {
11701171
APIError::InvalidRoute { err: "Pubkey along hop was maliciously selected".to_owned() }
@@ -1175,7 +1176,7 @@ pub fn create_payment_onion<T: secp256k1::Signing>(
11751176
recipient_onion,
11761177
cur_block_height,
11771178
keysend_preimage,
1178-
None,
1179+
invoice_request,
11791180
)?;
11801181
let onion_packet = construct_onion_packet(onion_payloads, onion_keys, prng_seed, payment_hash)
11811182
.map_err(|_| APIError::InvalidRoute {

lightning/src/ln/payment_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4269,7 +4269,7 @@ fn peel_payment_onion_custom_tlvs() {
42694269

42704270
let (onion_routing_packet, first_hop_msat, cltv_expiry) = onion_utils::create_payment_onion(
42714271
&secp_ctx, &route.paths[0], &session_priv, amt_msat, &recipient_onion,
4272-
nodes[0].best_block_info().1, &payment_hash, &Some(keysend_preimage), prng_seed
4272+
nodes[0].best_block_info().1, &payment_hash, &Some(keysend_preimage), None, prng_seed
42734273
).unwrap();
42744274

42754275
let update_add = msgs::UpdateAddHTLC {

0 commit comments

Comments
 (0)