Changeset View
Changeset View
Standalone View
Standalone View
src/base58.cpp
Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | bool DecodeBase58(const char *psz, std::vector<uint8_t> &vch) { | ||||
while (IsSpace(*psz)) { | while (IsSpace(*psz)) { | ||||
psz++; | psz++; | ||||
} | } | ||||
if (*psz != 0) { | if (*psz != 0) { | ||||
return false; | return false; | ||||
} | } | ||||
// Skip leading zeroes in b256. | // Skip leading zeroes in b256. | ||||
std::vector<uint8_t>::iterator it = b256.begin() + (size - length); | std::vector<uint8_t>::iterator it = b256.begin() + (size - length); | ||||
while (it != b256.end() && *it == 0) | while (it != b256.end() && *it == 0) { | ||||
it++; | it++; | ||||
} | |||||
// Copy result into output vector. | // Copy result into output vector. | ||||
vch.reserve(zeroes + (b256.end() - it)); | vch.reserve(zeroes + (b256.end() - it)); | ||||
vch.assign(zeroes, 0x00); | vch.assign(zeroes, 0x00); | ||||
while (it != b256.end()) { | while (it != b256.end()) { | ||||
vch.push_back(*(it++)); | vch.push_back(*(it++)); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |