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