MCPcopy Create free account
hub / github.com/LUX-Core/lux / GetKey

Method GetKey

src/wallet.cpp:259–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259bool CWallet::GetKey(const CKeyID &address, CKey& keyOut) const
260{
261 LOCK(cs_wallet);
262 std::map<CKeyID, CHDPubKey>::const_iterator mi = mapHdPubKeys.find(address);
263 if (mi != mapHdPubKeys.end())
264 {
265 // if the key has been found in mapHdPubKeys, derive it on the fly
266 const CHDPubKey &hdPubKey = (*mi).second;
267 CHDChain hdChainCurrent;
268 if (!GetHDChain(hdChainCurrent))
269 throw std::runtime_error(std::string(__func__) + ": GetHDChain failed");
270 if (!DecryptHDChain(hdChainCurrent))
271 throw std::runtime_error(std::string(__func__) + ": DecryptHDChainSeed failed");
272 // make sure seed matches this chain
273 if (hdChainCurrent.GetID() != hdChainCurrent.GetSeedHash())
274 throw std::runtime_error(std::string(__func__) + ": Wrong HD chain!");
275
276 CExtKey extkey;
277 hdChainCurrent.DeriveChildExtKey(hdPubKey.nAccountIndex, hdPubKey.nChangeIndex != 0, hdPubKey.extPubKey.nChild, extkey);
278 keyOut = extkey.key;
279
280 return true;
281 }
282 else {
283 return CCryptoKeyStore::GetKey(address, keyOut);
284 }
285}
286
287bool CWallet::HaveKey(const CKeyID &address) const
288{

Callers

nothing calls this directly

Calls 5

GetSeedHashMethod · 0.80
DeriveChildExtKeyMethod · 0.80
findMethod · 0.45
endMethod · 0.45
GetIDMethod · 0.45

Tested by

no test coverage detected