| 243 | } |
| 244 | |
| 245 | CExtPubKey DecodeExtPubKey(const std::string& str) |
| 246 | { |
| 247 | CExtPubKey key; |
| 248 | std::vector<unsigned char> data; |
| 249 | if (DecodeBase58Check(str, data, 78)) { |
| 250 | const std::vector<unsigned char>& prefix = Params().Base58Prefix(CChainParams::EXT_PUBLIC_KEY); |
| 251 | if (data.size() == BIP32_EXTKEY_SIZE + prefix.size() && std::equal(prefix.begin(), prefix.end(), data.begin())) { |
| 252 | key.Decode(data.data() + prefix.size()); |
| 253 | } |
| 254 | } |
| 255 | return key; |
| 256 | } |
| 257 | |
| 258 | std::string EncodeExtPubKey(const CExtPubKey& key) |
| 259 | { |