MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / ParseHDKeypath

Function ParseHDKeypath

src/wallet/rpcwallet.cpp:4447–4486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4445}
4446
4447bool ParseHDKeypath(std::string keypath_str, std::vector<uint32_t>& keypath)
4448{
4449 std::stringstream ss(keypath_str);
4450 std::string item;
4451 bool first = true;
4452 while (std::getline(ss, item, '/')) {
4453 if (item.compare("m") == 0) {
4454 if (first) {
4455 first = false;
4456 continue;
4457 }
4458 return false;
4459 }
4460 // Finds whether it is hardened
4461 uint32_t path = 0;
4462 size_t pos = item.find("'");
4463 if (pos != std::string::npos) {
4464 // The hardened tick can only be in the last index of the string
4465 if (pos != item.size() - 1) {
4466 return false;
4467 }
4468 path |= 0x80000000;
4469 item = item.substr(0, item.size() - 1); // Drop the last character which is the hardened tick
4470 }
4471
4472 // Ensure this is only numbers
4473 if (item.find_first_not_of( "0123456789" ) != std::string::npos) {
4474 return false;
4475 }
4476 uint32_t number;
4477 if (!ParseUInt32(item, &number)) {
4478 return false;
4479 }
4480 path |= number;
4481
4482 keypath.push_back(path);
4483 first = false;
4484 }
4485 return true;
4486}
4487
4488void AddKeypathToMap(const CWallet* pwallet, const CKeyID& keyID, std::map<CPubKey, std::vector<uint32_t>>& hd_keypaths)
4489{

Callers 2

AddKeypathToMapFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 5

ParseUInt32Function · 0.85
compareMethod · 0.80
findMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68