Parse blinding point in UpdateAddHTLC
authorValentine Wallace <vwallace@protonmail.com>
Thu, 23 Mar 2023 22:56:11 +0000 (18:56 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Wed, 29 Nov 2023 22:10:41 +0000 (17:10 -0500)
A blinding point is provided in update_add_htlc messages if we are relaying or
receiving a payment within a blinded path, to decrypt the onion routing packet
and the recipient-provided encrypted payload within. Will be used in upcoming
commits.

lightning/src/ln/channel.rs
lightning/src/ln/functional_tests.rs
lightning/src/ln/msgs.rs
lightning/src/ln/onion_payment.rs

index 2862e360e339149ce700e148e5a159859d05217a..4650a9c143a07a5ada0c75535a5c25f197726119 100644 (file)
@@ -4076,6 +4076,7 @@ impl<SP: Deref> Channel<SP> where
                                        cltv_expiry: htlc.cltv_expiry,
                                        onion_routing_packet: (**onion_packet).clone(),
                                        skimmed_fee_msat: htlc.skimmed_fee_msat,
+                                       blinding_point: None,
                                });
                        }
                }
@@ -5617,6 +5618,7 @@ impl<SP: Deref> Channel<SP> where
                        cltv_expiry,
                        onion_routing_packet,
                        skimmed_fee_msat,
+                       blinding_point: None,
                };
                self.context.next_holder_htlc_id += 1;
 
index cc00d93b17abf7026b62288d1ffd6a49d1588d10..8df252586a30acd9dc902cb42e4a55b9071a06f8 100644 (file)
@@ -1415,6 +1415,7 @@ fn test_fee_spike_violation_fails_htlc() {
                cltv_expiry: htlc_cltv,
                onion_routing_packet: onion_packet,
                skimmed_fee_msat: None,
+               blinding_point: None,
        };
 
        nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &msg);
@@ -1611,6 +1612,7 @@ fn test_chan_reserve_violation_inbound_htlc_outbound_channel() {
                cltv_expiry: htlc_cltv,
                onion_routing_packet: onion_packet,
                skimmed_fee_msat: None,
+               blinding_point: None,
        };
 
        nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &msg);
@@ -1789,6 +1791,7 @@ fn test_chan_reserve_violation_inbound_htlc_inbound_chan() {
                cltv_expiry: htlc_cltv,
                onion_routing_packet: onion_packet,
                skimmed_fee_msat: None,
+               blinding_point: None,
        };
 
        nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &msg);
@@ -3510,6 +3513,7 @@ fn fail_backward_pending_htlc_upon_channel_failure() {
                        cltv_expiry,
                        onion_routing_packet,
                        skimmed_fee_msat: None,
+                       blinding_point: None,
                };
                nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &update_add_htlc);
        }
@@ -6481,6 +6485,7 @@ fn test_update_add_htlc_bolt2_receiver_check_max_htlc_limit() {
                cltv_expiry: htlc_cltv,
                onion_routing_packet: onion_packet.clone(),
                skimmed_fee_msat: None,
+               blinding_point: None,
        };
 
        for i in 0..50 {
index b2825df4a9cdd606389c5cbfad640d607ba78b5f..349cc5c728a093fe45412d945e1dded466242225 100644 (file)
@@ -682,6 +682,9 @@ pub struct UpdateAddHTLC {
        pub skimmed_fee_msat: Option<u64>,
        /// The onion routing packet with encrypted data for the next hop.
        pub onion_routing_packet: OnionPacket,
+       /// Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
+       /// routing packet and the recipient-provided encrypted payload within.
+       pub blinding_point: Option<PublicKey>,
 }
 
  /// An onion message to be sent to or received from a peer.
@@ -2212,6 +2215,7 @@ impl_writeable_msg!(UpdateAddHTLC, {
        cltv_expiry,
        onion_routing_packet,
 }, {
+       (0, blinding_point, option),
        (65537, skimmed_fee_msat, option)
 });
 
@@ -3757,6 +3761,7 @@ mod tests {
                        cltv_expiry: 821716,
                        onion_routing_packet,
                        skimmed_fee_msat: None,
+                       blinding_point: None,
                };
                let encoded_value = update_add_htlc.encode();
                let target_value = <Vec<u8>>::from_hex("020202020202020202020202020202020202020202020202020202020202020200083a840000034d32144668701144760101010101010101010101010101010101010101010101010101010101010101000c89d4ff031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010202020202020202020202020202020202020202020202020202020202020202").unwrap();
index d191c470373256d4424e6a47ffd1b5f740a2a08c..ca7c0dff20c2fd986c55310dba19586ed27ace3f 100644 (file)
@@ -449,6 +449,7 @@ mod tests {
                        payment_hash,
                        onion_routing_packet,
                        skimmed_fee_msat: None,
+                       blinding_point: None,
                }
        }