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

Function DecodeBase58Check

src/base58.cpp:146–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 6

DecodeDestinationFunction · 0.85
DecodeSecretFunction · 0.85
DecodeExtPubKeyFunction · 0.85
DecodeExtKeyFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
FUZZ_TARGETFunction · 0.85

Calls 6

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

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.68
FUZZ_TARGETFunction · 0.68