]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Set update_add blinding point on HTLC forward
authorValentine Wallace <vwallace@protonmail.com>
Thu, 26 Oct 2023 18:24:10 +0000 (14:24 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Wed, 29 Nov 2023 22:18:40 +0000 (17:18 -0500)
Used by the next hop to decode their blinded onion payload.

lightning/src/ln/channelmanager.rs
lightning/src/ln/onion_utils.rs

index b3994e97763e2d0500ec9af60372a93bb9d05902..de126084215a6ce9d70d4fee1f7d92566ca7ea14 100644 (file)
@@ -53,7 +53,7 @@ use crate::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringFeeParame
 use crate::ln::onion_payment::{check_incoming_htlc_cltv, create_recv_pending_htlc_info, create_fwd_pending_htlc_info, decode_incoming_update_add_htlc_onion, InboundOnionErr, NextPacketDetails};
 use crate::ln::msgs;
 use crate::ln::onion_utils;
-use crate::ln::onion_utils::HTLCFailReason;
+use crate::ln::onion_utils::{HTLCFailReason, INVALID_ONION_BLINDING};
 use crate::ln::msgs::{ChannelMessageHandler, DecodeError, LightningError};
 #[cfg(test)]
 use crate::ln::outbound_payment;
@@ -4262,9 +4262,17 @@ where
                                                                                phantom_shared_secret: None,
                                                                                blinded_failure: blinded.map(|_| BlindedFailure::FromIntroductionNode),
                                                                        });
+                                                                       let next_blinding_point = blinded.and_then(|b| {
+                                                                               let encrypted_tlvs_ss = self.node_signer.ecdh(
+                                                                                       Recipient::Node, &b.inbound_blinding_point, None
+                                                                               ).unwrap().secret_bytes();
+                                                                               onion_utils::next_hop_pubkey(
+                                                                                       &self.secp_ctx, b.inbound_blinding_point, &encrypted_tlvs_ss
+                                                                               ).ok()
+                                                                       });
                                                                        if let Err(e) = chan.queue_add_htlc(outgoing_amt_msat,
                                                                                payment_hash, outgoing_cltv_value, htlc_source.clone(),
-                                                                               onion_packet, skimmed_fee_msat, None, &self.fee_estimator,
+                                                                               onion_packet, skimmed_fee_msat, next_blinding_point, &self.fee_estimator,
                                                                                &self.logger)
                                                                        {
                                                                                if let ChannelError::Ignore(msg) = e {
index 605080c7b9298798e45b1a9216f5bad62c810fd3..88f0efe9aa8f393060372dc2b05c843f3be5e1b0 100644 (file)
@@ -242,6 +242,8 @@ pub(super) fn build_onion_payloads(path: &Path, total_msat: u64, mut recipient_o
 /// the hops can be of variable length.
 pub(crate) const ONION_DATA_LEN: usize = 20*65;
 
+pub(super) const INVALID_ONION_BLINDING: u16 = 0x8000 | 0x4000 | 24;
+
 #[inline]
 fn shift_slice_right(arr: &mut [u8], amt: usize) {
        for i in (amt..arr.len()).rev() {