@@ -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
@@ -4343,30 +4335,15 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4343
4335
if valid_mpp {
4344
4336
for htlc in sources. drain ( ..) {
4345
4337
if channel_state. is_none ( ) { channel_state = Some ( self . channel_state . lock ( ) . unwrap ( ) ) ; }
4346
- match self . claim_funds_from_hop ( channel_state. take ( ) . unwrap ( ) , htlc. prev_hop ,
4338
+ if let Err ( ( pk , err ) ) = self . claim_funds_from_hop ( channel_state. take ( ) . unwrap ( ) , htlc. prev_hop ,
4347
4339
payment_preimage,
4348
4340
|_| Some ( MonitorUpdateCompletionAction :: PaymentClaimed { payment_hash } ) )
4349
4341
{
4350
- ClaimFundsFromHop :: MonitorUpdateFail ( pk, err, _) => {
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) ) ; }
4356
- } ,
4357
- ClaimFundsFromHop :: PrevHopForceClosed => {
4358
- // This should be incredibly rare - we checked that all the channels were
4359
- // open above, though as we release the lock at each loop iteration it's
4360
- // still possible. We should still claim the HTLC on-chain through the
4361
- // closed-channel-update generated in claim_funds_from_hop.
4362
- } ,
4363
- ClaimFundsFromHop :: DuplicateClaim => {
4364
- // While we should never get here in most cases, if we do, it likely
4365
- // indicates that the HTLC was timed out some time ago and is no longer
4366
- // available to be claimed. Thus, it does not make sense to set
4367
- // `claimed_any_htlcs`.
4368
- } ,
4369
- ClaimFundsFromHop :: Success ( _) => { } ,
4342
+ if let msgs:: ErrorAction :: IgnoreError = err. err . action {
4343
+ // We got a temporary failure updating monitor, but will claim the
4344
+ // HTLC when the monitor updating is restored (or on chain).
4345
+ log_error ! ( self . logger, "Temporary failure claiming HTLC, treating as success: {}" , err. err. err) ;
4346
+ } else { errs. push ( ( pk, err) ) ; }
4370
4347
}
4371
4348
}
4372
4349
}
@@ -4393,7 +4370,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4393
4370
fn claim_funds_from_hop < ComplFunc : FnOnce ( Option < u64 > ) -> Option < MonitorUpdateCompletionAction > > ( & self ,
4394
4371
mut channel_state_lock : MutexGuard < ChannelHolder < <K :: Target as KeysInterface >:: Signer > > ,
4395
4372
prev_hop : HTLCPreviousHopData , payment_preimage : PaymentPreimage , completion_action : ComplFunc )
4396
- -> ClaimFundsFromHop {
4373
+ -> Result < ( ) , ( PublicKey , MsgHandleErrInternal ) > {
4397
4374
//TODO: Delay the claimed_funds relaying just like we do outbound relay!
4398
4375
4399
4376
let chan_id = prev_hop. outpoint . to_channel_id ( ) ;
@@ -4409,11 +4386,10 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4409
4386
"Failed to update channel monitor with preimage {:?}: {:?}" ,
4410
4387
payment_preimage, e) ;
4411
4388
self . handle_monitor_update_completion_actions ( completion_action ( Some ( htlc_value_msat) ) ) ;
4412
- return ClaimFundsFromHop :: MonitorUpdateFail (
4389
+ return Err ( (
4413
4390
chan. get ( ) . get_counterparty_node_id ( ) ,
4414
4391
handle_monitor_update_res ! ( self , e, chan, RAACommitmentOrder :: CommitmentFirst , false , msgs. is_some( ) ) . unwrap_err ( ) ,
4415
- Some ( htlc_value_msat)
4416
- ) ;
4392
+ ) ) ;
4417
4393
}
4418
4394
}
4419
4395
if let Some ( ( msg, commitment_signed) ) = msgs {
@@ -4432,9 +4408,9 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4432
4408
} ) ;
4433
4409
}
4434
4410
self . handle_monitor_update_completion_actions ( completion_action ( Some ( htlc_value_msat) ) ) ;
4435
- return ClaimFundsFromHop :: Success ( htlc_value_msat ) ;
4411
+ Ok ( ( ) )
4436
4412
} else {
4437
- return ClaimFundsFromHop :: DuplicateClaim ;
4413
+ Ok ( ( ) )
4438
4414
}
4439
4415
} ,
4440
4416
Err ( ( e, monitor_update) ) => {
@@ -4452,7 +4428,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4452
4428
chan. remove_entry ( ) ;
4453
4429
}
4454
4430
self . handle_monitor_update_completion_actions ( completion_action ( None ) ) ;
4455
- return ClaimFundsFromHop :: MonitorUpdateFail ( counterparty_node_id, res, None ) ;
4431
+ Err ( ( counterparty_node_id, res) )
4456
4432
} ,
4457
4433
}
4458
4434
} else {
@@ -4480,7 +4456,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4480
4456
// generally always allowed to be duplicative (and it's specifically noted in
4481
4457
// `PaymentForwarded`)..
4482
4458
self . handle_monitor_update_completion_actions ( completion_action ( None ) ) ;
4483
- return ClaimFundsFromHop :: PrevHopForceClosed
4459
+ Ok ( ( ) )
4484
4460
}
4485
4461
}
4486
4462
@@ -4572,7 +4548,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4572
4548
} } )
4573
4549
} else { None }
4574
4550
} ) ;
4575
- if let ClaimFundsFromHop :: MonitorUpdateFail ( pk, err, _ ) = res {
4551
+ if let Err ( ( pk, err) ) = res {
4576
4552
let result: Result < ( ) , _ > = Err ( err) ;
4577
4553
let _ = handle_error ! ( self , result, pk) ;
4578
4554
}
0 commit comments