aboutsummaryrefslogtreecommitdiff
path: root/src/util/strencodings.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2018-11-06 09:23:43 -0500
committerAndrew Chow <achow101-github@achow101.com>2019-02-14 14:00:28 -0500
commite7652d3f64212a6af68fc7d788411d28fcbdbd0a (patch)
tree6fefe2f16e7e29c4af58765fad34064d758de483 /src/util/strencodings.cpp
parentc45415f73a095665a8ff6172b57eb818cf572547 (diff)
Add WriteHDKeypath function and move *HDKeypath to util/bip32.{h,cpp}
Creates new files util/bip32.h and util/bip32.cpp for containing BIP 32 stuff. Moves FormatKeyPath from descriptor.cpp to util/bip32. Adds a wrapper around it to prepent the 'm' for when just the BIP 32 style keypath is needed.
Diffstat (limited to 'src/util/strencodings.cpp')
-rw-r--r--src/util/strencodings.cpp41
1 files changed, 0 insertions, 41 deletions
diff --git a/src/util/strencodings.cpp b/src/util/strencodings.cpp
index b55547bc63..0acbb4f117 100644
--- a/src/util/strencodings.cpp
+++ b/src/util/strencodings.cpp
@@ -546,47 +546,6 @@ bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out)
return true;
}
-bool ParseHDKeypath(const 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;
- item = item.substr(0, item.size() - 1); // Drop the last character which is the hardened tick
- }
-
- // Ensure this is only numbers
- if (item.find_first_not_of( "0123456789" ) != std::string::npos) {
- return false;
- }
- uint32_t number;
- if (!ParseUInt32(item, &number)) {
- return false;
- }
- path |= number;
-
- keypath.push_back(path);
- first = false;
- }
- return true;
-}
-
void Downcase(std::string& str)
{
std::transform(str.begin(), str.end(), str.begin(), [](char c){return ToLower(c);});