mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
walletdb: Refactor hd chain loading to its own function
This commit is contained in:
@@ -452,6 +452,22 @@ bool LoadEncryptionKey(CWallet* pwallet, DataStream& ssKey, DataStream& ssValue,
|
|||||||
return true;
|
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
|
static bool
|
||||||
ReadKeyValue(CWallet* pwallet, DataStream& ssKey, CDataStream& ssValue,
|
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)
|
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);
|
pwallet->LoadAddressReceiveRequest(dest, strKey.substr(2), strValue);
|
||||||
}
|
}
|
||||||
} else if (strType == DBKeys::HDCHAIN) {
|
} else if (strType == DBKeys::HDCHAIN) {
|
||||||
CHDChain chain;
|
if (!LoadHDChain(pwallet, ssValue, strErr)) return false;
|
||||||
ssValue >> chain;
|
|
||||||
pwallet->GetOrCreateLegacyScriptPubKeyMan()->LoadHDChain(chain);
|
|
||||||
} else if (strType == DBKeys::OLD_KEY) {
|
} else if (strType == DBKeys::OLD_KEY) {
|
||||||
strErr = "Found unsupported 'wkey' record, try loading with version 0.18";
|
strErr = "Found unsupported 'wkey' record, try loading with version 0.18";
|
||||||
return false;
|
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 LoadKey(CWallet* pwallet, DataStream& ssKey, DataStream& ssValue, std::string& strErr);
|
||||||
bool LoadCryptedKey(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 LoadEncryptionKey(CWallet* pwallet, DataStream& ssKey, DataStream& ssValue, std::string& strErr);
|
||||||
|
bool LoadHDChain(CWallet* pwallet, DataStream& ssValue, std::string& strErr);
|
||||||
} // namespace wallet
|
} // namespace wallet
|
||||||
|
|
||||||
#endif // BITCOIN_WALLET_WALLETDB_H
|
#endif // BITCOIN_WALLET_WALLETDB_H
|
||||||
|
|||||||
Reference in New Issue
Block a user