Skip to content

Commit

Permalink
wallet: Pass WalletBatch to CWallet::UnsetWalletFlag
Browse files Browse the repository at this point in the history
  • Loading branch information
promag authored and achow101 committed May 18, 2019
1 parent 3b7147b commit c6e4421
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -454,7 +454,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;
Expand Down Expand Up @@ -1555,10 +1555,16 @@ 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");
}

Expand Down
1 change: 1 addition & 0 deletions src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,7 @@ class CWallet final : public CCryptoKeyStore, private interfaces::Chain::Notific

/** Unsets a single wallet flag */
void UnsetWalletFlag(uint64_t flag);
void UnsetWalletFlagWithDB(WalletBatch& batch, uint64_t flag);

/** check if a certain wallet flag is set */
bool IsWalletFlagSet(uint64_t flag);
Expand Down

0 comments on commit c6e4421

Please sign in to comment.