@@ -275,14 +275,6 @@ struct ReceiveError {
275
275
msg : & ' static str ,
276
276
}
277
277
278
- /// Return value for claim_funds_from_hop
279
- enum ClaimFundsFromHop {
280
- PrevHopForceClosed ,
281
- MonitorUpdateFail ( PublicKey , MsgHandleErrInternal , Option < u64 > ) ,
282
- Success ( u64 ) ,
283
- DuplicateClaim ,
284
- }
285
-
286
278
type ShutdownResult = ( Option < ( OutPoint , ChannelMonitorUpdate ) > , Vec < ( HTLCSource , PaymentHash , PublicKey , [ u8 ; 32 ] ) > ) ;
287
279
288
280
/// Error type returned across the channel_state mutex boundary. When an Err is generated for a
@@ -4196,30 +4188,15 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4196
4188
if valid_mpp {
4197
4189
for htlc in sources. drain ( ..) {
4198
4190
if channel_state. is_none ( ) { channel_state = Some ( self . channel_state . lock ( ) . unwrap ( ) ) ; }
4199
- match self . claim_funds_from_hop ( channel_state. take ( ) . unwrap ( ) , htlc. prev_hop ,
4191
+ if let Err ( ( pk , err ) ) = self . claim_funds_from_hop ( channel_state. take ( ) . unwrap ( ) , htlc. prev_hop ,
4200
4192
payment_preimage,
4201
4193
|_| Some ( MonitorUpdateCompletionAction :: PaymentClaimed { payment_hash } ) )
4202
4194
{
4203
- ClaimFundsFromHop :: MonitorUpdateFail ( pk, err, _) => {
4204
- if let msgs:: ErrorAction :: IgnoreError = err. err . action {
4205
- // We got a temporary failure updating monitor, but will claim the
4206
- // HTLC when the monitor updating is restored (or on chain).
4207
- log_error ! ( self . logger, "Temporary failure claiming HTLC, treating as success: {}" , err. err. err) ;
4208
- } else { errs. push ( ( pk, err) ) ; }
4209
- } ,
4210
- ClaimFundsFromHop :: PrevHopForceClosed => {
4211
- // This should be incredibly rare - we checked that all the channels were
4212
- // open above, though as we release the lock at each loop iteration it's
4213
- // still possible. We should still claim the HTLC on-chain through the
4214
- // closed-channel-update generated in claim_funds_from_hop.
4215
- } ,
4216
- ClaimFundsFromHop :: DuplicateClaim => {
4217
- // While we should never get here in most cases, if we do, it likely
4218
- // indicates that the HTLC was timed out some time ago and is no longer
4219
- // available to be claimed. Thus, it does not make sense to set
4220
- // `claimed_any_htlcs`.
4221
- } ,
4222
- ClaimFundsFromHop :: Success ( _) => { } ,
4195
+ if let msgs:: ErrorAction :: IgnoreError = err. err . action {
4196
+ // We got a temporary failure updating monitor, but will claim the
4197
+ // HTLC when the monitor updating is restored (or on chain).
4198
+ log_error ! ( self . logger, "Temporary failure claiming HTLC, treating as success: {}" , err. err. err) ;
4199
+ } else { errs. push ( ( pk, err) ) ; }
4223
4200
}
4224
4201
}
4225
4202
}
@@ -4246,7 +4223,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4246
4223
fn claim_funds_from_hop < ComplFunc : FnOnce ( Option < u64 > ) -> Option < MonitorUpdateCompletionAction > > ( & self ,
4247
4224
mut channel_state_lock : MutexGuard < ChannelHolder < <K :: Target as KeysInterface >:: Signer > > ,
4248
4225
prev_hop : HTLCPreviousHopData , payment_preimage : PaymentPreimage , completion_action : ComplFunc )
4249
- -> ClaimFundsFromHop {
4226
+ -> Result < ( ) , ( PublicKey , MsgHandleErrInternal ) > {
4250
4227
//TODO: Delay the claimed_funds relaying just like we do outbound relay!
4251
4228
4252
4229
let chan_id = prev_hop. outpoint . to_channel_id ( ) ;
@@ -4262,11 +4239,10 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4262
4239
"Failed to update channel monitor with preimage {:?}: {:?}" ,
4263
4240
payment_preimage, e) ;
4264
4241
self . handle_monitor_update_completion_actions ( completion_action ( Some ( htlc_value_msat) ) ) ;
4265
- return ClaimFundsFromHop :: MonitorUpdateFail (
4242
+ return Err ( (
4266
4243
chan. get ( ) . get_counterparty_node_id ( ) ,
4267
4244
handle_monitor_update_res ! ( self , e, chan, RAACommitmentOrder :: CommitmentFirst , false , msgs. is_some( ) ) . unwrap_err ( ) ,
4268
- Some ( htlc_value_msat)
4269
- ) ;
4245
+ ) ) ;
4270
4246
}
4271
4247
}
4272
4248
if let Some ( ( msg, commitment_signed) ) = msgs {
@@ -4285,9 +4261,9 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4285
4261
} ) ;
4286
4262
}
4287
4263
self . handle_monitor_update_completion_actions ( completion_action ( Some ( htlc_value_msat) ) ) ;
4288
- return ClaimFundsFromHop :: Success ( htlc_value_msat ) ;
4264
+ Ok ( ( ) )
4289
4265
} else {
4290
- return ClaimFundsFromHop :: DuplicateClaim ;
4266
+ Ok ( ( ) )
4291
4267
}
4292
4268
} ,
4293
4269
Err ( ( e, monitor_update) ) => {
@@ -4305,7 +4281,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4305
4281
chan. remove_entry ( ) ;
4306
4282
}
4307
4283
self . handle_monitor_update_completion_actions ( completion_action ( None ) ) ;
4308
- return ClaimFundsFromHop :: MonitorUpdateFail ( counterparty_node_id, res, None ) ;
4284
+ Err ( ( counterparty_node_id, res) )
4309
4285
} ,
4310
4286
}
4311
4287
} else {
@@ -4333,7 +4309,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4333
4309
// generally always allowed to be duplicative (and it's specifically noted in
4334
4310
// `PaymentForwarded`)..
4335
4311
self . handle_monitor_update_completion_actions ( completion_action ( None ) ) ;
4336
- return ClaimFundsFromHop :: PrevHopForceClosed
4312
+ Ok ( ( ) )
4337
4313
}
4338
4314
}
4339
4315
@@ -4425,7 +4401,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4425
4401
} } )
4426
4402
} else { None }
4427
4403
} ) ;
4428
- if let ClaimFundsFromHop :: MonitorUpdateFail ( pk, err, _ ) = res {
4404
+ if let Err ( ( pk, err) ) = res {
4429
4405
let result: Result < ( ) , _ > = Err ( err) ;
4430
4406
let _ = handle_error ! ( self , result, pk) ;
4431
4407
}
0 commit comments