| 116 | } |
| 117 | |
| 118 | bool DecodeBase58Check(const char* psz, vector<unsigned char>& vchRet) { |
| 119 | if (!DecodeBase58(psz, vchRet) || (vchRet.size() < 4)) { |
| 120 | vchRet.clear(); |
| 121 | return false; |
| 122 | } |
| 123 | // re-calculate the checksum, insure it matches the included 4-byte checksum |
| 124 | uint256 hash = Hash(vchRet.begin(), vchRet.end() - 4); |
| 125 | if (memcmp(&hash, &vchRet.end()[-4], 4) != 0) { |
| 126 | vchRet.clear(); |
| 127 | return false; |
| 128 | } |
| 129 | vchRet.resize(vchRet.size() - 4); |
| 130 | return true; |
| 131 | } |
| 132 | |
| 133 | bool DecodeBase58Check(const string& str, vector<unsigned char>& vchRet) { |
| 134 | return DecodeBase58Check(str.c_str(), vchRet); |