Skip to content

Commit

Permalink
f: set multipath_trampoline_data
Browse files Browse the repository at this point in the history
  • Loading branch information
arik-so committed Dec 13, 2024
1 parent aeeba82 commit ba71d6e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lightning/src/ln/onion_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -1400,11 +1401,19 @@ pub fn create_payment_onion<T: secp256k1::Signing>(
})?;

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,
});
},
Expand Down

0 comments on commit ba71d6e

Please sign in to comment.