bitcoin_hdkeypath/
hdkeypath.rs

1crate::ix!();
2
3//-------------------------------------------[.cpp/bitcoin/src/util/bip32.h]
4//-------------------------------------------[.cpp/bitcoin/src/util/bip32.cpp]
5
6/**
7  | Parse an HD keypaths like "m/7/0'/2000".
8  |
9  */
10pub fn parse_hd_keypath(
11        keypath_str: &String,
12        keypath:     &mut Vec<u32>) -> bool {
13    
14    todo!();
15        /*
16            std::stringstream ss(keypath_str);
17        std::string item;
18        bool first = true;
19        while (std::getline(ss, item, '/')) {
20            if (item.compare("m") == 0) {
21                if (first) {
22                    first = false;
23                    continue;
24                }
25                return false;
26            }
27            // Finds whether it is hardened
28            uint32_t path = 0;
29            size_t pos = item.find("'");
30            if (pos != std::string::npos) {
31                // The hardened tick can only be in the last index of the string
32                if (pos != item.size() - 1) {
33                    return false;
34                }
35                path |= 0x80000000;
36                item = item.substr(0, item.size() - 1); // Drop the last character which is the hardened tick
37            }
38
39            // Ensure this is only numbers
40            if (item.find_first_not_of( "0123456789" ) != std::string::npos) {
41                return false;
42            }
43            uint32_t number;
44            if (!ParseUInt32(item, &number)) {
45                return false;
46            }
47            path |= number;
48
49            keypath.push_back(path);
50            first = false;
51        }
52        return true;
53        */
54}
55
56pub fn format_hd_keypath(path: &Vec<u32>) -> String {
57    
58    todo!();
59        /*
60            std::string ret;
61        for (auto i : path) {
62            ret += strprintf("/%i", (i << 1) >> 1);
63            if (i >> 31) ret += '\'';
64        }
65        return ret;
66        */
67}
68
69/**
70  | Write HD keypaths as strings
71  |
72  */
73pub fn write_hd_keypath(keypath: &Vec<u32>) -> String {
74    
75    todo!();
76        /*
77            return "m" + FormatHDKeypath(keypath);
78        */
79}
80