@@ -275,7 +275,6 @@ pub struct Channel {
275
275
channel_state : u32 ,
276
276
channel_outbound : bool ,
277
277
secp_ctx : Secp256k1 < secp256k1:: All > ,
278
- announce_publicly : bool ,
279
278
channel_value_satoshis : u64 ,
280
279
281
280
local_keys : ChannelKeys ,
@@ -408,7 +407,7 @@ impl Channel {
408
407
}
409
408
410
409
// Constructors:
411
- pub fn new_outbound ( fee_estimator : & FeeEstimator , chan_keys : ChannelKeys , their_node_id : PublicKey , channel_value_satoshis : u64 , push_msat : u64 , announce_publicly : bool , user_id : u64 , logger : Arc < Logger > , configurations : & UserConfigurations ) -> Result < Channel , APIError > {
410
+ pub fn new_outbound ( fee_estimator : & FeeEstimator , chan_keys : ChannelKeys , their_node_id : PublicKey , channel_value_satoshis : u64 , push_msat : u64 , user_id : u64 , logger : Arc < Logger > , configurations : & UserConfigurations ) -> Result < Channel , APIError > {
412
411
if channel_value_satoshis >= MAX_FUNDING_SATOSHIS {
413
412
return Err ( APIError :: APIMisuseError { err : "funding value > 2^24" } ) ;
414
413
}
@@ -440,7 +439,6 @@ impl Channel {
440
439
channel_state : ChannelState :: OurInitSent as u32 ,
441
440
channel_outbound : true ,
442
441
secp_ctx : secp_ctx,
443
- announce_publicly : announce_publicly,
444
442
channel_value_satoshis : channel_value_satoshis,
445
443
446
444
local_keys : chan_keys,
@@ -505,7 +503,7 @@ impl Channel {
505
503
/// Assumes chain_hash has already been checked and corresponds with what we expect!
506
504
/// Generally prefers to take the DisconnectPeer action on failure, as a notice to the sender
507
505
/// that we're rejecting the new channel.
508
- pub fn new_from_req ( fee_estimator : & FeeEstimator , chan_keys : ChannelKeys , their_node_id : PublicKey , msg : & msgs:: OpenChannel , user_id : u64 , require_announce : bool , allow_announce : bool , logger : Arc < Logger > , configurations : & UserConfigurations ) -> Result < Channel , HandleError > {
506
+ pub fn new_from_req ( fee_estimator : & FeeEstimator , chan_keys : ChannelKeys , their_node_id : PublicKey , msg : & msgs:: OpenChannel , user_id : u64 , logger : Arc < Logger > , configurations : & UserConfigurations ) -> Result < Channel , HandleError > {
509
507
macro_rules! return_error_message {
510
508
( $msg: expr ) => {
511
509
return Err ( HandleError { err: $msg, action: Some ( msgs:: ErrorAction :: SendErrorMessage { msg: msgs:: ErrorMessage { channel_id: msg. temporary_channel_id, data: $msg. to_string( ) } } ) } ) ;
@@ -568,10 +566,10 @@ impl Channel {
568
566
// Convert things into internal flags and prep our state:
569
567
570
568
let their_announce = if ( msg. channel_flags & 1 ) == 1 { true } else { false } ;
571
- if require_announce && !their_announce {
569
+ if configurations . channel_options . annouce_channel && !their_announce {
572
570
return_error_message ! ( "Peer tried to open unannounced channel, but we require public ones" ) ;
573
571
}
574
- if !allow_announce && their_announce {
572
+ if !configurations . channel_options . allow_annouce_channel && their_announce {
575
573
return_error_message ! ( "Peer tried to open announced channel, but we require private ones" ) ;
576
574
}
577
575
@@ -619,7 +617,6 @@ impl Channel {
619
617
channel_state : ( ChannelState :: OurInitSent as u32 ) | ( ChannelState :: TheirInitSent as u32 ) ,
620
618
channel_outbound : false ,
621
619
secp_ctx : secp_ctx,
622
- announce_publicly : their_announce,
623
620
624
621
local_keys : chan_keys,
625
622
cur_local_commitment_transaction_number : INITIAL_COMMITMENT_NUMBER ,
@@ -2253,7 +2250,7 @@ impl Channel {
2253
2250
}
2254
2251
2255
2252
pub fn should_announce ( & self ) -> bool {
2256
- self . announce_publicly
2253
+ self . config . channel_options . annouce_channel
2257
2254
}
2258
2255
2259
2256
/// Gets the fee we'd want to charge for adding an HTLC output to this Channel
@@ -2439,7 +2436,7 @@ impl Channel {
2439
2436
delayed_payment_basepoint : PublicKey :: from_secret_key ( & self . secp_ctx , & self . local_keys . delayed_payment_base_key ) ,
2440
2437
htlc_basepoint : PublicKey :: from_secret_key ( & self . secp_ctx , & self . local_keys . htlc_base_key ) ,
2441
2438
first_per_commitment_point : PublicKey :: from_secret_key ( & self . secp_ctx , & local_commitment_secret) ,
2442
- channel_flags : if self . announce_publicly { 1 } else { 0 } ,
2439
+ channel_flags : if self . config . channel_options . allow_annouce_channel { 1 } else { 0 } ,
2443
2440
shutdown_scriptpubkey : None ,
2444
2441
}
2445
2442
}
@@ -2543,7 +2540,7 @@ impl Channel {
2543
2540
/// Note that the "channel must be funded" requirement is stricter than BOLT 7 requires - see
2544
2541
/// https://github.com/lightningnetwork/lightning-rfc/issues/468
2545
2542
pub fn get_channel_announcement ( & self , our_node_id : PublicKey , chain_hash : Sha256dHash ) -> Result < ( msgs:: UnsignedChannelAnnouncement , Signature ) , HandleError > {
2546
- if !self . announce_publicly {
2543
+ if !self . self . config . channel_options . allow_annouce_channel {
2547
2544
return Err ( HandleError { err : "Channel is not available for public announcements" , action : Some ( msgs:: ErrorAction :: IgnoreError ) } ) ;
2548
2545
}
2549
2546
if self . channel_state & ( ChannelState :: ChannelFunded as u32 ) == 0 {
@@ -2905,7 +2902,9 @@ mod tests {
2905
2902
hex:: decode( "023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb" ) . unwrap( ) [ ..] ) ;
2906
2903
2907
2904
let their_node_id = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & secp_ctx, & [ 42 ; 32 ] ) . unwrap ( ) ) ;
2908
- let mut chan = Channel :: new_outbound ( & feeest, chan_keys, their_node_id, 10000000 , 100000 , false , 42 , Arc :: clone ( & logger) , & UserConfigurations :: new ( ) ) . unwrap ( ) ; // Nothing uses their network key in this test
2905
+ let mut config = UserConfigurations :: new ( ) ;
2906
+ config. channel_options . annouce_channel = false ;
2907
+ let mut chan = Channel :: new_outbound ( & feeest, chan_keys, their_node_id, 10000000 , 100000 , 42 , Arc :: clone ( & logger) , & config) . unwrap ( ) ; // Nothing uses their network key in this test
2909
2908
chan. their_to_self_delay = 144 ;
2910
2909
chan. our_dust_limit_satoshis = 546 ;
2911
2910
0 commit comments