@@ -303,14 +303,6 @@ struct ReceiveError {
303
303
msg : & ' static str ,
304
304
}
305
305
306
- /// Return value for claim_funds_from_hop
307
- enum ClaimFundsFromHop {
308
- PrevHopForceClosed ,
309
- MonitorUpdateFail ( PublicKey , MsgHandleErrInternal , Option < u64 > ) ,
310
- Success ( u64 ) ,
311
- DuplicateClaim ,
312
- }
313
-
314
306
type ShutdownResult = ( Option < ( OutPoint , ChannelMonitorUpdate ) > , Vec < ( HTLCSource , PaymentHash , PublicKey , [ u8 ; 32 ] ) > ) ;
315
307
316
308
/// Error type returned across the channel_state mutex boundary. When an Err is generated for a
@@ -4336,30 +4328,15 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4336
4328
if valid_mpp {
4337
4329
for htlc in sources. drain ( ..) {
4338
4330
if channel_state. is_none ( ) { channel_state = Some ( self . channel_state . lock ( ) . unwrap ( ) ) ; }
4339
- match self . claim_funds_from_hop ( channel_state. take ( ) . unwrap ( ) , htlc. prev_hop ,
4331
+ if let Err ( ( pk , err ) ) = self . claim_funds_from_hop ( channel_state. take ( ) . unwrap ( ) , htlc. prev_hop ,
4340
4332
payment_preimage,
4341
4333
|_| Some ( MonitorUpdateCompletionAction :: PaymentClaimed { payment_hash } ) )
4342
4334
{
4343
- ClaimFundsFromHop :: MonitorUpdateFail ( pk, err, _) => {
4344
- if let msgs:: ErrorAction :: IgnoreError = err. err . action {
4345
- // We got a temporary failure updating monitor, but will claim the
4346
- // HTLC when the monitor updating is restored (or on chain).
4347
- log_error ! ( self . logger, "Temporary failure claiming HTLC, treating as success: {}" , err. err. err) ;
4348
- } else { errs. push ( ( pk, err) ) ; }
4349
- } ,
4350
- ClaimFundsFromHop :: PrevHopForceClosed => {
4351
- // This should be incredibly rare - we checked that all the channels were
4352
- // open above, though as we release the lock at each loop iteration it's
4353
- // still possible. We should still claim the HTLC on-chain through the
4354
- // closed-channel-update generated in claim_funds_from_hop.
4355
- } ,
4356
- ClaimFundsFromHop :: DuplicateClaim => {
4357
- // While we should never get here in most cases, if we do, it likely
4358
- // indicates that the HTLC was timed out some time ago and is no longer
4359
- // available to be claimed. Thus, it does not make sense to set
4360
- // `claimed_any_htlcs`.
4361
- } ,
4362
- ClaimFundsFromHop :: Success ( _) => { } ,
4335
+ if let msgs:: ErrorAction :: IgnoreError = err. err . action {
4336
+ // We got a temporary failure updating monitor, but will claim the
4337
+ // HTLC when the monitor updating is restored (or on chain).
4338
+ log_error ! ( self . logger, "Temporary failure claiming HTLC, treating as success: {}" , err. err. err) ;
4339
+ } else { errs. push ( ( pk, err) ) ; }
4363
4340
}
4364
4341
}
4365
4342
}
@@ -4386,7 +4363,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4386
4363
fn claim_funds_from_hop < ComplFunc : FnOnce ( Option < u64 > ) -> Option < MonitorUpdateCompletionAction > > ( & self ,
4387
4364
mut channel_state_lock : MutexGuard < ChannelHolder < <K :: Target as KeysInterface >:: Signer > > ,
4388
4365
prev_hop : HTLCPreviousHopData , payment_preimage : PaymentPreimage , completion_action : ComplFunc )
4389
- -> ClaimFundsFromHop {
4366
+ -> Result < ( ) , ( PublicKey , MsgHandleErrInternal ) > {
4390
4367
//TODO: Delay the claimed_funds relaying just like we do outbound relay!
4391
4368
4392
4369
let chan_id = prev_hop. outpoint . to_channel_id ( ) ;
@@ -4402,11 +4379,10 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4402
4379
"Failed to update channel monitor with preimage {:?}: {:?}" ,
4403
4380
payment_preimage, e) ;
4404
4381
self . handle_monitor_update_completion_actions ( completion_action ( Some ( htlc_value_msat) ) ) ;
4405
- return ClaimFundsFromHop :: MonitorUpdateFail (
4382
+ return Err ( (
4406
4383
chan. get ( ) . get_counterparty_node_id ( ) ,
4407
4384
handle_monitor_update_res ! ( self , e, chan, RAACommitmentOrder :: CommitmentFirst , false , msgs. is_some( ) ) . unwrap_err ( ) ,
4408
- Some ( htlc_value_msat)
4409
- ) ;
4385
+ ) ) ;
4410
4386
}
4411
4387
}
4412
4388
if let Some ( ( msg, commitment_signed) ) = msgs {
@@ -4425,9 +4401,9 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4425
4401
} ) ;
4426
4402
}
4427
4403
self . handle_monitor_update_completion_actions ( completion_action ( Some ( htlc_value_msat) ) ) ;
4428
- return ClaimFundsFromHop :: Success ( htlc_value_msat ) ;
4404
+ Ok ( ( ) )
4429
4405
} else {
4430
- return ClaimFundsFromHop :: DuplicateClaim ;
4406
+ Ok ( ( ) )
4431
4407
}
4432
4408
} ,
4433
4409
Err ( ( e, monitor_update) ) => {
@@ -4445,7 +4421,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4445
4421
chan. remove_entry ( ) ;
4446
4422
}
4447
4423
self . handle_monitor_update_completion_actions ( completion_action ( None ) ) ;
4448
- return ClaimFundsFromHop :: MonitorUpdateFail ( counterparty_node_id, res, None ) ;
4424
+ Err ( ( counterparty_node_id, res) )
4449
4425
} ,
4450
4426
}
4451
4427
} else {
@@ -4473,7 +4449,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4473
4449
// generally always allowed to be duplicative (and it's specifically noted in
4474
4450
// `PaymentForwarded`)..
4475
4451
self . handle_monitor_update_completion_actions ( completion_action ( None ) ) ;
4476
- return ClaimFundsFromHop :: PrevHopForceClosed
4452
+ Ok ( ( ) )
4477
4453
}
4478
4454
}
4479
4455
@@ -4565,7 +4541,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4565
4541
} } )
4566
4542
} else { None }
4567
4543
} ) ;
4568
- if let ClaimFundsFromHop :: MonitorUpdateFail ( pk, err, _ ) = res {
4544
+ if let Err ( ( pk, err) ) = res {
4569
4545
let result: Result < ( ) , _ > = Err ( err) ;
4570
4546
let _ = handle_error ! ( self , result, pk) ;
4571
4547
}
0 commit comments