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