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