@@ -1193,28 +1193,32 @@ impl Channel {
1193
1193
self . channel_monitor . provide_payment_preimage ( & payment_hash_calc, & payment_preimage_arg) ;
1194
1194
1195
1195
if ( self . channel_state & ( ChannelState :: AwaitingRemoteRevoke as u32 | ChannelState :: PeerDisconnected as u32 | ChannelState :: MonitorUpdateFailed as u32 ) ) != 0 {
1196
- for pending_update in self . holding_cell_htlc_updates . iter ( ) {
1196
+ let mut need_update = true ;
1197
+ self . holding_cell_htlc_updates . retain ( |pending_update| {
1197
1198
match pending_update {
1198
1199
& HTLCUpdateAwaitingACK :: ClaimHTLC { htlc_id, .. } => {
1199
1200
if htlc_id_arg == htlc_id {
1200
- return Ok ( ( None , None ) ) ;
1201
+ need_update = false ;
1201
1202
}
1203
+ true
1202
1204
} ,
1203
1205
& HTLCUpdateAwaitingACK :: FailHTLC { htlc_id, .. } => {
1204
1206
if htlc_id_arg == htlc_id {
1205
- log_warn ! ( self , "Have preimage and want to fulfill HTLC with pending failure against channel {}" , log_bytes!( self . channel_id( ) ) ) ;
1206
- // TODO: We may actually be able to switch to a fulfill here, though its
1207
- // rare enough it may not be worth the complexity burden.
1208
- return Ok ( ( None , Some ( self . channel_monitor . clone ( ) ) ) ) ;
1207
+ return false
1209
1208
}
1209
+ true
1210
1210
} ,
1211
- _ => { }
1211
+ _ => { true }
1212
1212
}
1213
- }
1214
- self . holding_cell_htlc_updates . push ( HTLCUpdateAwaitingACK :: ClaimHTLC {
1215
- payment_preimage : payment_preimage_arg, htlc_id : htlc_id_arg,
1216
1213
} ) ;
1217
- return Ok ( ( None , Some ( self . channel_monitor . clone ( ) ) ) ) ;
1214
+ if need_update {
1215
+ self . holding_cell_htlc_updates . push ( HTLCUpdateAwaitingACK :: ClaimHTLC {
1216
+ payment_preimage : payment_preimage_arg, htlc_id : htlc_id_arg,
1217
+ } ) ;
1218
+ return Ok ( ( None , Some ( self . channel_monitor . clone ( ) ) ) ) ;
1219
+ } else {
1220
+ return Ok ( ( None , None ) ) ;
1221
+ }
1218
1222
}
1219
1223
1220
1224
{
0 commit comments