diff options
author | João Barbosa <joao.paulo.barbosa@gmail.com> | 2019-05-18 11:01:56 +0100 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2019-05-28 11:03:54 -0400 |
commit | 0db94e55dcbbfc741df463c404818d9033b4fff1 (patch) | |
tree | 12800e57958760e320ef62c0790067a76a27b414 | |
parent | 6cb888b37d7022fbcf5b9c88a8d4f19454f32699 (diff) |
wallet: Pass WalletBatch to CWallet::UnsetWalletFlag
-rw-r--r-- | src/wallet/wallet.cpp | 14 | ||||
-rw-r--r-- | src/wallet/wallet.h | 3 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 2e20c0e0a4..da8b2c3f0c 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -320,7 +320,7 @@ bool CWallet::AddKeyPubKeyWithDB(WalletBatch& batch, const CKey& secret, const C secret.GetPrivKey(), mapKeyMetadata[pubkey.GetID()]); } - UnsetWalletFlag(WALLET_FLAG_BLANK_WALLET); + UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET); return true; } @@ -431,7 +431,7 @@ bool CWallet::AddCScriptWithDB(WalletBatch& batch, const CScript& redeemScript) if (!CCryptoKeyStore::AddCScript(redeemScript)) return false; if (batch.WriteCScript(Hash160(redeemScript), redeemScript)) { - UnsetWalletFlag(WALLET_FLAG_BLANK_WALLET); + UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET); return true; } return false; @@ -460,7 +460,7 @@ bool CWallet::AddWatchOnlyWithDB(WalletBatch &batch, const CScript& dest) UpdateTimeFirstKey(meta.nCreateTime); NotifyWatchonlyChanged(true); if (batch.WriteWatchOnly(dest, meta)) { - UnsetWalletFlag(WALLET_FLAG_BLANK_WALLET); + UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET); return true; } return false; @@ -1562,9 +1562,15 @@ void CWallet::SetWalletFlag(uint64_t flags) void CWallet::UnsetWalletFlag(uint64_t flag) { + WalletBatch batch(*database); + UnsetWalletFlagWithDB(batch, flag); +} + +void CWallet::UnsetWalletFlagWithDB(WalletBatch& batch, uint64_t flag) +{ LOCK(cs_wallet); m_wallet_flags &= ~flag; - if (!WalletBatch(*database).WriteWalletFlags(m_wallet_flags)) + if (!batch.WriteWalletFlags(m_wallet_flags)) throw std::runtime_error(std::string(__func__) + ": writing wallet flags failed"); } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index f627cc59a2..3f6f6808ae 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -720,6 +720,9 @@ private: //! Adds a script to the store and saves it to disk bool AddCScriptWithDB(WalletBatch& batch, const CScript& script); + //! Unsets a wallet flag and saves it to disk + void UnsetWalletFlagWithDB(WalletBatch& batch, uint64_t flag); + /** Interface for accessing chain state. */ interfaces::Chain* m_chain; |