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