X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Fwallet.cpp;h=e77fe80ea49899cad243fe949ae378c5d8155eef;hp=67a1859733851451707507dbf4bed453b6d72107;hb=8a813e2fd53405027be2c1099f76768fb0417b40;hpb=7393f26356680386cdf0af9f3270727187638973 diff --git a/src/wallet.cpp b/src/wallet.cpp index 67a1859..e77fe80 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -2256,7 +2256,7 @@ bool GetWalletFile(CWallet* pwallet, string &strWalletFileOut) // Mark old keypool keys as used, // and generate all new keys // -bool CWallet::NewKeyPool() +bool CWallet::NewKeyPool(unsigned int nSize) { { LOCK(cs_wallet); @@ -2268,14 +2268,19 @@ bool CWallet::NewKeyPool() if (IsLocked()) return false; - int64_t nKeys = max(GetArg("-keypool", 100), (int64_t)0); - for (int i = 0; i < nKeys; i++) + uint64_t nKeys; + if (nSize > 0) + nKeys = nSize; + else + nKeys = max(GetArg("-keypool", 100), 0); + + for (uint64_t i = 0; i < nKeys; i++) { - int64_t nIndex = i+1; + uint64_t nIndex = i+1; walletdb.WritePool(nIndex, CKeyPool(GenerateNewKey())); setKeyPool.insert(nIndex); } - printf("CWallet::NewKeyPool wrote %" PRId64 " new keys\n", nKeys); + printf("CWallet::NewKeyPool wrote %" PRIu64 " new keys\n", nKeys); } return true; } @@ -2291,21 +2296,21 @@ bool CWallet::TopUpKeyPool(unsigned int nSize) CWalletDB walletdb(strWalletFile); // Top up key pool - unsigned int nTargetSize; + uint64_t nTargetSize; if (nSize > 0) nTargetSize = nSize; else - nTargetSize = max(GetArg("-keypool", 100), 0LL); + nTargetSize = max(GetArg("-keypool", 100), 0); while (setKeyPool.size() < (nTargetSize + 1)) { - int64_t nEnd = 1; + uint64_t nEnd = 1; if (!setKeyPool.empty()) nEnd = *(--setKeyPool.end()) + 1; if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey()))) throw runtime_error("TopUpKeyPool() : writing generated key failed"); setKeyPool.insert(nEnd); - printf("keypool added key %" PRId64 ", size=%" PRIszu "\n", nEnd, setKeyPool.size()); + printf("keypool added key %" PRIu64 ", size=%" PRIszu "\n", nEnd, setKeyPool.size()); } } return true;