refactor: remove dependency scriptpubkeyman on uiInterface

This commit is contained in:
Konstantin Akimov 2023-11-21 16:38:38 +07:00 committed by PastaPastaPasta
parent aa48c222ab
commit d95d7f63c9
4 changed files with 13 additions and 4 deletions

View File

@ -8,7 +8,6 @@
#include <script/descriptor.h> #include <script/descriptor.h>
#include <script/sign.h> #include <script/sign.h>
#include <shutdown.h> #include <shutdown.h>
#include <ui_interface.h>
#include <util/bip32.h> #include <util/bip32.h>
#include <util/strencodings.h> #include <util/strencodings.h>
#include <util/system.h> #include <util/system.h>
@ -1437,7 +1436,7 @@ bool LegacyScriptPubKeyMan::TopUpInner(unsigned int kpSize)
int64_t progress_report_time = GetTime(); int64_t progress_report_time = GetTime();
WalletLogPrintf("%s\n", strMsg); WalletLogPrintf("%s\n", strMsg);
if (should_show_progress) { if (should_show_progress) {
uiInterface.ShowProgress(strMsg, 0, false); m_storage.UpdateProgress(strMsg, 0);
} }
bool fInternal = false; bool fInternal = false;
@ -1458,7 +1457,7 @@ bool LegacyScriptPubKeyMan::TopUpInner(unsigned int kpSize)
progress_report_time = GetTime(); progress_report_time = GetTime();
WalletLogPrintf("Still topping up. At key %lld. Progress=%f\n", current_index, dProgress); WalletLogPrintf("Still topping up. At key %lld. Progress=%f\n", current_index, dProgress);
if (should_show_progress) { if (should_show_progress) {
uiInterface.ShowProgress(strMsg, static_cast<int>(dProgress), false); m_storage.UpdateProgress(strMsg, static_cast<int>(dProgress));
} }
} }
if (ShutdownRequested()) break; if (ShutdownRequested()) break;
@ -1466,7 +1465,7 @@ bool LegacyScriptPubKeyMan::TopUpInner(unsigned int kpSize)
WalletLogPrintf("Keypool added %d keys, size=%u (%u internal)\n", WalletLogPrintf("Keypool added %d keys, size=%u (%u internal)\n",
current_index + 1, setInternalKeyPool.size() + setExternalKeyPool.size(), setInternalKeyPool.size()); current_index + 1, setInternalKeyPool.size() + setExternalKeyPool.size(), setInternalKeyPool.size());
if (should_show_progress) { if (should_show_progress) {
uiInterface.ShowProgress("", 100, false); m_storage.UpdateProgress("", 100);
} }
} }
NotifyCanGetAddressesChanged(); NotifyCanGetAddressesChanged();

View File

@ -39,6 +39,9 @@ public:
virtual bool HasEncryptionKeys() const = 0; virtual bool HasEncryptionKeys() const = 0;
virtual bool IsLocked(bool fForMixing = false) const = 0; virtual bool IsLocked(bool fForMixing = false) const = 0;
// for LegacyScriptPubKeyMan::TopUpInner needs:
virtual void UpdateProgress(const std::string&, int) = 0;
// methods below are unique from Dash due to different implementation of HD // methods below are unique from Dash due to different implementation of HD
virtual void NewKeyPoolCallback() = 0; virtual void NewKeyPoolCallback() = 0;
virtual void KeepDestinationCallback(bool erased) = 0; virtual void KeepDestinationCallback(bool erased) = 0;

View File

@ -5501,3 +5501,8 @@ bool CWallet::GenerateNewHDChainEncrypted(const SecureString& secureMnemonic, co
return false; return false;
} }
void CWallet::UpdateProgress(const std::string& title, int nProgress)
{
ShowProgress(title, nProgress);
}

View File

@ -855,6 +855,8 @@ public:
bool IsLocked(bool fForMixing = false) const override; bool IsLocked(bool fForMixing = false) const override;
bool Lock(bool fForMixing = false); bool Lock(bool fForMixing = false);
void UpdateProgress(const std::string& title, int nProgress) override;
std::map<uint256, CWalletTx> mapWallet GUARDED_BY(cs_wallet); std::map<uint256, CWalletTx> mapWallet GUARDED_BY(cs_wallet);
typedef std::multimap<int64_t, CWalletTx*> TxItems; typedef std::multimap<int64_t, CWalletTx*> TxItems;