From b9343798ba5471d5d5c0a265a23bd514986fe1d8 Mon Sep 17 00:00:00 2001 From: Arik Sosman Date: Thu, 12 Dec 2024 23:59:22 -0800 Subject: [PATCH] f: set multipath_trampoline_data --- lightning/src/ln/onion_utils.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lightning/src/ln/onion_utils.rs b/lightning/src/ln/onion_utils.rs index 50063a49b32..8265713310c 100644 --- a/lightning/src/ln/onion_utils.rs +++ b/lightning/src/ln/onion_utils.rs @@ -33,10 +33,11 @@ use bitcoin::secp256k1::ecdh::SharedSecret; use bitcoin::secp256k1::{PublicKey, Scalar, Secp256k1, SecretKey}; use crate::io::{Cursor, Read}; -use crate::ln::msgs::OutboundOnionPayload; +use crate::ln::msgs::{FinalOnionHopData, OutboundOnionPayload}; #[allow(unused_imports)] use crate::prelude::*; use core::ops::Deref; +use types::payment::PaymentSecret; pub(crate) struct OnionKeys { #[cfg(test)] @@ -1400,11 +1401,20 @@ pub fn create_payment_onion( })?; match last_payload { - OutboundOnionPayload::Receive { .. } => { + OutboundOnionPayload::Receive { payment_data, .. } => { + let multipath_trampoline_data = payment_data.map(|d| { + let trampoline_payment_secret = + Sha256::hash(&d.payment_secret.0).to_byte_array(); + let total_msat = d.total_msat + path.hops.last().map_or(0, |h| h.fee_msat); + FinalOnionHopData { + payment_secret: PaymentSecret(trampoline_payment_secret), + total_msat, + } + }); onion_payloads.push(OutboundOnionPayload::TrampolineEntrypoint { amt_to_forward: outer_total_msat, outgoing_cltv_value: outer_starting_htlc_offset, - multipath_trampoline_data: None, + multipath_trampoline_data, trampoline_packet, }); },