Пример #1
0
 UniValue operator()(const WitnessV0KeyHash& id) const
 {
     UniValue obj(UniValue::VOBJ);
     obj.pushKV("isscript", false);
     obj.pushKV("iswitness", true);
     obj.pushKV("witness_version", 0);
     obj.pushKV("witness_program", HexStr(id.begin(), id.end()));
     return obj;
 }
Пример #2
0
 UniValue operator()(const WitnessV0KeyHash& id) const
 {
     UniValue obj(UniValue::VOBJ);
     CPubKey pubkey;
     obj.push_back(Pair("isscript", false));
     obj.push_back(Pair("iswitness", true));
     obj.push_back(Pair("witness_version", 0));
     obj.push_back(Pair("witness_program", HexStr(id.begin(), id.end())));
     if (pwallet && pwallet->GetPubKey(CKeyID(id), pubkey)) {
         obj.push_back(Pair("pubkey", HexStr(pubkey)));
     }
     return obj;
 }
Пример #3
0
bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet)
{
    std::vector<valtype> vSolutions;
    txnouttype whichType;
    if (!Solver(scriptPubKey, whichType, vSolutions))
        return false;

    if (whichType == TX_PUBKEY)
    {
        CPubKey pubKey(vSolutions[0]);
        if (!pubKey.IsValid())
            return false;

        addressRet = pubKey.GetID();
        return true;
    }
    else if (whichType == TX_PUBKEYHASH)
    {
        addressRet = CKeyID(uint160(vSolutions[0]));
        return true;
    }
    else if (whichType == TX_SCRIPTHASH)
    {
        addressRet = CScriptID(uint160(vSolutions[0]));
        return true;
    } else if (whichType == TX_WITNESS_V0_KEYHASH) {
        WitnessV0KeyHash hash;
        std::copy(vSolutions[0].begin(), vSolutions[0].end(), hash.begin());
        addressRet = hash;
        return true;
    } else if (whichType == TX_WITNESS_V0_SCRIPTHASH) {
        WitnessV0ScriptHash hash;
        std::copy(vSolutions[0].begin(), vSolutions[0].end(), hash.begin());
        addressRet = hash;
        return true;
    } else if (whichType == TX_WITNESS_UNKNOWN) {
        WitnessUnknown unk;
        unk.version = vSolutions[0][0];
        std::copy(vSolutions[1].begin(), vSolutions[1].end(), unk.program);
        unk.length = vSolutions[1].size();
        addressRet = unk;
        return true;
    }
    // Multisig txns have more than one address...
    return false;
}