Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/scriptpubkeyman.cpp
Show First 20 Lines • Show All 872 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
bool LegacyScriptPubKeyMan::AddWatchOnly(const CScript &dest, | bool LegacyScriptPubKeyMan::AddWatchOnly(const CScript &dest, | ||||
int64_t nCreateTime) { | int64_t nCreateTime) { | ||||
m_script_metadata[CScriptID(dest)].nCreateTime = nCreateTime; | m_script_metadata[CScriptID(dest)].nCreateTime = nCreateTime; | ||||
return AddWatchOnly(dest); | return AddWatchOnly(dest); | ||||
} | } | ||||
void LegacyScriptPubKeyMan::SetHDChain(const CHDChain &chain, bool memonly) { | void LegacyScriptPubKeyMan::LoadHDChain(const CHDChain &chain) { | ||||
LOCK(cs_KeyStore); | |||||
m_hd_chain = chain; | |||||
} | |||||
void LegacyScriptPubKeyMan::AddHDChain(const CHDChain &chain) { | |||||
LOCK(cs_KeyStore); | LOCK(cs_KeyStore); | ||||
// memonly == true means we are loading the wallet file | |||||
// memonly == false means that the chain is actually being changed | |||||
if (!memonly) { | |||||
// Store the new chain | // Store the new chain | ||||
if (!WalletBatch(m_storage.GetDatabase()).WriteHDChain(chain)) { | if (!WalletBatch(m_storage.GetDatabase()).WriteHDChain(chain)) { | ||||
throw std::runtime_error(std::string(__func__) + | throw std::runtime_error(std::string(__func__) + | ||||
": writing chain failed"); | ": writing chain failed"); | ||||
} | } | ||||
// When there's an old chain, add it as an inactive chain as we are now | // When there's an old chain, add it as an inactive chain as we are now | ||||
// rotating hd chains | // rotating hd chains | ||||
if (!m_hd_chain.seed_id.IsNull()) { | if (!m_hd_chain.seed_id.IsNull()) { | ||||
AddInactiveHDChain(m_hd_chain); | AddInactiveHDChain(m_hd_chain); | ||||
} | } | ||||
} | |||||
m_hd_chain = chain; | m_hd_chain = chain; | ||||
} | } | ||||
void LegacyScriptPubKeyMan::AddInactiveHDChain(const CHDChain &chain) { | void LegacyScriptPubKeyMan::AddInactiveHDChain(const CHDChain &chain) { | ||||
LOCK(cs_KeyStore); | LOCK(cs_KeyStore); | ||||
assert(!chain.seed_id.IsNull()); | assert(!chain.seed_id.IsNull()); | ||||
m_inactive_hd_chains[chain.seed_id] = chain; | m_inactive_hd_chains[chain.seed_id] = chain; | ||||
▲ Show 20 Lines • Show All 261 Lines • ▼ Show 20 Lines | void LegacyScriptPubKeyMan::SetHDSeed(const CPubKey &seed) { | ||||
// Store the keyid (hash160) together with the child index counter in the | // Store the keyid (hash160) together with the child index counter in the | ||||
// database as a hdchain object. | // database as a hdchain object. | ||||
CHDChain newHdChain; | CHDChain newHdChain; | ||||
newHdChain.nVersion = m_storage.CanSupportFeature(FEATURE_HD_SPLIT) | newHdChain.nVersion = m_storage.CanSupportFeature(FEATURE_HD_SPLIT) | ||||
? CHDChain::VERSION_HD_CHAIN_SPLIT | ? CHDChain::VERSION_HD_CHAIN_SPLIT | ||||
: CHDChain::VERSION_HD_BASE; | : CHDChain::VERSION_HD_BASE; | ||||
newHdChain.seed_id = seed.GetID(); | newHdChain.seed_id = seed.GetID(); | ||||
SetHDChain(newHdChain, false); | AddHDChain(newHdChain); | ||||
NotifyCanGetAddressesChanged(); | NotifyCanGetAddressesChanged(); | ||||
WalletBatch batch(m_storage.GetDatabase()); | WalletBatch batch(m_storage.GetDatabase()); | ||||
m_storage.UnsetBlankWalletFlag(batch); | m_storage.UnsetBlankWalletFlag(batch); | ||||
} | } | ||||
/** | /** | ||||
* Mark old keypool keys as used, and generate all new keys. | * Mark old keypool keys as used, and generate all new keys. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 1,172 Lines • Show Last 20 Lines |