@@ -223,6 +223,7 @@ struct OutboundHTLCOutput {
223
223
payment_hash: PaymentHash,
224
224
state: OutboundHTLCState,
225
225
source: HTLCSource,
226
+ blinding_point: Option<PublicKey>,
226
227
skimmed_fee_msat: Option<u64>,
227
228
}
228
229
@@ -237,6 +238,7 @@ enum HTLCUpdateAwaitingACK {
237
238
onion_routing_packet: msgs::OnionPacket,
238
239
// The extra fee we're skimming off the top of this HTLC.
239
240
skimmed_fee_msat: Option<u64>,
241
+ blinding_point: Option<PublicKey>,
240
242
},
241
243
ClaimHTLC {
242
244
payment_preimage: PaymentPreimage,
@@ -5239,6 +5241,7 @@ impl<SP: Deref> Channel<SP> where
5239
5241
source,
5240
5242
onion_routing_packet,
5241
5243
skimmed_fee_msat,
5244
+ blinding_point: None,
5242
5245
});
5243
5246
return Ok(None);
5244
5247
}
@@ -5250,6 +5253,7 @@ impl<SP: Deref> Channel<SP> where
5250
5253
cltv_expiry,
5251
5254
state: OutboundHTLCState::LocalAnnounced(Box::new(onion_routing_packet.clone())),
5252
5255
source,
5256
+ blinding_point: None,
5253
5257
skimmed_fee_msat,
5254
5258
});
5255
5259
@@ -6751,6 +6755,7 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
6751
6755
6752
6756
let mut preimages: Vec<&Option<PaymentPreimage>> = vec![];
6753
6757
let mut pending_outbound_skimmed_fees: Vec<Option<u64>> = Vec::new();
6758
+ let mut pending_outbound_blinding_points: Vec<Option<PublicKey>> = Vec::new();
6754
6759
6755
6760
(self.context.pending_outbound_htlcs.len() as u64).write(writer)?;
6756
6761
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 {
6797
6802
} else if !pending_outbound_skimmed_fees.is_empty() {
6798
6803
pending_outbound_skimmed_fees.push(None);
6799
6804
}
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
+ }
6800
6813
}
6801
6814
6802
6815
let mut holding_cell_skimmed_fees: Vec<Option<u64>> = Vec::new();
6816
+ let mut holding_cell_blinding_points: Vec<Option<PublicKey>> = Vec::new();
6803
6817
(self.context.holding_cell_htlc_updates.len() as u64).write(writer)?;
6804
6818
for (idx, update) in self.context.holding_cell_htlc_updates.iter().enumerate() {
6805
6819
match update {
6806
6820
&HTLCUpdateAwaitingACK::AddHTLC {
6807
6821
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,
6809
6823
} => {
6810
6824
0u8.write(writer)?;
6811
6825
amount_msat.write(writer)?;
@@ -6820,6 +6834,14 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
6820
6834
}
6821
6835
holding_cell_skimmed_fees.push(Some(skimmed_fee));
6822
6836
} 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
+ }
6823
6845
},
6824
6846
&HTLCUpdateAwaitingACK::ClaimHTLC { ref payment_preimage, ref htlc_id } => {
6825
6847
1u8.write(writer)?;
@@ -6988,6 +7010,8 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
6988
7010
(31, channel_pending_event_emitted, option),
6989
7011
(35, pending_outbound_skimmed_fees, optional_vec),
6990
7012
(37, holding_cell_skimmed_fees, optional_vec),
7013
+ (39, pending_outbound_blinding_points, optional_vec),
7014
+ (41, holding_cell_blinding_points, optional_vec),
6991
7015
});
6992
7016
6993
7017
Ok(())
@@ -7099,6 +7123,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
7099
7123
_ => return Err(DecodeError::InvalidValue),
7100
7124
},
7101
7125
skimmed_fee_msat: None,
7126
+ blinding_point: None,
7102
7127
});
7103
7128
}
7104
7129
@@ -7113,6 +7138,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
7113
7138
source: Readable::read(reader)?,
7114
7139
onion_routing_packet: Readable::read(reader)?,
7115
7140
skimmed_fee_msat: None,
7141
+ blinding_point: None,
7116
7142
},
7117
7143
1 => HTLCUpdateAwaitingACK::ClaimHTLC {
7118
7144
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
7271
7297
let mut pending_outbound_skimmed_fees_opt: Option<Vec<Option<u64>>> = None;
7272
7298
let mut holding_cell_skimmed_fees_opt: Option<Vec<Option<u64>>> = None;
7273
7299
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
+
7274
7303
read_tlv_fields!(reader, {
7275
7304
(0, announcement_sigs, option),
7276
7305
(1, minimum_depth, option),
@@ -7296,6 +7325,8 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
7296
7325
(31, channel_pending_event_emitted, option),
7297
7326
(35, pending_outbound_skimmed_fees_opt, optional_vec),
7298
7327
(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),
7299
7330
});
7300
7331
7301
7332
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
7372
7403
// We expect all skimmed fees to be consumed above
7373
7404
if iter.next().is_some() { return Err(DecodeError::InvalidValue) }
7374
7405
}
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
+ }
7375
7424
7376
7425
Ok(Channel {
7377
7426
context: ChannelContext {
@@ -7714,6 +7763,7 @@ mod tests {
7714
7763
payment_id: PaymentId([42; 32]),
7715
7764
},
7716
7765
skimmed_fee_msat: None,
7766
+ blinding_point: None,
7717
7767
});
7718
7768
7719
7769
// Make sure when Node A calculates their local commitment transaction, none of the HTLCs pass
@@ -8271,6 +8321,7 @@ mod tests {
8271
8321
state: OutboundHTLCState::Committed,
8272
8322
source: HTLCSource::dummy(),
8273
8323
skimmed_fee_msat: None,
8324
+ blinding_point: None,
8274
8325
};
8275
8326
out.payment_hash.0 = Sha256::hash(&hex::decode("0202020202020202020202020202020202020202020202020202020202020202").unwrap()).into_inner();
8276
8327
out
@@ -8284,6 +8335,7 @@ mod tests {
8284
8335
state: OutboundHTLCState::Committed,
8285
8336
source: HTLCSource::dummy(),
8286
8337
skimmed_fee_msat: None,
8338
+ blinding_point: None,
8287
8339
};
8288
8340
out.payment_hash.0 = Sha256::hash(&hex::decode("0303030303030303030303030303030303030303030303030303030303030303").unwrap()).into_inner();
8289
8341
out
@@ -8695,6 +8747,7 @@ mod tests {
8695
8747
state: OutboundHTLCState::Committed,
8696
8748
source: HTLCSource::dummy(),
8697
8749
skimmed_fee_msat: None,
8750
+ blinding_point: None,
8698
8751
};
8699
8752
out.payment_hash.0 = Sha256::hash(&hex::decode("0505050505050505050505050505050505050505050505050505050505050505").unwrap()).into_inner();
8700
8753
out
@@ -8708,6 +8761,7 @@ mod tests {
8708
8761
state: OutboundHTLCState::Committed,
8709
8762
source: HTLCSource::dummy(),
8710
8763
skimmed_fee_msat: None,
8764
+ blinding_point: None,
8711
8765
};
8712
8766
out.payment_hash.0 = Sha256::hash(&hex::decode("0505050505050505050505050505050505050505050505050505050505050505").unwrap()).into_inner();
8713
8767
out
0 commit comments