| 138 | } |
| 139 | |
| 140 | bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet) |
| 141 | { |
| 142 | if (!DecodeBase58(psz, vchRet) || |
| 143 | (vchRet.size() < 4)) { |
| 144 | vchRet.clear(); |
| 145 | return false; |
| 146 | } |
| 147 | // re-calculate the checksum, insure it matches the included 4-byte checksum |
| 148 | uint256 hash = Hash(vchRet.begin(), vchRet.end() - 4); |
| 149 | if (memcmp(&hash, &vchRet.end()[-4], 4) != 0) { |
| 150 | vchRet.clear(); |
| 151 | return false; |
| 152 | } |
| 153 | vchRet.resize(vchRet.size() - 4); |
| 154 | return true; |
| 155 | } |
| 156 | |
| 157 | bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet) |
| 158 | { |