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