From ae70e8a344818482421828902802e2454d16ad5c Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Fri, 1 Feb 2019 12:07:03 +0300 Subject: [PATCH] Fix negative "keys left since backup" (#2671) --- src/wallet/wallet.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 8f480e7812121..798dd7475673a 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4262,8 +4262,10 @@ void CWallet::KeepKey(int64_t nIndex) if (fFileBacked) { CWalletDB walletdb(strWalletFile); - walletdb.ErasePool(nIndex); - nKeysLeftSinceAutoBackup = nWalletBackups ? nKeysLeftSinceAutoBackup - 1 : 0; + if (walletdb.ErasePool(nIndex)) + --nKeysLeftSinceAutoBackup; + if (!nWalletBackups) + nKeysLeftSinceAutoBackup = 0; } LogPrintf("keypool keep %d\n", nIndex); }