]> git.bitcoin.ninja Git - rust-lightning/commitdiff
add 1% chnnel reserve while keeping min value
authorYuntai Kyong <yuntai.kyong@gmail.com>
Fri, 17 Aug 2018 17:12:58 +0000 (13:12 -0400)
committerMatt Corallo <git@bluematt.me>
Fri, 17 Aug 2018 17:18:29 +0000 (13:18 -0400)
if 1000 is always used it will almost always fail test reserve < dust_limit check

src/ln/channel.rs

index e2749ffffb94ba150c7a5c6947b136cef4281f35..d7729a1eca8eb6103c2f9648836a892b307a99aa 100644 (file)
@@ -360,7 +360,8 @@ impl Channel {
 
        /// Guaranteed to return a value no larger than channel_value_satoshis
        fn get_our_channel_reserve_satoshis(channel_value_satoshis: u64) -> u64 {
-               cmp::min(channel_value_satoshis, 1000) //TODO
+               let (q, _) = channel_value_satoshis.overflowing_div(100);
+               cmp::min(channel_value_satoshis, cmp::max(q, 1000)) //TODO
        }
 
        fn derive_our_dust_limit_satoshis(at_open_background_feerate: u64) -> u64 {