@@ -1947,8 +1947,9 @@ impl<Signer: Sign> Channel<Signer> {
1947
1947
/// however, fail more than once as we wait for an upstream failure to be irrevocably committed
1948
1948
/// before we fail backwards.
1949
1949
///
1950
- /// If we do fail twice, we debug_assert!(false) and return Ok(()). Thus, will always return
1951
- /// Ok(()) if debug assertions are turned on or preconditions are met.
1950
+ /// If we do fail twice, we `debug_assert!(false)` and return `Ok(None)`. Thus, this will always
1951
+ /// return `Ok(_)` if preconditions are met. In any case, `Err`s will only be
1952
+ /// [`ChannelError::Ignore`].
1952
1953
pub fn queue_fail_htlc < L : Deref > ( & mut self , htlc_id_arg : u64 , err_packet : msgs:: OnionErrorPacket , logger : & L )
1953
1954
-> Result < ( ) , ChannelError > where L :: Target : Logger {
1954
1955
self . fail_htlc ( htlc_id_arg, err_packet, true , logger)
@@ -1959,8 +1960,10 @@ impl<Signer: Sign> Channel<Signer> {
1959
1960
/// an HTLC more than once or fulfill once and then attempt to fail after reconnect. We cannot,
1960
1961
/// however, fail more than once as we wait for an upstream failure to be irrevocably committed
1961
1962
/// before we fail backwards.
1962
- /// If we do fail twice, we debug_assert!(false) and return Ok(None). Thus, will always return
1963
- /// Ok(_) if debug assertions are turned on or preconditions are met.
1963
+ ///
1964
+ /// If we do fail twice, we `debug_assert!(false)` and return `Ok(None)`. Thus, this will always
1965
+ /// return `Ok(_)` if preconditions are met. In any case, `Err`s will only be
1966
+ /// [`ChannelError::Ignore`].
1964
1967
fn fail_htlc < L : Deref > ( & mut self , htlc_id_arg : u64 , err_packet : msgs:: OnionErrorPacket , mut force_holding_cell : bool , logger : & L )
1965
1968
-> Result < Option < msgs:: UpdateFailHTLC > , ChannelError > where L :: Target : Logger {
1966
1969
if ( self . channel_state & ( ChannelState :: ChannelReady as u32 ) ) != ( ChannelState :: ChannelReady as u32 ) {
@@ -2001,7 +2004,7 @@ impl<Signer: Sign> Channel<Signer> {
2001
2004
}
2002
2005
2003
2006
if ( self . channel_state & ( ChannelState :: AwaitingRemoteRevoke as u32 | ChannelState :: PeerDisconnected as u32 | ChannelState :: MonitorUpdateInProgress as u32 ) ) != 0 {
2004
- debug_assert ! ( force_holding_cell, "We don't expect to need to use the holding cell if we weren 't trying to " ) ;
2007
+ debug_assert ! ( force_holding_cell, "!force_holding_cell is only called when emptying the holding cell, so we shouldn 't end up back in it! " ) ;
2005
2008
force_holding_cell = true ;
2006
2009
}
2007
2010
@@ -5501,8 +5504,14 @@ impl<Signer: Sign> Channel<Signer> {
5501
5504
pub fn queue_add_htlc < L : Deref > ( & mut self , amount_msat : u64 , payment_hash : PaymentHash , cltv_expiry : u32 , source : HTLCSource ,
5502
5505
onion_routing_packet : msgs:: OnionPacket , logger : & L )
5503
5506
-> Result < ( ) , ChannelError > where L :: Target : Logger {
5504
- self . send_htlc ( amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, true , logger)
5507
+ self
5508
+ . send_htlc ( amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, true , logger)
5505
5509
. map ( |msg_opt| assert ! ( msg_opt. is_none( ) , "We forced holding cell?" ) )
5510
+ . map_err ( |err| {
5511
+ if let ChannelError :: Ignore ( _) = err { /* fine */ }
5512
+ else { debug_assert ! ( false , "Queueing cannot trigger channel failure" ) ; }
5513
+ err
5514
+ } )
5506
5515
}
5507
5516
5508
5517
/// Adds a pending outbound HTLC to this channel, note that you probably want
0 commit comments