@@ -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
@@ -4352,29 +4344,15 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4352
4344
if valid_mpp {
4353
4345
for htlc in sources. drain ( ..) {
4354
4346
if channel_state. is_none ( ) { channel_state = Some ( self . channel_state . lock ( ) . unwrap ( ) ) ; }
4355
- match self . claim_funds_from_hop ( channel_state. take ( ) . unwrap ( ) , htlc. prev_hop , payment_preimage,
4347
+ if let Err ( ( pk, err) ) = self . claim_funds_from_hop ( channel_state. take ( ) . unwrap ( ) , htlc. prev_hop ,
4348
+ payment_preimage,
4356
4349
|_| Some ( MonitorUpdateCompletionAction :: PaymentClaimed { payment_hash } ) )
4357
4350
{
4358
- ClaimFundsFromHop :: MonitorUpdateFail ( pk, err, _) => {
4359
- if let msgs:: ErrorAction :: IgnoreError = err. err . action {
4360
- // We got a temporary failure updating monitor, but will claim the
4361
- // HTLC when the monitor updating is restored (or on chain).
4362
- log_error ! ( self . logger, "Temporary failure claiming HTLC, treating as success: {}" , err. err. err) ;
4363
- } else { errs. push ( ( pk, err) ) ; }
4364
- } ,
4365
- ClaimFundsFromHop :: PrevHopForceClosed => {
4366
- // This should be incredibly rare - we checked that all the channels were
4367
- // open above, though as we release the lock at each loop iteration it's
4368
- // still possible. We should still claim the HTLC on-chain through the
4369
- // closed-channel-update generated in claim_funds_from_hop.
4370
- } ,
4371
- ClaimFundsFromHop :: DuplicateClaim => {
4372
- // While we should never get here in most cases, if we do, it likely
4373
- // indicates that the HTLC was timed out some time ago and is no longer
4374
- // available to be claimed. Thus, it does not make sense to set
4375
- // `claimed_any_htlcs`.
4376
- } ,
4377
- ClaimFundsFromHop :: Success ( _) => { } ,
4351
+ if let msgs:: ErrorAction :: IgnoreError = err. err . action {
4352
+ // We got a temporary failure updating monitor, but will claim the
4353
+ // HTLC when the monitor updating is restored (or on chain).
4354
+ log_error ! ( self . logger, "Temporary failure claiming HTLC, treating as success: {}" , err. err. err) ;
4355
+ } else { errs. push ( ( pk, err) ) ; }
4378
4356
}
4379
4357
}
4380
4358
}
@@ -4401,7 +4379,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4401
4379
fn claim_funds_from_hop < ComplFunc : FnOnce ( Option < u64 > ) -> Option < MonitorUpdateCompletionAction > > ( & self ,
4402
4380
mut channel_state_lock : MutexGuard < ChannelHolder < <K :: Target as KeysInterface >:: Signer > > ,
4403
4381
prev_hop : HTLCPreviousHopData , payment_preimage : PaymentPreimage , completion_action : ComplFunc )
4404
- -> ClaimFundsFromHop {
4382
+ -> Result < ( ) , ( PublicKey , MsgHandleErrInternal ) > {
4405
4383
//TODO: Delay the claimed_funds relaying just like we do outbound relay!
4406
4384
4407
4385
let chan_id = prev_hop. outpoint . to_channel_id ( ) ;
@@ -4420,9 +4398,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4420
4398
let err = handle_monitor_update_res ! ( self , e, chan, RAACommitmentOrder :: CommitmentFirst , false , msgs. is_some( ) ) . unwrap_err ( ) ;
4421
4399
mem:: drop ( channel_state_lock) ;
4422
4400
self . handle_monitor_update_completion_actions ( completion_action ( Some ( htlc_value_msat) ) ) ;
4423
- return ClaimFundsFromHop :: MonitorUpdateFail (
4424
- counterparty_node_id, err, Some ( htlc_value_msat)
4425
- ) ;
4401
+ return Err ( ( counterparty_node_id, err) ) ;
4426
4402
}
4427
4403
}
4428
4404
if let Some ( ( msg, commitment_signed) ) = msgs {
@@ -4442,9 +4418,9 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4442
4418
}
4443
4419
mem:: drop ( channel_state_lock) ;
4444
4420
self . handle_monitor_update_completion_actions ( completion_action ( Some ( htlc_value_msat) ) ) ;
4445
- return ClaimFundsFromHop :: Success ( htlc_value_msat ) ;
4421
+ Ok ( ( ) )
4446
4422
} else {
4447
- return ClaimFundsFromHop :: DuplicateClaim ;
4423
+ Ok ( ( ) )
4448
4424
}
4449
4425
} ,
4450
4426
Err ( ( e, monitor_update) ) => {
@@ -4462,7 +4438,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4462
4438
}
4463
4439
mem:: drop ( channel_state_lock) ;
4464
4440
self . handle_monitor_update_completion_actions ( completion_action ( None ) ) ;
4465
- return ClaimFundsFromHop :: MonitorUpdateFail ( counterparty_node_id, res, None ) ;
4441
+ Err ( ( counterparty_node_id, res) )
4466
4442
} ,
4467
4443
}
4468
4444
} else {
@@ -4490,7 +4466,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4490
4466
// generally always allowed to be duplicative (and it's specifically noted in
4491
4467
// `PaymentForwarded`).
4492
4468
self . handle_monitor_update_completion_actions ( completion_action ( None ) ) ;
4493
- return ClaimFundsFromHop :: PrevHopForceClosed
4469
+ Ok ( ( ) )
4494
4470
}
4495
4471
}
4496
4472
@@ -4582,7 +4558,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4582
4558
} } )
4583
4559
} else { None }
4584
4560
} ) ;
4585
- if let ClaimFundsFromHop :: MonitorUpdateFail ( pk, err, _ ) = res {
4561
+ if let Err ( ( pk, err) ) = res {
4586
4562
let result: Result < ( ) , _ > = Err ( err) ;
4587
4563
let _ = handle_error ! ( self , result, pk) ;
4588
4564
}
0 commit comments