@@ -445,7 +445,7 @@ impl Channel {
445
445
/// Assumes chain_hash has already been checked and corresponds with what we expect!
446
446
/// Generally prefers to take the DisconnectPeer action on failure, as a notice to the sender
447
447
/// that we're rejecting the new channel.
448
- pub fn new_from_req ( fee_estimator : & FeeEstimator , chan_keys : ChannelKeys , their_node_id : PublicKey , msg : & msgs:: OpenChannel , user_id : u64 , announce_publicly : bool ) -> Result < Channel , HandleError > {
448
+ 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 ) -> Result < Channel , HandleError > {
449
449
// Check sanity of message fields:
450
450
if msg. funding_satoshis >= MAX_FUNDING_SATOSHIS {
451
451
return Err ( HandleError { err : "funding value > 2^24" , action : Some ( msgs:: ErrorAction :: DisconnectPeer { msg : None } ) } ) ;
@@ -476,6 +476,12 @@ impl Channel {
476
476
// Convert things into internal flags and prep our state:
477
477
478
478
let their_announce = if ( msg. channel_flags & 1 ) == 1 { true } else { false } ;
479
+ if require_announce && !their_announce {
480
+ return Err ( HandleError { err : "Peer tried to open unannounced channel, but we require public ones" , action : Some ( msgs:: ErrorAction :: IgnoreError ) } ) ;
481
+ }
482
+ if !allow_announce && their_announce {
483
+ return Err ( HandleError { err : "Peer tried to open announced channel, but we require private ones" , action : Some ( msgs:: ErrorAction :: IgnoreError ) } ) ;
484
+ }
479
485
480
486
let background_feerate = fee_estimator. get_est_sat_per_1000_weight ( ConfirmationTarget :: Background ) ;
481
487
@@ -496,7 +502,7 @@ impl Channel {
496
502
channel_state : ( ChannelState :: OurInitSent as u32 ) | ( ChannelState :: TheirInitSent as u32 ) ,
497
503
channel_outbound : false ,
498
504
secp_ctx : secp_ctx,
499
- announce_publicly : their_announce && announce_publicly ,
505
+ announce_publicly : their_announce,
500
506
501
507
local_keys : chan_keys,
502
508
cur_local_commitment_transaction_number : ( 1 << 48 ) - 1 ,
0 commit comments