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