@@ -7037,7 +7037,7 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
70377037 let mut pending_outbound_blinding_points: Vec<Option<PublicKey>> = Vec::new();
70387038
70397039 (self.context.pending_outbound_htlcs.len() as u64).write(writer)?;
7040- for (idx, htlc) in self.context.pending_outbound_htlcs.iter().enumerate () {
7040+ for htlc in self.context.pending_outbound_htlcs.iter() {
70417041 htlc.htlc_id.write(writer)?;
70427042 htlc.amount_msat.write(writer)?;
70437043 htlc.cltv_expiry.write(writer)?;
@@ -7073,21 +7073,14 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
70737073 reason.write(writer)?;
70747074 }
70757075 }
7076- if let Some(skimmed_fee) = htlc.skimmed_fee_msat {
7077- if pending_outbound_skimmed_fees.is_empty() {
7078- for _ in 0..idx { pending_outbound_skimmed_fees.push(None); }
7079- }
7080- pending_outbound_skimmed_fees.push(Some(skimmed_fee));
7081- } else if !pending_outbound_skimmed_fees.is_empty() {
7082- pending_outbound_skimmed_fees.push(None);
7083- }
7076+ pending_outbound_skimmed_fees.push(htlc.skimmed_fee_msat);
70847077 pending_outbound_blinding_points.push(htlc.blinding_point);
70857078 }
70867079
70877080 let mut holding_cell_skimmed_fees: Vec<Option<u64>> = Vec::new();
70887081 let mut holding_cell_blinding_points: Vec<Option<PublicKey>> = Vec::new();
70897082 (self.context.holding_cell_htlc_updates.len() as u64).write(writer)?;
7090- for (idx, update) in self.context.holding_cell_htlc_updates.iter().enumerate () {
7083+ for update in self.context.holding_cell_htlc_updates.iter() {
70917084 match update {
70927085 &HTLCUpdateAwaitingACK::AddHTLC {
70937086 ref amount_msat, ref cltv_expiry, ref payment_hash, ref source, ref onion_routing_packet,
@@ -7100,13 +7093,7 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
71007093 source.write(writer)?;
71017094 onion_routing_packet.write(writer)?;
71027095
7103- if let Some(skimmed_fee) = skimmed_fee_msat {
7104- if holding_cell_skimmed_fees.is_empty() {
7105- for _ in 0..idx { holding_cell_skimmed_fees.push(None); }
7106- }
7107- holding_cell_skimmed_fees.push(Some(skimmed_fee));
7108- } else if !holding_cell_skimmed_fees.is_empty() { holding_cell_skimmed_fees.push(None); }
7109-
7096+ holding_cell_skimmed_fees.push(skimmed_fee_msat);
71107097 holding_cell_blinding_points.push(blinding_point);
71117098 },
71127099 &HTLCUpdateAwaitingACK::ClaimHTLC { ref payment_preimage, ref htlc_id } => {
@@ -8366,8 +8353,8 @@ mod tests {
83668353 }
83678354
83688355 #[test]
8369- fn blinding_point_ser () {
8370- // Ensure that channel blinding points are (de)serialized properly.
8356+ fn blinding_point_skimmed_fee_ser () {
8357+ // Ensure that channel blinding points and skimmed fees are (de)serialized properly.
83718358 let feeest = LowerBoundedFeeEstimator::new(&TestFeeEstimator{fee_est: 15000});
83728359 let secp_ctx = Secp256k1::new();
83738360 let seed = [42; 32];
@@ -8408,6 +8395,9 @@ mod tests {
84088395 if idx % 2 == 0 {
84098396 htlc.blinding_point = Some(test_utils::pubkey(42 + idx as u8));
84108397 }
8398+ if idx % 3 == 0 {
8399+ htlc.skimmed_fee_msat = Some(1);
8400+ }
84118401 }
84128402 chan.context.pending_outbound_htlcs = pending_outbound_htlcs.clone();
84138403
@@ -8437,8 +8427,11 @@ mod tests {
84378427 holding_cell_htlc_updates.push(dummy_holding_cell_claim_htlc.clone());
84388428 } else {
84398429 let mut dummy_add = dummy_holding_cell_add_htlc.clone();
8440- if let HTLCUpdateAwaitingACK::AddHTLC { ref mut blinding_point, .. } = &mut dummy_add {
8430+ if let HTLCUpdateAwaitingACK::AddHTLC {
8431+ ref mut blinding_point, ref mut skimmed_fee_msat, ..
8432+ } = &mut dummy_add {
84418433 *blinding_point = Some(test_utils::pubkey(42 + i));
8434+ *skimmed_fee_msat = Some(42);
84428435 } else { panic!() }
84438436 holding_cell_htlc_updates.push(dummy_add);
84448437 }
0 commit comments