Post
Topic
Board Development & Technical Discussion
Re: ScriptHash to CKeyID
by
liorko87
on 24/05/2021, 14:18:33 UTC
The address is P2SH.
DecodeAddressDestination is a function that I added to base58.cpp. I added the implementation.

Code:
CTxDestination DecodeAddressDestination(const std::string& str, const std::vector<unsigned char>& pubkey_prefix) {
        std::vector<unsigned char> data;
        uint160 hash;
        if (DecodeBase58Check(str, data, 256)) {

        // base58-encoded Bitcoin addresses.
        // Public-key-hash-addresses have version 0 (or 111 testnet).
        // The data vector contains RIPEMD160(SHA256(pubkey)), where pubkey is the serialized public key.
        if (data.size() == hash.size() + pubkey_prefix.size() &&
        std::equal(pubkey_prefix.begin(), pubkey_prefix.end(), data.begin())) {
            std::copy(data.begin() + pubkey_prefix.size(), data.end(), hash.begin());
            return ScriptHash(hash);
            }
        }
        return CNoDestination();
}