Add facility to store wallet flags (64 bits)
This commit is contained in:
parent
5ba77df15d
commit
9995a602a6
4 changed files with 43 additions and 1 deletions
|
@ -1526,6 +1526,28 @@ bool CWallet::IsHDEnabled() const
|
|||
return !hdChain.seed_id.IsNull();
|
||||
}
|
||||
|
||||
void CWallet::SetWalletFlag(uint64_t flags)
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
m_wallet_flags |= flags;
|
||||
if (!WalletBatch(*database).WriteWalletFlags(m_wallet_flags))
|
||||
throw std::runtime_error(std::string(__func__) + ": writing wallet flags failed");
|
||||
}
|
||||
|
||||
bool CWallet::IsWalletFlagSet(uint64_t flag)
|
||||
{
|
||||
return (m_wallet_flags & flag);
|
||||
}
|
||||
|
||||
void CWallet::SetWalletFlags(uint64_t overwriteFlags, bool memonly)
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
m_wallet_flags = overwriteFlags;
|
||||
if (!memonly && !WalletBatch(*database).WriteWalletFlags(m_wallet_flags)) {
|
||||
throw std::runtime_error(std::string(__func__) + ": writing wallet flags failed");
|
||||
}
|
||||
}
|
||||
|
||||
int64_t CWalletTx::GetTxTime() const
|
||||
{
|
||||
int64_t n = nTimeSmart;
|
||||
|
|
|
@ -723,6 +723,7 @@ private:
|
|||
std::set<int64_t> set_pre_split_keypool;
|
||||
int64_t m_max_keypool_index = 0;
|
||||
std::map<CKeyID, int64_t> m_pool_key_to_index;
|
||||
std::atomic<uint64_t> m_wallet_flags{0};
|
||||
|
||||
int64_t nTimeFirstKey = 0;
|
||||
|
||||
|
@ -1190,6 +1191,15 @@ public:
|
|||
|
||||
/** Whether a given output is spendable by this wallet */
|
||||
bool OutputEligibleForSpending(const COutput& output, const CoinEligibilityFilter& eligibility_filter) const;
|
||||
|
||||
/** set a single wallet flag */
|
||||
void SetWalletFlag(uint64_t flags);
|
||||
|
||||
/** check if a certain wallet flag is set */
|
||||
bool IsWalletFlagSet(uint64_t flag);
|
||||
|
||||
/** overwrite all flags by the given uint64_t */
|
||||
void SetWalletFlags(uint64_t overwriteFlags, bool memOnly);
|
||||
};
|
||||
|
||||
/** A key allocated from the key pool. */
|
||||
|
|
|
@ -510,7 +510,11 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
|
|||
strErr = "Error reading wallet database: SetHDChain failed";
|
||||
return false;
|
||||
}
|
||||
} else if (strType != "bestblock" && strType != "bestblock_nomerkle"){
|
||||
} else if (strType == "flags") {
|
||||
uint64_t flags;
|
||||
ssValue >> flags;
|
||||
pwallet->SetWalletFlags(flags, true);
|
||||
} else if (strType != "bestblock" && strType != "bestblock_nomerkle") {
|
||||
wss.m_unknown_records++;
|
||||
}
|
||||
} catch (...)
|
||||
|
@ -840,6 +844,11 @@ bool WalletBatch::WriteHDChain(const CHDChain& chain)
|
|||
return WriteIC(std::string("hdchain"), chain);
|
||||
}
|
||||
|
||||
bool WalletBatch::WriteWalletFlags(const uint64_t flags)
|
||||
{
|
||||
return WriteIC(std::string("flags"), flags);
|
||||
}
|
||||
|
||||
bool WalletBatch::TxnBegin()
|
||||
{
|
||||
return m_batch.TxnBegin();
|
||||
|
|
|
@ -234,6 +234,7 @@ public:
|
|||
//! write the hdchain model (external chain child index counter)
|
||||
bool WriteHDChain(const CHDChain& chain);
|
||||
|
||||
bool WriteWalletFlags(const uint64_t flags);
|
||||
//! Begin a new transaction
|
||||
bool TxnBegin();
|
||||
//! Commit current transaction
|
||||
|
|
Loading…
Reference in a new issue