+ if require_announce && !their_announce {
+ return Err(HandleError{err: "Peer tried to open unannounced channel, but we require public ones", action: Some(msgs::ErrorAction::IgnoreError) });
+ }
+ if !allow_announce && their_announce {
+ return Err(HandleError{err: "Peer tried to open announced channel, but we require private ones", action: Some(msgs::ErrorAction::IgnoreError) });
+ }
+
+ let background_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background);
+
+ let our_dust_limit_satoshis = Channel::derive_our_dust_limit_satoshis(background_feerate);
+ let our_channel_reserve_satoshis = Channel::get_our_channel_reserve_satoshis(msg.funding_satoshis);
+ if our_channel_reserve_satoshis < our_dust_limit_satoshis {
+ return_error_message!("Suitalbe channel reserve not found. aborting");
+ }
+ if msg.channel_reserve_satoshis < our_dust_limit_satoshis {
+ return_error_message!("channel_reserve_satoshis too small");
+ }
+ if our_channel_reserve_satoshis < msg.dust_limit_satoshis {
+ return_error_message!("Dust limit too high for our channel reserve");
+ }
+
+ // check if the funder's amount for the initial commitment tx is sufficient
+ // for full fee payment
+ let funders_amount_msat = msg.funding_satoshis * 1000 - msg.push_msat;
+ if funders_amount_msat < background_feerate * COMMITMENT_TX_BASE_WEIGHT {
+ return_error_message!("Insufficient funding amount for initial commitment");
+ }