@@ -256,7 +256,6 @@ pub struct ChannelManager {
256
256
tx_broadcaster : Arc < BroadcasterInterface > ,
257
257
258
258
announce_channels_publicly : bool ,
259
- fee_proportional_millionths : u32 ,
260
259
latest_block_height : AtomicUsize ,
261
260
secp_ctx : Secp256k1 < secp256k1:: All > ,
262
261
@@ -307,22 +306,19 @@ pub struct ChannelDetails {
307
306
impl ChannelManager {
308
307
/// Constructs a new ChannelManager to hold several channels and route between them. This is
309
308
/// the main "logic hub" for all channel-related actions, and implements ChannelMessageHandler.
310
- /// fee_proportional_millionths is an optional fee to charge any payments routed through us.
311
309
/// Non-proportional fees are fixed according to our risk using the provided fee estimator.
312
310
/// panics if channel_value_satoshis is >= `MAX_FUNDING_SATOSHIS`!
313
- pub fn new ( our_network_key : SecretKey , fee_proportional_millionths : u32 , announce_channels_publicly : bool , network : Network , feeest : Arc < FeeEstimator > , monitor : Arc < ManyChannelMonitor > , chain_monitor : Arc < ChainWatchInterface > , tx_broadcaster : Arc < BroadcasterInterface > , logger : Arc < Logger > ) -> Result < Arc < ChannelManager > , secp256k1:: Error > {
311
+ pub fn new ( our_network_key : SecretKey , fee_proportional_millionths : u32 , announce_channels_publicly : bool , network : Network , feeest : Arc < FeeEstimator > , monitor : Arc < ManyChannelMonitor > , chain_monitor : Arc < ChainWatchInterface > , tx_broadcaster : Arc < BroadcasterInterface > , logger : Arc < Logger > , config : UserConfigurations ) -> Result < Arc < ChannelManager > , secp256k1:: Error > {
314
312
let secp_ctx = Secp256k1 :: new ( ) ;
315
-
316
313
let res = Arc :: new ( ChannelManager {
317
- configuration : UserConfigurations :: new ( ) ,
314
+ configuration : config ,
318
315
genesis_hash : genesis_block ( network) . header . bitcoin_hash ( ) ,
319
316
fee_estimator : feeest. clone ( ) ,
320
317
monitor : monitor. clone ( ) ,
321
318
chain_monitor,
322
319
tx_broadcaster,
323
320
324
- announce_channels_publicly,
325
- fee_proportional_millionths,
321
+ announce_channels_publicly,
326
322
latest_block_height : AtomicUsize :: new ( 0 ) , //TODO: Get an init value (generally need to replay recent chain on chain_monitor registration)
327
323
secp_ctx,
328
324
@@ -917,7 +913,7 @@ impl ChannelManager {
917
913
if !chan. is_live ( ) {
918
914
Some ( ( "Forwarding channel is not in a ready state." , 0x1000 | 7 , self . get_channel_update ( chan) . unwrap ( ) ) )
919
915
} else {
920
- let fee = amt_to_forward. checked_mul ( self . fee_proportional_millionths as u64 ) . and_then ( |prop_fee| { ( prop_fee / 1000000 ) . checked_add ( chan. get_our_fee_base_msat ( & * self . fee_estimator ) as u64 ) } ) ;
916
+ let fee = amt_to_forward. checked_mul ( self . configuration . channel_options . fee_proportional_millionths as u64 ) . and_then ( |prop_fee| { ( prop_fee / 1000000 ) . checked_add ( chan. get_our_fee_base_msat ( & * self . fee_estimator ) as u64 ) } ) ;
921
917
if fee. is_none ( ) || msg. amount_msat < fee. unwrap ( ) || ( msg. amount_msat - fee. unwrap ( ) ) < * amt_to_forward {
922
918
Some ( ( "Prior hop has deviated from specified fees parameters or origin node has obsolete ones" , 0x1000 | 12 , self . get_channel_update ( chan) . unwrap ( ) ) )
923
919
} else {
@@ -954,7 +950,7 @@ impl ChannelManager {
954
950
cltv_expiry_delta : CLTV_EXPIRY_DELTA ,
955
951
htlc_minimum_msat : chan. get_our_htlc_minimum_msat ( ) ,
956
952
fee_base_msat : chan. get_our_fee_base_msat ( & * self . fee_estimator ) ,
957
- fee_proportional_millionths : self . fee_proportional_millionths ,
953
+ fee_proportional_millionths : self . configuration . channel_options . fee_proportional_millionths ,
958
954
excess_data : Vec :: new ( ) ,
959
955
} ;
960
956
@@ -1486,7 +1482,8 @@ impl ChannelManager {
1486
1482
pending_events. push ( events:: Event :: FundingGenerationReady {
1487
1483
temporary_channel_id : msg. temporary_channel_id ,
1488
1484
channel_value_satoshis : value,
1489
- output_script : output_script, user_channel_id : user_id,
1485
+ output_script : output_script,
1486
+ user_channel_id : user_id,
1490
1487
} ) ;
1491
1488
Ok ( ( ) )
1492
1489
}
@@ -2996,6 +2993,8 @@ mod tests {
2996
2993
}
2997
2994
2998
2995
fn create_network ( node_count : usize ) -> Vec < Node > {
2996
+ use util:: UserConfigurations ;
2997
+
2999
2998
let mut nodes = Vec :: new ( ) ;
3000
2999
let mut rng = thread_rng ( ) ;
3001
3000
let secp_ctx = Secp256k1 :: new ( ) ;
@@ -3014,7 +3013,8 @@ mod tests {
3014
3013
rng. fill_bytes ( & mut key_slice) ;
3015
3014
SecretKey :: from_slice ( & secp_ctx, & key_slice) . unwrap ( )
3016
3015
} ;
3017
- let node = ChannelManager :: new ( node_id. clone ( ) , 0 , true , Network :: Testnet , feeest. clone ( ) , chan_monitor. clone ( ) , chain_monitor. clone ( ) , tx_broadcaster. clone ( ) , Arc :: clone ( & logger) ) . unwrap ( ) ;
3016
+ let config = UserConfigurations :: new ( ) ;
3017
+ let node = ChannelManager :: new ( node_id. clone ( ) , 0 , true , Network :: Testnet , feeest. clone ( ) , chan_monitor. clone ( ) , chain_monitor. clone ( ) , tx_broadcaster. clone ( ) , Arc :: clone ( & logger) , config) . unwrap ( ) ;
3018
3018
let router = Router :: new ( PublicKey :: from_secret_key ( & secp_ctx, & node_id) , chain_monitor. clone ( ) , Arc :: clone ( & logger) ) ;
3019
3019
nodes. push ( Node { chain_monitor, tx_broadcaster, chan_monitor, node, router,
3020
3020
network_payment_count : payment_count. clone ( ) ,
0 commit comments