From: Yuntai Kyong Date: Fri, 17 Aug 2018 03:57:51 +0000 (+0900) Subject: Add checking locally derived reserve and dust limit X-Git-Tag: v0.0.12~347^2~2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=1c839ff1035eea3b01f5f9c258826d867e04af24;p=rust-lightning Add checking locally derived reserve and dust limit --- diff --git a/src/ln/channel.rs b/src/ln/channel.rs index f3455a9f5..e2749ffff 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -391,8 +391,13 @@ impl Channel { return Err(APIError::APIMisuseError{err: "push value > channel value"}); } - let feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal); + let background_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background); + if Channel::get_our_channel_reserve_satoshis(channel_value_satoshis) < Channel::derive_our_dust_limit_satoshis(background_feerate) { + return Err(APIError::FeeRateTooHigh{err: format!("Not enough reserve above dust limit can be found at current fee rate({})", background_feerate), feerate: background_feerate}); + } + + let feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal); let secp_ctx = Secp256k1::new(); let our_channel_monitor_claim_key_hash = Hash160::from_data(&PublicKey::from_secret_key(&secp_ctx, &chan_keys.channel_monitor_claim_key).unwrap().serialize());