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