Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | void CWallet::DeriveNewChildKey(CWalletDB &walletdb, CKeyMetadata &metadata, | ||||
// derive child key at next index, skip keys already known to the wallet | // derive child key at next index, skip keys already known to the wallet | ||||
do { | do { | ||||
// always derive hardened keys | // always derive hardened keys | ||||
// childIndex | BIP32_HARDENED_KEY_LIMIT = derive childIndex in hardened | // childIndex | BIP32_HARDENED_KEY_LIMIT = derive childIndex in hardened | ||||
// child-index-range | // child-index-range | ||||
// example: 1 | BIP32_HARDENED_KEY_LIMIT == 0x80000001 == 2147483649 | // example: 1 | BIP32_HARDENED_KEY_LIMIT == 0x80000001 == 2147483649 | ||||
if (internal) { | if (internal) { | ||||
chainChildKey.Derive(childKey, | chainChildKey.Derive(childKey, hdChain.nInternalChainCounter | | ||||
hdChain.nInternalChainCounter | | |||||
BIP32_HARDENED_KEY_LIMIT); | BIP32_HARDENED_KEY_LIMIT); | ||||
metadata.hdKeypath = "m/0'/1'/" + | metadata.hdKeypath = "m/0'/1'/" + | ||||
std::to_string(hdChain.nInternalChainCounter) + | std::to_string(hdChain.nInternalChainCounter) + | ||||
"'"; | "'"; | ||||
hdChain.nInternalChainCounter++; | hdChain.nInternalChainCounter++; | ||||
} else { | } else { | ||||
chainChildKey.Derive(childKey, | chainChildKey.Derive(childKey, hdChain.nExternalChainCounter | | ||||
hdChain.nExternalChainCounter | | |||||
BIP32_HARDENED_KEY_LIMIT); | BIP32_HARDENED_KEY_LIMIT); | ||||
metadata.hdKeypath = "m/0'/0'/" + | metadata.hdKeypath = "m/0'/0'/" + | ||||
std::to_string(hdChain.nExternalChainCounter) + | std::to_string(hdChain.nExternalChainCounter) + | ||||
"'"; | "'"; | ||||
hdChain.nExternalChainCounter++; | hdChain.nExternalChainCounter++; | ||||
} | } | ||||
} while (HaveKey(childKey.key.GetPubKey().GetID())); | } while (HaveKey(childKey.key.GetPubKey().GetID())); | ||||
secret = childKey.key; | secret = childKey.key; | ||||
metadata.hdMasterKeyID = hdChain.masterKeyID; | metadata.hdMasterKeyID = hdChain.masterKeyID; | ||||
▲ Show 20 Lines • Show All 1,492 Lines • ▼ Show 20 Lines | CBlockIndex *CWallet::ScanForWalletTransactions(CBlockIndex *pindexStart, | ||||
double dProgressStart = | double dProgressStart = | ||||
GuessVerificationProgress(chainParams.TxData(), pindex); | GuessVerificationProgress(chainParams.TxData(), pindex); | ||||
double dProgressTip = | double dProgressTip = | ||||
GuessVerificationProgress(chainParams.TxData(), chainActive.Tip()); | GuessVerificationProgress(chainParams.TxData(), chainActive.Tip()); | ||||
while (pindex && !fAbortRescan) { | while (pindex && !fAbortRescan) { | ||||
if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0) { | if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0) { | ||||
ShowProgress( | ShowProgress( | ||||
_("Rescanning..."), | _("Rescanning..."), | ||||
std::max(1, std::min<int>(99, | std::max(1, | ||||
(GuessVerificationProgress( | std::min<int>(99, (GuessVerificationProgress( | ||||
chainParams.TxData(), pindex) - | chainParams.TxData(), pindex) - | ||||
dProgressStart) / | dProgressStart) / | ||||
(dProgressTip - dProgressStart) * | (dProgressTip - dProgressStart) * | ||||
100))); | 100))); | ||||
} | } | ||||
CBlock block; | CBlock block; | ||||
if (ReadBlockFromDisk(block, pindex, GetConfig())) { | if (ReadBlockFromDisk(block, pindex, GetConfig())) { | ||||
for (size_t posInBlock = 0; posInBlock < block.vtx.size(); | for (size_t posInBlock = 0; posInBlock < block.vtx.size(); | ||||
++posInBlock) { | ++posInBlock) { | ||||
AddToWalletIfInvolvingMe(block.vtx[posInBlock], pindex, | AddToWalletIfInvolvingMe(block.vtx[posInBlock], pindex, | ||||
posInBlock, fUpdate); | posInBlock, fUpdate); | ||||
▲ Show 20 Lines • Show All 2,561 Lines • Show Last 20 Lines |