@@ -7152,7 +7152,7 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
7152
7152
let mut pending_outbound_blinding_points: Vec<Option<PublicKey>> = Vec::new();
7153
7153
7154
7154
(self.context.pending_outbound_htlcs.len() as u64).write(writer)?;
7155
- for (idx, htlc) in self.context.pending_outbound_htlcs.iter().enumerate () {
7155
+ for htlc in self.context.pending_outbound_htlcs.iter() {
7156
7156
htlc.htlc_id.write(writer)?;
7157
7157
htlc.amount_msat.write(writer)?;
7158
7158
htlc.cltv_expiry.write(writer)?;
@@ -7188,21 +7188,14 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
7188
7188
reason.write(writer)?;
7189
7189
}
7190
7190
}
7191
- if let Some(skimmed_fee) = htlc.skimmed_fee_msat {
7192
- if pending_outbound_skimmed_fees.is_empty() {
7193
- for _ in 0..idx { pending_outbound_skimmed_fees.push(None); }
7194
- }
7195
- pending_outbound_skimmed_fees.push(Some(skimmed_fee));
7196
- } else if !pending_outbound_skimmed_fees.is_empty() {
7197
- pending_outbound_skimmed_fees.push(None);
7198
- }
7191
+ pending_outbound_skimmed_fees.push(htlc.skimmed_fee_msat);
7199
7192
pending_outbound_blinding_points.push(htlc.blinding_point);
7200
7193
}
7201
7194
7202
7195
let mut holding_cell_skimmed_fees: Vec<Option<u64>> = Vec::new();
7203
7196
let mut holding_cell_blinding_points: Vec<Option<PublicKey>> = Vec::new();
7204
7197
(self.context.holding_cell_htlc_updates.len() as u64).write(writer)?;
7205
- for (idx, update) in self.context.holding_cell_htlc_updates.iter().enumerate () {
7198
+ for update in self.context.holding_cell_htlc_updates.iter() {
7206
7199
match update {
7207
7200
&HTLCUpdateAwaitingACK::AddHTLC {
7208
7201
ref amount_msat, ref cltv_expiry, ref payment_hash, ref source, ref onion_routing_packet,
@@ -7215,13 +7208,7 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
7215
7208
source.write(writer)?;
7216
7209
onion_routing_packet.write(writer)?;
7217
7210
7218
- if let Some(skimmed_fee) = skimmed_fee_msat {
7219
- if holding_cell_skimmed_fees.is_empty() {
7220
- for _ in 0..idx { holding_cell_skimmed_fees.push(None); }
7221
- }
7222
- holding_cell_skimmed_fees.push(Some(skimmed_fee));
7223
- } else if !holding_cell_skimmed_fees.is_empty() { holding_cell_skimmed_fees.push(None); }
7224
-
7211
+ holding_cell_skimmed_fees.push(skimmed_fee_msat);
7225
7212
holding_cell_blinding_points.push(blinding_point);
7226
7213
},
7227
7214
&HTLCUpdateAwaitingACK::ClaimHTLC { ref payment_preimage, ref htlc_id } => {
@@ -8474,8 +8461,8 @@ mod tests {
8474
8461
}
8475
8462
8476
8463
#[test]
8477
- fn blinding_point_ser () {
8478
- // Ensure that channel blinding points are (de)serialized properly.
8464
+ fn blinding_point_skimmed_fee_ser () {
8465
+ // Ensure that channel blinding points and skimmed fees are (de)serialized properly.
8479
8466
let feeest = LowerBoundedFeeEstimator::new(&TestFeeEstimator{fee_est: 15000});
8480
8467
let secp_ctx = Secp256k1::new();
8481
8468
let seed = [42; 32];
@@ -8516,6 +8503,9 @@ mod tests {
8516
8503
if idx % 2 == 0 {
8517
8504
htlc.blinding_point = Some(test_utils::pubkey(42 + idx as u8));
8518
8505
}
8506
+ if idx % 3 == 0 {
8507
+ htlc.skimmed_fee_msat = Some(1);
8508
+ }
8519
8509
}
8520
8510
chan.context.pending_outbound_htlcs = pending_outbound_htlcs.clone();
8521
8511
@@ -8545,8 +8535,11 @@ mod tests {
8545
8535
holding_cell_htlc_updates.push(dummy_holding_cell_claim_htlc.clone());
8546
8536
} else {
8547
8537
let mut dummy_add = dummy_holding_cell_add_htlc.clone();
8548
- if let HTLCUpdateAwaitingACK::AddHTLC { ref mut blinding_point, .. } = &mut dummy_add {
8538
+ if let HTLCUpdateAwaitingACK::AddHTLC {
8539
+ ref mut blinding_point, ref mut skimmed_fee_msat, ..
8540
+ } = &mut dummy_add {
8549
8541
*blinding_point = Some(test_utils::pubkey(42 + i));
8542
+ *skimmed_fee_msat = Some(42);
8550
8543
} else { panic!() }
8551
8544
holding_cell_htlc_updates.push(dummy_add);
8552
8545
}
0 commit comments