Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 1,481 Lines • ▼ Show 20 Lines | |||||
void CWallet::UnsetBlankWalletFlag(WalletBatch &batch) { | void CWallet::UnsetBlankWalletFlag(WalletBatch &batch) { | ||||
UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET); | UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET); | ||||
} | } | ||||
bool CWallet::IsWalletFlagSet(uint64_t flag) const { | bool CWallet::IsWalletFlagSet(uint64_t flag) const { | ||||
return (m_wallet_flags & flag); | return (m_wallet_flags & flag); | ||||
} | } | ||||
bool CWallet::SetWalletFlags(uint64_t overwriteFlags, bool memonly) { | bool CWallet::LoadWalletFlags(uint64_t flags) { | ||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
m_wallet_flags = overwriteFlags; | if (((flags & KNOWN_WALLET_FLAGS) >> 32) ^ (flags >> 32)) { | ||||
if (((overwriteFlags & KNOWN_WALLET_FLAGS) >> 32) ^ | |||||
(overwriteFlags >> 32)) { | |||||
// contains unknown non-tolerable wallet flags | // contains unknown non-tolerable wallet flags | ||||
return false; | return false; | ||||
} | } | ||||
if (!memonly && !WalletBatch(*database).WriteWalletFlags(m_wallet_flags)) { | m_wallet_flags = flags; | ||||
return true; | |||||
} | |||||
bool CWallet::AddWalletFlags(uint64_t flags) { | |||||
LOCK(cs_wallet); | |||||
// We should never be writing unknown onon-tolerable wallet flags | |||||
assert(!(((flags & KNOWN_WALLET_FLAGS) >> 32) ^ (flags >> 32))); | |||||
if (!WalletBatch(*database).WriteWalletFlags(flags)) { | |||||
throw std::runtime_error(std::string(__func__) + | throw std::runtime_error(std::string(__func__) + | ||||
": writing wallet flags failed"); | ": writing wallet flags failed"); | ||||
} | } | ||||
return true; | return LoadWalletFlags(flags); | ||||
} | } | ||||
int64_t CWalletTx::GetTxTime() const { | int64_t CWalletTx::GetTxTime() const { | ||||
int64_t n = nTimeSmart; | int64_t n = nTimeSmart; | ||||
return n ? n : nTimeReceived; | return n ? n : nTimeReceived; | ||||
} | } | ||||
// Helper for producing a max-sized low-S low-R signature (eg 71 bytes) | // Helper for producing a max-sized low-S low-R signature (eg 71 bytes) | ||||
▲ Show 20 Lines • Show All 2,702 Lines • ▼ Show 20 Lines | if (nLoadWalletRet != DBErrors::LOAD_OK) { | ||||
} | } | ||||
} | } | ||||
if (fFirstRun) { | if (fFirstRun) { | ||||
// Ensure this wallet.dat can only be opened by clients supporting | // Ensure this wallet.dat can only be opened by clients supporting | ||||
// HD with chain split and expects no default key. | // HD with chain split and expects no default key. | ||||
walletInstance->SetMinVersion(FEATURE_LATEST); | walletInstance->SetMinVersion(FEATURE_LATEST); | ||||
walletInstance->SetWalletFlags(wallet_creation_flags, false); | walletInstance->AddWalletFlags(wallet_creation_flags); | ||||
// Only create LegacyScriptPubKeyMan when not descriptor wallet | // Only create LegacyScriptPubKeyMan when not descriptor wallet | ||||
if (!walletInstance->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) { | if (!walletInstance->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) { | ||||
walletInstance->SetupLegacyScriptPubKeyMan(); | walletInstance->SetupLegacyScriptPubKeyMan(); | ||||
} | } | ||||
if (!(wallet_creation_flags & | if (!(wallet_creation_flags & | ||||
(WALLET_FLAG_DISABLE_PRIVATE_KEYS | WALLET_FLAG_BLANK_WALLET))) { | (WALLET_FLAG_DISABLE_PRIVATE_KEYS | WALLET_FLAG_BLANK_WALLET))) { | ||||
▲ Show 20 Lines • Show All 809 Lines • Show Last 20 Lines |