aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2019-10-29 17:53:35 -0400
committerAndrew Chow <achow101-github@achow101.com>2019-11-01 22:58:05 -0400
commitfc2867fdf50f47e5ad5f43445e500e3a477a8074 (patch)
tree09a6d8d8b7b99d434c00ef0731755c1d19f61066 /src
parent78e7cbc7ba5938ab2ae6347141ca793a8fc09853 (diff)
downloadbitcoin-fc2867fdf50f47e5ad5f43445e500e3a477a8074.tar.xz
refactor: Replace UnsetWalletFlagWithDB with UnsetBlankWalletFlag in ScriptPubKeyMan
ScriptPubKeyMan is only using UnsetWalletFlagWithDB to unset the blank wallet flag. Just make that it's own function and not expose the flag writing directly. This does not change behavior.
Diffstat (limited to 'src')
-rw-r--r--src/wallet/scriptpubkeyman.cpp8
-rw-r--r--src/wallet/scriptpubkeyman.h2
-rw-r--r--src/wallet/wallet.cpp5
-rw-r--r--src/wallet/wallet.h5
4 files changed, 14 insertions, 6 deletions
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp
index 3c57232d11..1d7483df12 100644
--- a/src/wallet/scriptpubkeyman.cpp
+++ b/src/wallet/scriptpubkeyman.cpp
@@ -440,7 +440,7 @@ bool LegacyScriptPubKeyMan::AddKeyPubKeyWithDB(WalletBatch& batch, const CKey& s
secret.GetPrivKey(),
mapKeyMetadata[pubkey.GetID()]);
}
- m_storage.UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET);
+ m_storage.UnsetBlankWalletFlag(batch);
return true;
}
@@ -597,7 +597,7 @@ bool LegacyScriptPubKeyMan::AddWatchOnlyWithDB(WalletBatch &batch, const CScript
UpdateTimeFirstKey(meta.nCreateTime);
NotifyWatchonlyChanged(true);
if (batch.WriteWatchOnly(dest, meta)) {
- m_storage.UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET);
+ m_storage.UnsetBlankWalletFlag(batch);
return true;
}
return false;
@@ -876,7 +876,7 @@ void LegacyScriptPubKeyMan::SetHDSeed(const CPubKey& seed)
SetHDChain(newHdChain, false);
NotifyCanGetAddressesChanged();
WalletBatch batch(m_storage.GetDatabase());
- m_storage.UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET);
+ m_storage.UnsetBlankWalletFlag(batch);
}
/**
@@ -1155,7 +1155,7 @@ bool LegacyScriptPubKeyMan::AddCScriptWithDB(WalletBatch& batch, const CScript&
if (!FillableSigningProvider::AddCScript(redeemScript))
return false;
if (batch.WriteCScript(Hash160(redeemScript), redeemScript)) {
- m_storage.UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET);
+ m_storage.UnsetBlankWalletFlag(batch);
return true;
}
return false;
diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h
index 0ef62e3f50..730229beb5 100644
--- a/src/wallet/scriptpubkeyman.h
+++ b/src/wallet/scriptpubkeyman.h
@@ -28,7 +28,7 @@ public:
virtual const std::string GetDisplayName() const = 0;
virtual WalletDatabase& GetDatabase() = 0;
virtual bool IsWalletFlagSet(uint64_t) const = 0;
- virtual void UnsetWalletFlagWithDB(WalletBatch&, uint64_t) = 0;
+ virtual void UnsetBlankWalletFlag(WalletBatch&) = 0;
virtual bool CanSupportFeature(enum WalletFeature) const = 0;
virtual void SetMinVersion(enum WalletFeature, WalletBatch* = nullptr, bool = false) = 0;
virtual bool IsLocked() const = 0;
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 7af2de224f..88acfdf2aa 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1309,6 +1309,11 @@ void CWallet::UnsetWalletFlagWithDB(WalletBatch& batch, uint64_t flag)
throw std::runtime_error(std::string(__func__) + ": writing wallet flags failed");
}
+void CWallet::UnsetBlankWalletFlag(WalletBatch& batch)
+{
+ UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET);
+}
+
bool CWallet::IsWalletFlagSet(uint64_t flag) const
{
return (m_wallet_flags & flag);
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index cb4dd71b1c..28cbdd66c1 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -660,7 +660,10 @@ private:
bool SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& address, const std::string& strName, const std::string& strPurpose);
//! Unsets a wallet flag and saves it to disk
- void UnsetWalletFlagWithDB(WalletBatch& batch, uint64_t flag) override;
+ void UnsetWalletFlagWithDB(WalletBatch& batch, uint64_t flag);
+
+ //! Unset the blank wallet flag and saves it to disk
+ void UnsetBlankWalletFlag(WalletBatch& batch) override;
/** Interface for accessing chain state. */
interfaces::Chain* m_chain;