Skip to content

Commit ca70c30

Browse files
authored
Merge pull request duality-solutions#364 from duality-solutions/v2.4.25-dmupdates
Update keypool and rescan logic. Update GUI elements. WIP
2 parents 8ff51c6 + 1ce8799 commit ca70c30

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

src/qt/res/css/drk.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,12 @@ margin: 0px 18px 0px 18px;
353353

354354

355355
QScrollBar::handle:vertical { /* Scroll Bar Slider - vertical */
356-
background:#e0e0e0;
356+
background: #494848;
357357
min-height:10px;
358358
}
359359

360360
QScrollBar::handle:horizontal { /* Scroll Bar Slider - horizontal */
361-
background:#e0e0e0;
361+
background: #494848;
362362
min-width:10px;
363363
}
364364

src/wallet/wallet.cpp

+26-12
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlockIndex
14421442
}
14431443
}
14441444
} else {
1445+
TopUpKeyPoolCombo(0, true);
14451446
for (const CTxOut& txout : tx.vout) {
14461447
CScript scriptPubKey = txout.scriptPubKey;
14471448
CTxDestination dest;
@@ -1456,7 +1457,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlockIndex
14561457
CPubKey retrievePubKey;
14571458
if (GetPubKey(keyID, retrievePubKey)) {
14581459
if (ReserveKeyForTransactions(retrievePubKey)) {
1459-
TopUpKeyPoolCombo(0, true);
1460+
SetAddressBook(dest, "", "");
14601461
fNeedToRescanTransactions = true;
14611462
}
14621463
}
@@ -4694,26 +4695,32 @@ bool CWallet::TopUpKeyPoolCombo(unsigned int kpSize, bool fIncreaseSize)
46944695
if (IsLocked(true))
46954696
return false;
46964697

4698+
int64_t amountExternal = setExternalKeyPool.size();
4699+
int64_t amountInternal = setInternalKeyPool.size();
4700+
46974701
// Top up key pool
46984702
unsigned int nTargetSize;
4703+
unsigned int defaultKeyPoolSize = std::max(GetArg("-keypool", DEFAULT_KEYPOOL_SIZE), (int64_t)0);
46994704
if (kpSize > 0)
47004705
nTargetSize = kpSize;
47014706
else {
4702-
nTargetSize = std::max(GetArg("-keypool", DEFAULT_KEYPOOL_SIZE), (int64_t)0);
4707+
if (defaultKeyPoolSize >= DynamicKeyPoolSize) {
4708+
DynamicKeyPoolSize = defaultKeyPoolSize;
4709+
}
4710+
4711+
if (fIncreaseSize) {
4712+
DynamicKeyPoolSize = DynamicKeyPoolSize + 1;
4713+
} //if fIncreaseSize
4714+
4715+
nTargetSize = DynamicKeyPoolSize;
47034716
}
47044717

47054718
// count amount of available keys (internal, external)
47064719
// make sure the keypool of external and internal keys fits the user selected target (-keypool)
4707-
int64_t amountExternal = setExternalKeyPool.size();
4708-
int64_t amountInternal = setInternalKeyPool.size();
4720+
47094721
int64_t missingExternal = std::max(std::max((int64_t)nTargetSize, (int64_t)1) - amountExternal, (int64_t)0);
47104722
int64_t missingInternal = std::max(std::max((int64_t)nTargetSize, (int64_t)1) - amountInternal, (int64_t)0);
47114723

4712-
if (fIncreaseSize) {
4713-
missingExternal = missingExternal + 2;
4714-
missingInternal = missingInternal + 2;
4715-
}
4716-
47174724
if (!IsHDEnabled()) {
47184725
// don't create extra internal keys
47194726
missingInternal = 0;
@@ -4763,7 +4770,11 @@ bool CWallet::TopUpKeyPoolCombo(unsigned int kpSize, bool fIncreaseSize)
47634770
}
47644771

47654772
double dProgress = 100.f * nEnd / (nTargetSize + 1);
4766-
std::string strMsg = strprintf(_("Loading wallet... (%3.2f %%)"), dProgress);
4773+
std::string strMsg = "";
4774+
if (dProgress <= 100)
4775+
strMsg = strprintf(_("Loading wallet... (%3.2f %%)"), dProgress);
4776+
else
4777+
strMsg = strprintf(_("Increasing keypool... (%d)"),amountExternal);
47674778
uiInterface.InitMessage(strMsg);
47684779
}
47694780
}
@@ -4904,7 +4915,9 @@ bool CWallet::ReserveKeyForTransactions(const CPubKey& pubKeyToReserve)
49044915
EraseIndex = true;
49054916
IndexToErase = nIndex;
49064917
ReserveKeyCount++;
4907-
SaveRescanIndex = true;
4918+
if (ReserveKeyCount <= DEFAULT_RESCAN_THRESHOLD) {
4919+
SaveRescanIndex = true;
4920+
}
49084921
}
49094922
it++;
49104923
}
@@ -5697,7 +5710,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile, const bool
56975710
walletInstance->ScanForWalletTransactions(pindexRescan, true);
56985711

56995712
//rescan if boolean is set. go back 100 transactions from most recent transaction involving me.
5700-
while ((walletInstance->fNeedToRescanTransactions) && (walletInstance->ReserveKeyCount > DEFAULT_RESCAN_THRESHOLD)) {
5713+
while ((walletInstance->fNeedToRescanTransactions) && (walletInstance->ReserveKeyCount > 0)) {
57015714
//initialize values
57025715
walletInstance->fNeedToRescanTransactions = false;
57035716
walletInstance->ReserveKeyCount = 0;
@@ -5707,6 +5720,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile, const bool
57075720
computed_rescan_index = chainActive[computed_rescan_index->nHeight - 100];
57085721
}
57095722
walletInstance->ScanForWalletTransactions(computed_rescan_index, true);
5723+
57105724
}
57115725

57125726
LogPrintf(" rescan %15dms\n", GetTimeMillis() - nStart);

src/wallet/wallet.h

+3
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,8 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
804804
std::set<int64_t> setInternalEdKeyPool;
805805
std::set<int64_t> setExternalEdKeyPool;
806806

807+
unsigned int DynamicKeyPoolSize = (int64_t)0;
808+
807809
std::vector<std::vector<unsigned char>> reservedEd25519PubKeys;
808810

809811
int64_t nTimeFirstKey;
@@ -835,6 +837,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
835837
CBlockIndex* rescan_index = nullptr;
836838
int ReserveKeyCount = 0;
837839
bool SaveRescanIndex = false;
840+
//unsigned int DynamicKeyPoolSize = (int64_t)0;
838841

839842
bool WalletNeedsUpgrading()
840843
{

0 commit comments

Comments
 (0)