@@ -223,6 +223,7 @@ struct OutboundHTLCOutput {
223223 payment_hash: PaymentHash,
224224 state: OutboundHTLCState,
225225 source: HTLCSource,
226+ blinding_point: Option<PublicKey>,
226227 skimmed_fee_msat: Option<u64>,
227228}
228229
@@ -237,6 +238,7 @@ enum HTLCUpdateAwaitingACK {
237238 onion_routing_packet: msgs::OnionPacket,
238239 // The extra fee we're skimming off the top of this HTLC.
239240 skimmed_fee_msat: Option<u64>,
241+ blinding_point: Option<PublicKey>,
240242 },
241243 ClaimHTLC {
242244 payment_preimage: PaymentPreimage,
@@ -5239,6 +5241,7 @@ impl<SP: Deref> Channel<SP> where
52395241 source,
52405242 onion_routing_packet,
52415243 skimmed_fee_msat,
5244+ blinding_point: None,
52425245 });
52435246 return Ok(None);
52445247 }
@@ -5250,6 +5253,7 @@ impl<SP: Deref> Channel<SP> where
52505253 cltv_expiry,
52515254 state: OutboundHTLCState::LocalAnnounced(Box::new(onion_routing_packet.clone())),
52525255 source,
5256+ blinding_point: None,
52535257 skimmed_fee_msat,
52545258 });
52555259
@@ -6751,6 +6755,7 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
67516755
67526756 let mut preimages: Vec<&Option<PaymentPreimage>> = vec![];
67536757 let mut pending_outbound_skimmed_fees: Vec<Option<u64>> = Vec::new();
6758+ let mut pending_outbound_blinding_points: Vec<Option<PublicKey>> = Vec::new();
67546759
67556760 (self.context.pending_outbound_htlcs.len() as u64).write(writer)?;
67566761 for (idx, htlc) in self.context.pending_outbound_htlcs.iter().enumerate() {
@@ -6797,15 +6802,24 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
67976802 } else if !pending_outbound_skimmed_fees.is_empty() {
67986803 pending_outbound_skimmed_fees.push(None);
67996804 }
6805+ if htlc.blinding_point.is_some() {
6806+ if pending_outbound_blinding_points.is_empty() {
6807+ for _ in 0..idx { pending_outbound_blinding_points.push(None); }
6808+ }
6809+ pending_outbound_blinding_points.push(htlc.blinding_point);
6810+ } else if !pending_outbound_blinding_points.is_empty() {
6811+ pending_outbound_blinding_points.push(None);
6812+ }
68006813 }
68016814
68026815 let mut holding_cell_skimmed_fees: Vec<Option<u64>> = Vec::new();
6816+ let mut holding_cell_blinding_points: Vec<Option<PublicKey>> = Vec::new();
68036817 (self.context.holding_cell_htlc_updates.len() as u64).write(writer)?;
68046818 for (idx, update) in self.context.holding_cell_htlc_updates.iter().enumerate() {
68056819 match update {
68066820 &HTLCUpdateAwaitingACK::AddHTLC {
68076821 ref amount_msat, ref cltv_expiry, ref payment_hash, ref source, ref onion_routing_packet,
6808- skimmed_fee_msat,
6822+ blinding_point, skimmed_fee_msat,
68096823 } => {
68106824 0u8.write(writer)?;
68116825 amount_msat.write(writer)?;
@@ -6820,6 +6834,14 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
68206834 }
68216835 holding_cell_skimmed_fees.push(Some(skimmed_fee));
68226836 } else if !holding_cell_skimmed_fees.is_empty() { holding_cell_skimmed_fees.push(None); }
6837+ if blinding_point.is_some() {
6838+ if holding_cell_blinding_points.is_empty() {
6839+ for _ in 0..idx { holding_cell_blinding_points.push(None); }
6840+ }
6841+ holding_cell_blinding_points.push(blinding_point);
6842+ } else if !holding_cell_blinding_points.is_empty() {
6843+ holding_cell_blinding_points.push(None);
6844+ }
68236845 },
68246846 &HTLCUpdateAwaitingACK::ClaimHTLC { ref payment_preimage, ref htlc_id } => {
68256847 1u8.write(writer)?;
@@ -6988,6 +7010,8 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
69887010 (31, channel_pending_event_emitted, option),
69897011 (35, pending_outbound_skimmed_fees, optional_vec),
69907012 (37, holding_cell_skimmed_fees, optional_vec),
7013+ (39, pending_outbound_blinding_points, optional_vec),
7014+ (41, holding_cell_blinding_points, optional_vec),
69917015 });
69927016
69937017 Ok(())
@@ -7099,6 +7123,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
70997123 _ => return Err(DecodeError::InvalidValue),
71007124 },
71017125 skimmed_fee_msat: None,
7126+ blinding_point: None,
71027127 });
71037128 }
71047129
@@ -7113,6 +7138,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
71137138 source: Readable::read(reader)?,
71147139 onion_routing_packet: Readable::read(reader)?,
71157140 skimmed_fee_msat: None,
7141+ blinding_point: None,
71167142 },
71177143 1 => HTLCUpdateAwaitingACK::ClaimHTLC {
71187144 payment_preimage: Readable::read(reader)?,
@@ -7271,6 +7297,9 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
72717297 let mut pending_outbound_skimmed_fees_opt: Option<Vec<Option<u64>>> = None;
72727298 let mut holding_cell_skimmed_fees_opt: Option<Vec<Option<u64>>> = None;
72737299
7300+ let mut pending_outbound_blinding_points_opt: Option<Vec<Option<PublicKey>>> = None;
7301+ let mut holding_cell_blinding_points_opt: Option<Vec<Option<PublicKey>>> = None;
7302+
72747303 read_tlv_fields!(reader, {
72757304 (0, announcement_sigs, option),
72767305 (1, minimum_depth, option),
@@ -7296,6 +7325,8 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
72967325 (31, channel_pending_event_emitted, option),
72977326 (35, pending_outbound_skimmed_fees_opt, optional_vec),
72987327 (37, holding_cell_skimmed_fees_opt, optional_vec),
7328+ (39, pending_outbound_blinding_points_opt, optional_vec),
7329+ (41, holding_cell_blinding_points_opt, optional_vec),
72997330 });
73007331
73017332 let (channel_keys_id, holder_signer) = if let Some(channel_keys_id) = channel_keys_id {
@@ -7372,6 +7403,24 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
73727403 // We expect all skimmed fees to be consumed above
73737404 if iter.next().is_some() { return Err(DecodeError::InvalidValue) }
73747405 }
7406+ if let Some(blinding_pts) = pending_outbound_blinding_points_opt {
7407+ let mut iter = blinding_pts.into_iter();
7408+ for htlc in pending_outbound_htlcs.iter_mut() {
7409+ htlc.blinding_point = iter.next().ok_or(DecodeError::InvalidValue)?;
7410+ }
7411+ // We expect all blinding points to be consumed above
7412+ if iter.next().is_some() { return Err(DecodeError::InvalidValue) }
7413+ }
7414+ if let Some(blinding_pts) = holding_cell_blinding_points_opt {
7415+ let mut iter = blinding_pts.into_iter();
7416+ for htlc in holding_cell_htlc_updates.iter_mut() {
7417+ if let HTLCUpdateAwaitingACK::AddHTLC { ref mut blinding_point, .. } = htlc {
7418+ *blinding_point = iter.next().ok_or(DecodeError::InvalidValue)?;
7419+ }
7420+ }
7421+ // We expect all blinding points to be consumed above
7422+ if iter.next().is_some() { return Err(DecodeError::InvalidValue) }
7423+ }
73757424
73767425 Ok(Channel {
73777426 context: ChannelContext {
@@ -7714,6 +7763,7 @@ mod tests {
77147763 payment_id: PaymentId([42; 32]),
77157764 },
77167765 skimmed_fee_msat: None,
7766+ blinding_point: None,
77177767 });
77187768
77197769 // Make sure when Node A calculates their local commitment transaction, none of the HTLCs pass
@@ -8271,6 +8321,7 @@ mod tests {
82718321 state: OutboundHTLCState::Committed,
82728322 source: HTLCSource::dummy(),
82738323 skimmed_fee_msat: None,
8324+ blinding_point: None,
82748325 };
82758326 out.payment_hash.0 = Sha256::hash(&hex::decode("0202020202020202020202020202020202020202020202020202020202020202").unwrap()).into_inner();
82768327 out
@@ -8284,6 +8335,7 @@ mod tests {
82848335 state: OutboundHTLCState::Committed,
82858336 source: HTLCSource::dummy(),
82868337 skimmed_fee_msat: None,
8338+ blinding_point: None,
82878339 };
82888340 out.payment_hash.0 = Sha256::hash(&hex::decode("0303030303030303030303030303030303030303030303030303030303030303").unwrap()).into_inner();
82898341 out
@@ -8695,6 +8747,7 @@ mod tests {
86958747 state: OutboundHTLCState::Committed,
86968748 source: HTLCSource::dummy(),
86978749 skimmed_fee_msat: None,
8750+ blinding_point: None,
86988751 };
86998752 out.payment_hash.0 = Sha256::hash(&hex::decode("0505050505050505050505050505050505050505050505050505050505050505").unwrap()).into_inner();
87008753 out
@@ -8708,6 +8761,7 @@ mod tests {
87088761 state: OutboundHTLCState::Committed,
87098762 source: HTLCSource::dummy(),
87108763 skimmed_fee_msat: None,
8764+ blinding_point: None,
87118765 };
87128766 out.payment_hash.0 = Sha256::hash(&hex::decode("0505050505050505050505050505050505050505050505050505050505050505").unwrap()).into_inner();
87138767 out
0 commit comments