Changeset View
Changeset View
Standalone View
Standalone View
src/base58.cpp
Show First 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | |||||
bool DecodeBase58Check(const char *psz, std::vector<uint8_t> &vchRet) { | bool DecodeBase58Check(const char *psz, std::vector<uint8_t> &vchRet) { | ||||
if (!DecodeBase58(psz, vchRet) || (vchRet.size() < 4)) { | if (!DecodeBase58(psz, vchRet) || (vchRet.size() < 4)) { | ||||
vchRet.clear(); | vchRet.clear(); | ||||
return false; | return false; | ||||
} | } | ||||
// re-calculate the checksum, ensure it matches the included 4-byte checksum | // re-calculate the checksum, ensure it matches the included 4-byte checksum | ||||
uint256 hash = Hash(vchRet.begin(), vchRet.end() - 4); | uint256 hash = Hash(vchRet.begin(), vchRet.end() - 4); | ||||
if (memcmp(&hash, &vchRet.end()[-4], 4) != 0) { | if (memcmp(&hash, &vchRet[vchRet.size() - 4], 4) != 0) { | ||||
vchRet.clear(); | vchRet.clear(); | ||||
return false; | return false; | ||||
} | } | ||||
vchRet.resize(vchRet.size() - 4); | vchRet.resize(vchRet.size() - 4); | ||||
return true; | return true; | ||||
} | } | ||||
bool DecodeBase58Check(const std::string &str, std::vector<uint8_t> &vchRet) { | bool DecodeBase58Check(const std::string &str, std::vector<uint8_t> &vchRet) { | ||||
▲ Show 20 Lines • Show All 149 Lines • Show Last 20 Lines |