| 160 | } |
| 161 | |
| 162 | CExtPubKey DecodeExtPubKey(const std::string& str) |
| 163 | { |
| 164 | CExtPubKey key; |
| 165 | std::vector<unsigned char> data; |
| 166 | if (DecodeBase58Check(str, data)) { |
| 167 | const std::vector<unsigned char>& prefix = Params().Base58Prefix(CChainParams::EXT_PUBLIC_KEY); |
| 168 | if (data.size() == BIP32_EXTKEY_SIZE + prefix.size() && std::equal(prefix.begin(), prefix.end(), data.begin())) { |
| 169 | key.Decode(data.data() + prefix.size()); |
| 170 | } |
| 171 | } |
| 172 | return key; |
| 173 | } |
| 174 | |
| 175 | std::string EncodeExtPubKey(const CExtPubKey& key) |
| 176 | { |