@@ -507,6 +507,7 @@ impl Channel {
507
507
return Err ( HandleError { err: $msg, action: Some ( msgs:: ErrorAction :: SendErrorMessage { msg: msgs:: ErrorMessage { channel_id: msg. temporary_channel_id, data: $msg. to_string( ) } } ) } ) ;
508
508
}
509
509
}
510
+ let mut local_config = ( * configurations) . clone ( ) ;
510
511
511
512
// Check sanity of message fields:
512
513
if msg. funding_satoshis >= MAX_FUNDING_SATOSHIS {
@@ -564,12 +565,16 @@ impl Channel {
564
565
// Convert things into internal flags and prep our state:
565
566
566
567
let their_announce = if ( msg. channel_flags & 1 ) == 1 { true } else { false } ;
567
- if configurations. channel_options . annouce_channel && !their_announce {
568
- return_error_message ! ( "Peer tried to open unannounced channel, but we require public ones" ) ;
569
- }
570
- if !configurations. channel_options . allow_annouce_channel && their_announce {
571
- return_error_message ! ( "Peer tried to open announced channel, but we require private ones" ) ;
568
+ if local_config. channel_options . force_announced_channel_preference {
569
+ if local_config. channel_options . announced_channel && !their_announce {
570
+ return_error_message ! ( "Peer tried to open unannounced channel, but we require public ones" ) ;
571
+ }
572
+ if !local_config. channel_options . announced_channel && their_announce {
573
+ return_error_message ! ( "Peer tried to open announced channel, but we require private ones" ) ;
574
+ }
572
575
}
576
+ //we either accept their preference or the preferences match
577
+ local_config. channel_options . announced_channel = their_announce;
573
578
574
579
let background_feerate = fee_estimator. get_est_sat_per_1000_weight ( ConfirmationTarget :: Background ) ;
575
580
@@ -610,7 +615,7 @@ impl Channel {
610
615
611
616
let mut chan = Channel {
612
617
user_id : user_id,
613
- config : ( * configurations ) . clone ( ) ,
618
+ config : local_config ,
614
619
channel_id : msg. temporary_channel_id ,
615
620
channel_state : ( ChannelState :: OurInitSent as u32 ) | ( ChannelState :: TheirInitSent as u32 ) ,
616
621
channel_outbound : false ,
@@ -2251,7 +2256,7 @@ impl Channel {
2251
2256
}
2252
2257
2253
2258
pub fn should_announce ( & self ) -> bool {
2254
- self . config . channel_options . annouce_channel
2259
+ self . config . channel_options . announced_channel
2255
2260
}
2256
2261
2257
2262
/// Gets the fee we'd want to charge for adding an HTLC output to this Channel
@@ -2437,7 +2442,7 @@ impl Channel {
2437
2442
delayed_payment_basepoint : PublicKey :: from_secret_key ( & self . secp_ctx , & self . local_keys . delayed_payment_base_key ) ,
2438
2443
htlc_basepoint : PublicKey :: from_secret_key ( & self . secp_ctx , & self . local_keys . htlc_base_key ) ,
2439
2444
first_per_commitment_point : PublicKey :: from_secret_key ( & self . secp_ctx , & local_commitment_secret) ,
2440
- channel_flags : if self . config . channel_options . allow_annouce_channel { 1 } else { 0 } ,
2445
+ channel_flags : if self . config . channel_options . announced_channel { 1 } else { 0 } ,
2441
2446
shutdown_scriptpubkey : None ,
2442
2447
}
2443
2448
}
@@ -2541,7 +2546,7 @@ impl Channel {
2541
2546
/// Note that the "channel must be funded" requirement is stricter than BOLT 7 requires - see
2542
2547
/// https://github.com/lightningnetwork/lightning-rfc/issues/468
2543
2548
pub fn get_channel_announcement ( & self , our_node_id : PublicKey , chain_hash : Sha256dHash ) -> Result < ( msgs:: UnsignedChannelAnnouncement , Signature ) , HandleError > {
2544
- if !self . config . channel_options . allow_annouce_channel {
2549
+ if !self . config . channel_options . force_announced_channel_preference {
2545
2550
return Err ( HandleError { err : "Channel is not available for public announcements" , action : Some ( msgs:: ErrorAction :: IgnoreError ) } ) ;
2546
2551
}
2547
2552
if self . channel_state & ( ChannelState :: ChannelFunded as u32 ) == 0 {
@@ -2904,7 +2909,7 @@ mod tests {
2904
2909
2905
2910
let their_node_id = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & secp_ctx, & [ 42 ; 32 ] ) . unwrap ( ) ) ;
2906
2911
let mut config = UserConfigurations :: new ( ) ;
2907
- config. channel_options . annouce_channel = false ;
2912
+ config. channel_options . announced_channel = false ;
2908
2913
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
2914
chan. their_to_self_delay = 144 ;
2910
2915
chan. our_dust_limit_satoshis = 546 ;
0 commit comments