@@ -287,26 +287,28 @@ impl ChannelMonitor {
287
287
}
288
288
}
289
289
290
- let mut pruned_payment_preimages = HashMap :: with_capacity ( self . payment_preimages . capacity ( ) ) ;
291
- for ( k, v) in self . payment_preimages . drain ( ) {
292
- for ( htlc, _s1, _s2) in & self . current_local_signed_commitment_tx . as_ref ( ) . expect ( "Channel need at least an initial commitment tx !" ) . htlc_outputs {
293
- if k == htlc. payment_hash {
294
- pruned_payment_preimages. insert ( k, v) ;
295
- }
296
- }
297
- for ( _tx, htlcs) in & self . remote_claimable_outpoints {
298
- for htlc in htlcs {
290
+ let local_signed_commitment_tx = & self . current_local_signed_commitment_tx ;
291
+ let remote_claimable_outpoints = & self . remote_claimable_outpoints ;
292
+ self . payment_preimages . retain ( | & k, _|
293
+ {
294
+ for ( htlc, _s1, _s2) in & local_signed_commitment_tx. as_ref ( ) . expect ( "Channel needs at least an initial commitment tx !" ) . htlc_outputs {
299
295
if k == htlc. payment_hash {
300
- pruned_payment_preimages . insert ( k , v ) ;
296
+ return true
301
297
}
302
298
}
303
- }
304
- }
305
- self . payment_preimages = pruned_payment_preimages;
299
+ for ( _tx, htlcs) in remote_claimable_outpoints {
300
+ for htlc in htlcs {
301
+ if k == htlc. payment_hash {
302
+ return true
303
+ }
304
+ }
305
+ }
306
+ false
307
+ } ) ;
306
308
307
309
Ok ( ( ) )
308
310
}
309
-
311
+
310
312
/// Informs this monitor of the latest remote (ie non-broadcastable) commitment transaction.
311
313
/// The monitor watches for it to be broadcasted and then uses the HTLC information (and
312
314
/// possibly future revocation/preimage information) to claim outputs where possible.
0 commit comments