My study on the scripts goes next.
I'm creating a ScriptPubKey decompiler, now I have a problem with the P2SH,
So how is calculate the key p2sh?
I using this code but I not think is correct
string scriptHash = hex.substr(4, hex.length() - 6);
Bytes bytes = hexBytes(scriptHash.c_str());
char address[36];
Base58Check::pubkeyHashToBase58Check(bytes.data(), 0x00, address);
string stringAddr(address);
cout << "P2SH addresss is " << address;
I have looked this code inside the class DestinationEncoder of the bitcoin core
std::string operator()(const CKeyID& id) const
{
std::vector<unsigned char> data = m_params.Base58Prefix(CChainParams::PUBKEY_ADDRESS);
data.insert(data.end(), id.begin(), id.end());
return EncodeBase58Check(data);
}
and with this code it seems that the information is queued to something, can you clarify my ideas?