MCPcopy Create free account
hub / github.com/ElementsProject/elements / DecodeBase58Check

Function DecodeBase58Check

src/base58.cpp:144–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 6

DecodeDestinationFunction · 0.85
DecodeSecretFunction · 0.85
DecodeExtPubKeyFunction · 0.85
DecodeExtKeyFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
FUZZ_TARGET_INITFunction · 0.85

Calls 6

DecodeBase58Function · 0.85
ValidAsCStringFunction · 0.85
HashFunction · 0.70
sizeMethod · 0.45
clearMethod · 0.45
resizeMethod · 0.45

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.68
FUZZ_TARGET_INITFunction · 0.68