0
1
Can anyone tell me the specified source code to make "checksum bits appended", before doing Base58 conversion? Thanks very much!!!!
0
1
Can anyone tell me the specified source code to make "checksum bits appended", before doing Base58 conversion? Thanks very much!!!!
1
std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn)
{
// add 4-byte hash check to the end
std::vector<unsigned char> vch(vchIn);
uint256 hash = Hash(vch.begin(), vch.end());
vch.insert(vch.end(), (unsigned char*)&hash, (unsigned char*)&hash + 4);
return EncodeBase58(vch);
}
As you can see, the data vch is hashed, then the first 4 bytes of the hash are appended to the end of vch before base58 encoding.
Thank you so much for your answer. Stupid me, I ask the wrong question, what I want ask is the source code to attach the prefix not checksum. would you please tell me which source to attach the prefix before do Base58? – yrm23 – 2018-09-06T15:33:26.390
I think you may be looking for these lines: https://github.com/bitcoin/bitcoin/blob/v0.16.2/src/base58.cpp#L226. Note this has changed in the latest 0.17 release candidate to https://github.com/bitcoin/bitcoin/blob/v0.17.0rc3/src/key_io.cpp#L29
– JBaczuk – 2018-09-06T15:43:34.430