aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonas Schnelli <dev@jonasschnelli.ch>2017-01-16 11:22:30 +0100
committerJonas Schnelli <dev@jonasschnelli.ch>2017-03-24 10:28:39 +0100
commitbcafca1077cf789ba79d16501a8cbb5d692bf8e6 (patch)
treee138e694f49d7a8f57fe3b78ae6f95c29b86f1e1 /src
parentd0a627a53aa8cc5cd190f54c95b888dff88a4d37 (diff)
downloadbitcoin-bcafca1077cf789ba79d16501a8cbb5d692bf8e6.tar.xz
Make sure we always generate one keypool key at minimum
Diffstat (limited to 'src')
-rw-r--r--src/wallet/wallet.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 488e6690cf..e7ac918b27 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2950,9 +2950,9 @@ bool CWallet::TopUpKeyPool(unsigned int kpSize)
// generate +20% internal keys (minimum 2 keys)
int64_t amountExternal = KeypoolCountExternalKeys();
int64_t amountInternal = setKeyPool.size() - amountExternal;
- int64_t targetInternal = max((int64_t)ceil(nTargetSize * 0.2), (int64_t) 2);
- int64_t missingExternal = max( (int64_t)(nTargetSize - amountExternal), (int64_t) 0);
- int64_t missingInternal = max(targetInternal - amountInternal, (int64_t) 0);
+ int64_t targetInternal = std::max((int64_t)ceil(nTargetSize * 0.2), (int64_t) 2);
+ int64_t missingExternal = std::max(std::max((int64_t) nTargetSize, (int64_t) 1) - amountExternal, (int64_t) 0);
+ int64_t missingInternal = std::max(targetInternal - amountInternal, (int64_t) 0);
if (!IsHDEnabled() || !CanSupportFeature(FEATURE_HD_SPLIT))
{