mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
walletdb: Refactor hd chain loading to its own function
This commit is contained in:
parent
72c2a54ebb
commit
ad779e9ece
2 changed files with 18 additions and 3 deletions
|
@ -452,6 +452,22 @@ bool LoadEncryptionKey(CWallet* pwallet, DataStream& ssKey, DataStream& ssValue,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool LoadHDChain(CWallet* pwallet, DataStream& ssValue, std::string& strErr)
|
||||
{
|
||||
LOCK(pwallet->cs_wallet);
|
||||
try {
|
||||
CHDChain chain;
|
||||
ssValue >> chain;
|
||||
pwallet->GetOrCreateLegacyScriptPubKeyMan()->LoadHDChain(chain);
|
||||
} catch (const std::exception& e) {
|
||||
if (strErr.empty()) {
|
||||
strErr = e.what();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
ReadKeyValue(CWallet* pwallet, DataStream& ssKey, CDataStream& ssValue,
|
||||
CWalletScanState &wss, std::string& strType, std::string& strErr, const KeyFilterFn& filter_fn = nullptr) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
|
||||
|
@ -672,9 +688,7 @@ ReadKeyValue(CWallet* pwallet, DataStream& ssKey, CDataStream& ssValue,
|
|||
pwallet->LoadAddressReceiveRequest(dest, strKey.substr(2), strValue);
|
||||
}
|
||||
} else if (strType == DBKeys::HDCHAIN) {
|
||||
CHDChain chain;
|
||||
ssValue >> chain;
|
||||
pwallet->GetOrCreateLegacyScriptPubKeyMan()->LoadHDChain(chain);
|
||||
if (!LoadHDChain(pwallet, ssValue, strErr)) return false;
|
||||
} else if (strType == DBKeys::OLD_KEY) {
|
||||
strErr = "Found unsupported 'wkey' record, try loading with version 0.18";
|
||||
return false;
|
||||
|
|
|
@ -309,6 +309,7 @@ bool ReadKeyValue(CWallet* pwallet, DataStream& ssKey, CDataStream& ssValue, std
|
|||
bool LoadKey(CWallet* pwallet, DataStream& ssKey, DataStream& ssValue, std::string& strErr);
|
||||
bool LoadCryptedKey(CWallet* pwallet, DataStream& ssKey, DataStream& ssValue, std::string& strErr);
|
||||
bool LoadEncryptionKey(CWallet* pwallet, DataStream& ssKey, DataStream& ssValue, std::string& strErr);
|
||||
bool LoadHDChain(CWallet* pwallet, DataStream& ssValue, std::string& strErr);
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_WALLETDB_H
|
||||
|
|
Loading…
Reference in a new issue