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