MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / CheckCharacters

Function CheckCharacters

src/bech32.cpp:287–309  ·  view source on GitHub ↗

Return indices of invalid characters in a Bech32 string. */

Source from the content-addressed store, hash-verified

285
286/** Return indices of invalid characters in a Bech32 string. */
287bool CheckCharacters(const std::string& str, std::vector<int>& errors)
288{
289 bool lower = false, upper = false;
290 for (size_t i = 0; i < str.size(); ++i) {
291 unsigned char c{(unsigned char)(str[i])};
292 if (c >= 'a' && c <= 'z') {
293 if (upper) {
294 errors.push_back(i);
295 } else {
296 lower = true;
297 }
298 } else if (c >= 'A' && c <= 'Z') {
299 if (lower) {
300 errors.push_back(i);
301 } else {
302 upper = true;
303 }
304 } else if (c < 33 || c > 126) {
305 errors.push_back(i);
306 }
307 }
308 return errors.empty();
309}
310
311std::vector<unsigned char> PreparePolynomialCoefficients(const std::string& hrp, const data& values)
312{

Callers 2

DecodeFunction · 0.85
LocateErrorsFunction · 0.85

Calls 3

sizeMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected