@@ -438,8 +438,9 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
438438 }
439439
440440 // Constructors:
441- pub fn new_outbound < K : Deref > ( fee_estimator : & FeeEstimator , keys_provider : & K , their_node_id : PublicKey , channel_value_satoshis : u64 , push_msat : u64 , user_id : u64 , logger : Arc < Logger > , config : & UserConfig ) -> Result < Channel < ChanSigner > , APIError >
442- where K :: Target : KeysInterface < ChanKeySigner = ChanSigner >
441+ pub fn new_outbound < K : Deref , F : Deref > ( fee_estimator : & F , keys_provider : & K , their_node_id : PublicKey , channel_value_satoshis : u64 , push_msat : u64 , user_id : u64 , logger : Arc < Logger > , config : & UserConfig ) -> Result < Channel < ChanSigner > , APIError >
442+ where K :: Target : KeysInterface < ChanKeySigner = ChanSigner > ,
443+ F :: Target : FeeEstimator ,
443444 {
444445 let chan_keys = keys_provider. get_channel_keys ( false , channel_value_satoshis) ;
445446
@@ -541,7 +542,9 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
541542 } )
542543 }
543544
544- fn check_remote_fee ( fee_estimator : & FeeEstimator , feerate_per_kw : u32 ) -> Result < ( ) , ChannelError > {
545+ fn check_remote_fee < F : Deref > ( fee_estimator : & F , feerate_per_kw : u32 ) -> Result < ( ) , ChannelError >
546+ where F :: Target : FeeEstimator
547+ {
545548 if ( feerate_per_kw as u64 ) < fee_estimator. get_est_sat_per_1000_weight ( ConfirmationTarget :: Background ) {
546549 return Err ( ChannelError :: Close ( "Peer's feerate much too low" ) ) ;
547550 }
@@ -553,8 +556,9 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
553556
554557 /// Creates a new channel from a remote sides' request for one.
555558 /// Assumes chain_hash has already been checked and corresponds with what we expect!
556- pub fn new_from_req < K : Deref > ( fee_estimator : & FeeEstimator , keys_provider : & K , their_node_id : PublicKey , their_features : InitFeatures , msg : & msgs:: OpenChannel , user_id : u64 , logger : Arc < Logger > , config : & UserConfig ) -> Result < Channel < ChanSigner > , ChannelError >
557- where K :: Target : KeysInterface < ChanKeySigner = ChanSigner >
559+ pub fn new_from_req < K : Deref , F : Deref > ( fee_estimator : & F , keys_provider : & K , their_node_id : PublicKey , their_features : InitFeatures , msg : & msgs:: OpenChannel , user_id : u64 , logger : Arc < Logger > , config : & UserConfig ) -> Result < Channel < ChanSigner > , ChannelError >
560+ where K :: Target : KeysInterface < ChanKeySigner = ChanSigner > ,
561+ F :: Target : FeeEstimator
558562 {
559563 let mut chan_keys = keys_provider. get_channel_keys ( true , msg. funding_satoshis ) ;
560564 let their_pubkeys = ChannelPublicKeys {
@@ -1777,7 +1781,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
17771781 Ok ( ( ) )
17781782 }
17791783
1780- pub fn commitment_signed ( & mut self , msg : & msgs:: CommitmentSigned , fee_estimator : & FeeEstimator ) -> Result < ( msgs:: RevokeAndACK , Option < msgs:: CommitmentSigned > , Option < msgs:: ClosingSigned > , ChannelMonitorUpdate ) , ( Option < ChannelMonitorUpdate > , ChannelError ) > {
1784+ pub fn commitment_signed < F : Deref > ( & mut self , msg : & msgs:: CommitmentSigned , fee_estimator : & F ) -> Result < ( msgs:: RevokeAndACK , Option < msgs:: CommitmentSigned > , Option < msgs:: ClosingSigned > , ChannelMonitorUpdate ) , ( Option < ChannelMonitorUpdate > , ChannelError ) > where F :: Target : FeeEstimator {
17811785 if ( self . channel_state & ( ChannelState :: ChannelFunded as u32 ) ) != ( ChannelState :: ChannelFunded as u32 ) {
17821786 return Err ( ( None , ChannelError :: Close ( "Got commitment signed message when channel was not in an operational state" ) ) ) ;
17831787 }
@@ -2065,7 +2069,9 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
20652069 /// waiting on this revoke_and_ack. The generation of this new commitment_signed may also fail,
20662070 /// generating an appropriate error *after* the channel state has been updated based on the
20672071 /// revoke_and_ack message.
2068- pub fn revoke_and_ack ( & mut self , msg : & msgs:: RevokeAndACK , fee_estimator : & FeeEstimator ) -> Result < ( Option < msgs:: CommitmentUpdate > , Vec < ( PendingHTLCInfo , u64 ) > , Vec < ( HTLCSource , PaymentHash , HTLCFailReason ) > , Option < msgs:: ClosingSigned > , ChannelMonitorUpdate ) , ChannelError > {
2072+ pub fn revoke_and_ack < F : Deref > ( & mut self , msg : & msgs:: RevokeAndACK , fee_estimator : & F ) -> Result < ( Option < msgs:: CommitmentUpdate > , Vec < ( PendingHTLCInfo , u64 ) > , Vec < ( HTLCSource , PaymentHash , HTLCFailReason ) > , Option < msgs:: ClosingSigned > , ChannelMonitorUpdate ) , ChannelError >
2073+ where F :: Target : FeeEstimator
2074+ {
20692075 if ( self . channel_state & ( ChannelState :: ChannelFunded as u32 ) ) != ( ChannelState :: ChannelFunded as u32 ) {
20702076 return Err ( ChannelError :: Close ( "Got revoke/ACK message when channel was not in an operational state" ) ) ;
20712077 }
@@ -2463,7 +2469,9 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
24632469 ( raa, commitment_update, order, forwards, failures, needs_broadcast_safe, funding_locked)
24642470 }
24652471
2466- pub fn update_fee ( & mut self , fee_estimator : & FeeEstimator , msg : & msgs:: UpdateFee ) -> Result < ( ) , ChannelError > {
2472+ pub fn update_fee < F : Deref > ( & mut self , fee_estimator : & F , msg : & msgs:: UpdateFee ) -> Result < ( ) , ChannelError >
2473+ where F :: Target : FeeEstimator
2474+ {
24672475 if self . channel_outbound {
24682476 return Err ( ChannelError :: Close ( "Non-funding remote tried to update channel fee" ) ) ;
24692477 }
@@ -2684,7 +2692,9 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
26842692 }
26852693 }
26862694
2687- fn maybe_propose_first_closing_signed ( & mut self , fee_estimator : & FeeEstimator ) -> Option < msgs:: ClosingSigned > {
2695+ fn maybe_propose_first_closing_signed < F : Deref > ( & mut self , fee_estimator : & F ) -> Option < msgs:: ClosingSigned >
2696+ where F :: Target : FeeEstimator
2697+ {
26882698 if !self . channel_outbound || !self . pending_inbound_htlcs . is_empty ( ) || !self . pending_outbound_htlcs . is_empty ( ) ||
26892699 self . channel_state & ( BOTH_SIDES_SHUTDOWN_MASK | ChannelState :: AwaitingRemoteRevoke as u32 ) != BOTH_SIDES_SHUTDOWN_MASK ||
26902700 self . last_sent_closing_fee . is_some ( ) || self . pending_update_fee . is_some ( ) {
@@ -2712,7 +2722,9 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
27122722 } )
27132723 }
27142724
2715- pub fn shutdown ( & mut self , fee_estimator : & FeeEstimator , msg : & msgs:: Shutdown ) -> Result < ( Option < msgs:: Shutdown > , Option < msgs:: ClosingSigned > , Vec < ( HTLCSource , PaymentHash ) > ) , ChannelError > {
2725+ pub fn shutdown < F : Deref > ( & mut self , fee_estimator : & F , msg : & msgs:: Shutdown ) -> Result < ( Option < msgs:: Shutdown > , Option < msgs:: ClosingSigned > , Vec < ( HTLCSource , PaymentHash ) > ) , ChannelError >
2726+ where F :: Target : FeeEstimator
2727+ {
27162728 if self . channel_state & ( ChannelState :: PeerDisconnected as u32 ) == ChannelState :: PeerDisconnected as u32 {
27172729 return Err ( ChannelError :: Close ( "Peer sent shutdown when we needed a channel_reestablish" ) ) ;
27182730 }
@@ -2808,7 +2820,9 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
28082820 tx. input [ 0 ] . witness . push ( self . get_funding_redeemscript ( ) . into_bytes ( ) ) ;
28092821 }
28102822
2811- pub fn closing_signed ( & mut self , fee_estimator : & FeeEstimator , msg : & msgs:: ClosingSigned ) -> Result < ( Option < msgs:: ClosingSigned > , Option < Transaction > ) , ChannelError > {
2823+ pub fn closing_signed < F : Deref > ( & mut self , fee_estimator : & F , msg : & msgs:: ClosingSigned ) -> Result < ( Option < msgs:: ClosingSigned > , Option < Transaction > ) , ChannelError >
2824+ where F :: Target : FeeEstimator
2825+ {
28122826 if self . channel_state & BOTH_SIDES_SHUTDOWN_MASK != BOTH_SIDES_SHUTDOWN_MASK {
28132827 return Err ( ChannelError :: Close ( "Remote end sent us a closing_signed before both sides provided a shutdown" ) ) ;
28142828 }
@@ -3026,7 +3040,9 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
30263040
30273041 /// Gets the fee we'd want to charge for adding an HTLC output to this Channel
30283042 /// Allowed in any state (including after shutdown)
3029- pub fn get_our_fee_base_msat ( & self , fee_estimator : & FeeEstimator ) -> u32 {
3043+ pub fn get_our_fee_base_msat < F : Deref > ( & self , fee_estimator : & F ) -> u32
3044+ where F :: Target : FeeEstimator
3045+ {
30303046 // For lack of a better metric, we calculate what it would cost to consolidate the new HTLC
30313047 // output value back into a transaction with the regular channel output:
30323048
@@ -3230,7 +3246,9 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
32303246 // Methods to get unprompted messages to send to the remote end (or where we already returned
32313247 // something in the handler for the message that prompted this message):
32323248
3233- pub fn get_open_channel ( & self , chain_hash : Sha256dHash , fee_estimator : & FeeEstimator ) -> msgs:: OpenChannel {
3249+ pub fn get_open_channel < F : Deref > ( & self , chain_hash : Sha256dHash , fee_estimator : & F ) -> msgs:: OpenChannel
3250+ where F :: Target : FeeEstimator
3251+ {
32343252 if !self . channel_outbound {
32353253 panic ! ( "Tried to open a channel for an inbound channel?" ) ;
32363254 }
@@ -4338,12 +4356,12 @@ mod tests {
43384356
43394357 assert_eq ! ( PublicKey :: from_secret_key( & secp_ctx, chan_keys. funding_key( ) ) . serialize( ) [ ..] ,
43404358 hex:: decode( "023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb" ) . unwrap( ) [ ..] ) ;
4341- let keys_provider: Arc < KeysInterface < ChanKeySigner = InMemoryChannelKeys > > = Arc :: new ( Keys { chan_keys } ) ;
4359+ let keys_provider = Keys { chan_keys } ;
43424360
43434361 let their_node_id = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
43444362 let mut config = UserConfig :: default ( ) ;
43454363 config. channel_options . announced_channel = false ;
4346- let mut chan = Channel :: < InMemoryChannelKeys > :: new_outbound ( & feeest, & keys_provider, their_node_id, 10000000 , 100000 , 42 , Arc :: clone ( & logger) , & config) . unwrap ( ) ; // Nothing uses their network key in this test
4364+ let mut chan = Channel :: < InMemoryChannelKeys > :: new_outbound ( & & feeest, & & keys_provider, their_node_id, 10000000 , 100000 , 42 , Arc :: clone ( & logger) , & config) . unwrap ( ) ; // Nothing uses their network key in this test
43474365 chan. their_to_self_delay = 144 ;
43484366 chan. our_dust_limit_satoshis = 546 ;
43494367
0 commit comments