Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 5,078 Lines • ▼ Show 20 Lines | static UniValue sethdseed(const Config &config, const JSONRPCRequest &request) { | ||||
pwallet->SetHDSeed(master_pub_key); | pwallet->SetHDSeed(master_pub_key); | ||||
if (flush_key_pool) { | if (flush_key_pool) { | ||||
pwallet->NewKeyPool(); | pwallet->NewKeyPool(); | ||||
} | } | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
static bool ParseHDKeypath(std::string keypath_str, | |||||
std::vector<uint32_t> &keypath) { | |||||
std::stringstream ss(keypath_str); | |||||
std::string item; | |||||
bool first = true; | |||||
while (std::getline(ss, item, '/')) { | |||||
if (item.compare("m") == 0) { | |||||
if (first) { | |||||
first = false; | |||||
continue; | |||||
} | |||||
return false; | |||||
} | |||||
// Finds whether it is hardened | |||||
uint32_t path = 0; | |||||
size_t pos = item.find("'"); | |||||
if (pos != std::string::npos) { | |||||
// The hardened tick can only be in the last index of the string | |||||
if (pos != item.size() - 1) { | |||||
return false; | |||||
} | |||||
path |= 0x80000000; | |||||
// Drop the last character which is the hardened tick | |||||
item = item.substr(0, item.size() - 1); | |||||
} | |||||
// Ensure this is only numbers | |||||
if (item.find_first_not_of("0123456789") != std::string::npos) { | |||||
return false; | |||||
} | |||||
uint32_t number; | |||||
ParseUInt32(item, &number); | |||||
path |= number; | |||||
keypath.push_back(path); | |||||
first = false; | |||||
} | |||||
return true; | |||||
} | |||||
static void AddKeypathToMap(const CWallet *pwallet, const CKeyID &keyID, | static void AddKeypathToMap(const CWallet *pwallet, const CKeyID &keyID, | ||||
std::map<CPubKey, KeyOriginInfo> &hd_keypaths) { | std::map<CPubKey, KeyOriginInfo> &hd_keypaths) { | ||||
CPubKey vchPubKey; | CPubKey vchPubKey; | ||||
if (!pwallet->GetPubKey(keyID, vchPubKey)) { | if (!pwallet->GetPubKey(keyID, vchPubKey)) { | ||||
return; | return; | ||||
} | } | ||||
CKeyMetadata meta; | CKeyMetadata meta; | ||||
auto it = pwallet->mapKeyMetadata.find(keyID); | auto it = pwallet->mapKeyMetadata.find(keyID); | ||||
▲ Show 20 Lines • Show All 409 Lines • Show Last 20 Lines |