@@ -1734,16 +1734,14 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
1734
1734
}
1735
1735
1736
1736
pub fn update_add_htlc < F > ( & mut self , msg : & msgs:: UpdateAddHTLC , mut pending_forward_state : PendingHTLCStatus , create_pending_htlc_status : F ) -> Result < ( ) , ChannelError >
1737
- where F : for <' a , ' b > Fn ( & ' a Self , & ' b PendingHTLCStatus , u16 ) -> Option < PendingHTLCStatus > {
1737
+ where F : for < ' a > Fn ( & ' a Self , PendingHTLCStatus , u16 ) -> PendingHTLCStatus {
1738
1738
if !self . is_usable ( ) {
1739
1739
// TODO: Note that |20 is defined as "channel FROM the processing
1740
1740
// node has been disabled" (emphasis mine), which seems to imply
1741
1741
// that we can't return |20 for an inbound channel being disabled.
1742
1742
// This probably needs a spec update but should definitely be
1743
1743
// allowed.
1744
- if let Some ( new_state) = create_pending_htlc_status ( self , & pending_forward_state, 0x1000 |20 ) {
1745
- pending_forward_state = new_state;
1746
- }
1744
+ pending_forward_state = create_pending_htlc_status ( self , pending_forward_state, 0x1000 |20 ) ;
1747
1745
}
1748
1746
if ( self . channel_state & ( ChannelState :: ChannelFunded as u32 | ChannelState :: RemoteShutdownSent as u32 ) ) != ( ChannelState :: ChannelFunded as u32 ) {
1749
1747
return Err ( ChannelError :: Close ( "Got add HTLC message when channel was not in an operational state" ) ) ;
@@ -1817,9 +1815,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
1817
1815
// but should help protect us from stuck channels).
1818
1816
let remote_fee_cost_incl_stuck_buffer_msat = 2 * self . next_remote_commit_tx_fee_msat ( 1 + 1 ) ;
1819
1817
if pending_remote_value_msat - msg. amount_msat - chan_reserve_msat < remote_fee_cost_incl_stuck_buffer_msat {
1820
- if let Some ( new_state) = create_pending_htlc_status ( self , & pending_forward_state, 0x1000 |7 ) {
1821
- pending_forward_state = new_state;
1822
- }
1818
+ pending_forward_state = create_pending_htlc_status ( self , pending_forward_state, 0x1000 |7 ) ;
1823
1819
}
1824
1820
} else {
1825
1821
// Check that they won't violate our local required channel reserve by adding this HTLC.
@@ -4696,14 +4692,14 @@ mod tests {
4696
4692
amt_to_forward : max_can_recv + 1 ,
4697
4693
outgoing_cltv_value : htlc_cltv
4698
4694
} ) ;
4699
- let create_pending_htlc_status = |chan : & Channel < EnforcingChannelKeys > , _pending_forward_info : & PendingHTLCStatus , _error_code : u16 | {
4700
- Some ( PendingHTLCStatus :: Fail ( HTLCFailureMsg :: Relay (
4695
+ let create_pending_htlc_status = |chan : & Channel < EnforcingChannelKeys > , _pending_forward_info : PendingHTLCStatus , _error_code : u16 | {
4696
+ PendingHTLCStatus :: Fail ( HTLCFailureMsg :: Relay (
4701
4697
UpdateFailHTLC {
4702
4698
channel_id : chan. channel_id ,
4703
4699
htlc_id : 0 ,
4704
4700
reason : OnionErrorPacket { data : vec ! [ ] } ,
4705
4701
}
4706
- ) ) )
4702
+ ) )
4707
4703
} ;
4708
4704
4709
4705
// Assert that the HTLC was successfully added.
@@ -4718,14 +4714,14 @@ mod tests {
4718
4714
}
4719
4715
4720
4716
// Check that adding an HTLC worth 1 msat less will succeed.
4721
- let create_pending_htlc_status = |chan : & Channel < EnforcingChannelKeys > , _pending_forward_info : & PendingHTLCStatus , _error_code : u16 | {
4722
- Some ( PendingHTLCStatus :: Fail ( HTLCFailureMsg :: Relay (
4717
+ let create_pending_htlc_status = |chan : & Channel < EnforcingChannelKeys > , _pending_forward_info : PendingHTLCStatus , _error_code : u16 | {
4718
+ PendingHTLCStatus :: Fail ( HTLCFailureMsg :: Relay (
4723
4719
UpdateFailHTLC {
4724
4720
channel_id : chan. channel_id ,
4725
4721
htlc_id : 0 ,
4726
4722
reason : OnionErrorPacket { data : vec ! [ ] } ,
4727
4723
}
4728
- ) ) )
4724
+ ) )
4729
4725
} ;
4730
4726
chans[ 1 ] . pending_inbound_htlcs = vec ! [ ] ;
4731
4727
let pending_forward_state = PendingHTLCStatus :: Forward ( PendingHTLCInfo {
@@ -4801,8 +4797,8 @@ mod tests {
4801
4797
outgoing_cltv_value : htlc_cltv
4802
4798
} ) ;
4803
4799
4804
- let create_pending_htlc_status = |_chan : & Channel < EnforcingChannelKeys > , _pending_forward_info : & PendingHTLCStatus , _error_code : u16 | {
4805
- None
4800
+ let create_pending_htlc_status = |_chan : & Channel < EnforcingChannelKeys > , pending_forward_info : PendingHTLCStatus , _error_code : u16 | {
4801
+ pending_forward_info
4806
4802
} ;
4807
4803
4808
4804
match chans[ 0 ] . update_add_htlc ( & msg, pending_forward_state, & create_pending_htlc_status) {
0 commit comments