wallet: Pass WalletBatch to CWallet::UnsetWalletFlag
This commit is contained in:
parent
6cb888b37d
commit
0db94e55dc
2 changed files with 13 additions and 4 deletions
|
@ -320,7 +320,7 @@ bool CWallet::AddKeyPubKeyWithDB(WalletBatch& batch, const CKey& secret, const C
|
||||||
secret.GetPrivKey(),
|
secret.GetPrivKey(),
|
||||||
mapKeyMetadata[pubkey.GetID()]);
|
mapKeyMetadata[pubkey.GetID()]);
|
||||||
}
|
}
|
||||||
UnsetWalletFlag(WALLET_FLAG_BLANK_WALLET);
|
UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ bool CWallet::AddCScriptWithDB(WalletBatch& batch, const CScript& redeemScript)
|
||||||
if (!CCryptoKeyStore::AddCScript(redeemScript))
|
if (!CCryptoKeyStore::AddCScript(redeemScript))
|
||||||
return false;
|
return false;
|
||||||
if (batch.WriteCScript(Hash160(redeemScript), redeemScript)) {
|
if (batch.WriteCScript(Hash160(redeemScript), redeemScript)) {
|
||||||
UnsetWalletFlag(WALLET_FLAG_BLANK_WALLET);
|
UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -460,7 +460,7 @@ bool CWallet::AddWatchOnlyWithDB(WalletBatch &batch, const CScript& dest)
|
||||||
UpdateTimeFirstKey(meta.nCreateTime);
|
UpdateTimeFirstKey(meta.nCreateTime);
|
||||||
NotifyWatchonlyChanged(true);
|
NotifyWatchonlyChanged(true);
|
||||||
if (batch.WriteWatchOnly(dest, meta)) {
|
if (batch.WriteWatchOnly(dest, meta)) {
|
||||||
UnsetWalletFlag(WALLET_FLAG_BLANK_WALLET);
|
UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1561,10 +1561,16 @@ void CWallet::SetWalletFlag(uint64_t flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::UnsetWalletFlag(uint64_t flag)
|
void CWallet::UnsetWalletFlag(uint64_t flag)
|
||||||
|
{
|
||||||
|
WalletBatch batch(*database);
|
||||||
|
UnsetWalletFlagWithDB(batch, flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CWallet::UnsetWalletFlagWithDB(WalletBatch& batch, uint64_t flag)
|
||||||
{
|
{
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
m_wallet_flags &= ~flag;
|
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");
|
throw std::runtime_error(std::string(__func__) + ": writing wallet flags failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -720,6 +720,9 @@ private:
|
||||||
//! Adds a script to the store and saves it to disk
|
//! Adds a script to the store and saves it to disk
|
||||||
bool AddCScriptWithDB(WalletBatch& batch, const CScript& script);
|
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. */
|
/** Interface for accessing chain state. */
|
||||||
interfaces::Chain* m_chain;
|
interfaces::Chain* m_chain;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue