@@ -1893,31 +1893,34 @@ impl Channel {
18931893
18941894 }
18951895
1896- pub fn send_update_fee ( & mut self , feerate_per_kw : u64 ) -> Result < Option < msgs:: UpdateFee > , HandleError > {
1896+ /// Adds a pending update to this channel. See the doc for send_htlc for
1897+ /// further details on the optionness of the return value.
1898+ /// You MUST call send_commitment prior to any other calls on this Channel
1899+ fn send_update_fee ( & mut self , feerate_per_kw : u64 ) -> Option < msgs:: UpdateFee > {
18971900 if !self . channel_outbound {
1898- return Err ( HandleError { err : "Cannot send fee from inbound channel" , action : None } ) ;
1901+ panic ! ( "Cannot send fee from inbound channel" ) ;
18991902 }
19001903
1901- if ( self . channel_state & ( ChannelState :: ChannelFunded as u32 | BOTH_SIDES_SHUTDOWN_MASK ) ) != ( ChannelState :: ChannelFunded as u32 ) {
1902- return Err ( HandleError { err : "Cannot update fee until channel is fully established and we haven't started shutting down" , action : None } ) ;
1904+ if ! self . is_usable ( ) {
1905+ panic ! ( "Cannot update fee until channel is fully established and we haven't started shutting down" ) ;
19031906 }
19041907
19051908 if ( self . channel_state & ( ChannelState :: AwaitingRemoteRevoke as u32 ) ) == ( ChannelState :: AwaitingRemoteRevoke as u32 ) {
19061909 self . holding_cell_update_fee = Some ( feerate_per_kw) ;
1907- return Ok ( None ) ;
1910+ return None ;
19081911 }
19091912
19101913 debug_assert ! ( self . pending_update_fee. is_none( ) ) ;
19111914 self . pending_update_fee = Some ( feerate_per_kw) ;
19121915
1913- Ok ( Some ( msgs:: UpdateFee {
1916+ Some ( msgs:: UpdateFee {
19141917 channel_id : self . channel_id ,
19151918 feerate_per_kw : feerate_per_kw as u32 ,
1916- } ) )
1919+ } )
19171920 }
19181921
19191922 pub fn send_update_fee_and_commit ( & mut self , feerate_per_kw : u64 ) -> Result < Option < ( msgs:: UpdateFee , msgs:: CommitmentSigned , ChannelMonitor ) > , HandleError > {
1920- match self . send_update_fee ( feerate_per_kw) ? {
1923+ match self . send_update_fee ( feerate_per_kw) {
19211924 Some ( update_fee) => {
19221925 let ( commitment_signed, monitor_update) = self . send_commitment_no_status_check ( ) ?;
19231926 Ok ( Some ( ( update_fee, commitment_signed, monitor_update) ) )
@@ -2348,6 +2351,10 @@ impl Channel {
23482351 self . announce_publicly
23492352 }
23502353
2354+ pub fn is_outbound ( & self ) -> bool {
2355+ self . channel_outbound
2356+ }
2357+
23512358 /// Gets the fee we'd want to charge for adding an HTLC output to this Channel
23522359 /// Allowed in any state (including after shutdown)
23532360 pub fn get_our_fee_base_msat ( & self , fee_estimator : & FeeEstimator ) -> u32 {
0 commit comments