mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Add support for NullData addresses (OP_RETURN)
This commit is contained in:
parent
18ee3417d8
commit
ac1eadd0de
4 changed files with 41 additions and 1 deletions
|
|
@ -120,6 +120,14 @@ public:
|
||||||
obj.pushKV("witness_program", HexStr(id.program, id.program + id.length));
|
obj.pushKV("witness_program", HexStr(id.program, id.program + id.length));
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniValue operator()(const NullData& id) const
|
||||||
|
{
|
||||||
|
UniValue obj(UniValue::VOBJ);
|
||||||
|
obj.pushKV("isscript", false);
|
||||||
|
obj.pushKV("iswitness", false);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UniValue DescribeAddress(const CTxDestination& dest)
|
UniValue DescribeAddress(const CTxDestination& dest)
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,11 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet)
|
||||||
if (!Solver(scriptPubKey, whichType, vSolutions))
|
if (!Solver(scriptPubKey, whichType, vSolutions))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (whichType == TX_NULL_DATA) {
|
||||||
|
// This is data, not addresses
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (whichType == TX_PUBKEY)
|
if (whichType == TX_PUBKEY)
|
||||||
{
|
{
|
||||||
CPubKey pubKey(vSolutions[0]);
|
CPubKey pubKey(vSolutions[0]);
|
||||||
|
|
@ -303,6 +308,16 @@ public:
|
||||||
*script << CScript::EncodeOP_N(id.version) << std::vector<unsigned char>(id.program, id.program + id.length);
|
*script << CScript::EncodeOP_N(id.version) << std::vector<unsigned char>(id.program, id.program + id.length);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator()(const NullData& id) const
|
||||||
|
{
|
||||||
|
script->clear();
|
||||||
|
*script << OP_RETURN;
|
||||||
|
for (const auto& push : id.null_data) {
|
||||||
|
*script << push;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,21 @@ struct WitnessUnknown
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ELEMENTS:
|
||||||
|
class NullData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::vector<std::vector<unsigned char>> null_data;
|
||||||
|
friend bool operator==(const NullData &a, const NullData &b) { return true; }
|
||||||
|
friend bool operator<(const NullData &a, const NullData &b) { return true; }
|
||||||
|
|
||||||
|
NullData& operator<<(std::vector<unsigned char> b)
|
||||||
|
{
|
||||||
|
null_data.push_back(b);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A txout script template with a specific destination. It is either:
|
* A txout script template with a specific destination. It is either:
|
||||||
* * CNoDestination: no destination set
|
* * CNoDestination: no destination set
|
||||||
|
|
@ -119,9 +134,10 @@ struct WitnessUnknown
|
||||||
* * WitnessV0ScriptHash: TX_WITNESS_V0_SCRIPTHASH destination (P2WSH)
|
* * WitnessV0ScriptHash: TX_WITNESS_V0_SCRIPTHASH destination (P2WSH)
|
||||||
* * WitnessV0KeyHash: TX_WITNESS_V0_KEYHASH destination (P2WPKH)
|
* * WitnessV0KeyHash: TX_WITNESS_V0_KEYHASH destination (P2WPKH)
|
||||||
* * WitnessUnknown: TX_WITNESS_UNKNOWN destination (P2W???)
|
* * WitnessUnknown: TX_WITNESS_UNKNOWN destination (P2W???)
|
||||||
|
* * NullData: TX_NULL_DATA destination (OP_RETURN)
|
||||||
* A CTxDestination is the internal data type encoded in a bitcoin address
|
* A CTxDestination is the internal data type encoded in a bitcoin address
|
||||||
*/
|
*/
|
||||||
typedef boost::variant<CNoDestination, CKeyID, CScriptID, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown> CTxDestination;
|
typedef boost::variant<CNoDestination, CKeyID, CScriptID, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown, NullData> CTxDestination;
|
||||||
|
|
||||||
/** Check whether a CTxDestination is a CNoDestination. */
|
/** Check whether a CTxDestination is a CNoDestination. */
|
||||||
bool IsValidDestination(const CTxDestination& dest);
|
bool IsValidDestination(const CTxDestination& dest);
|
||||||
|
|
|
||||||
|
|
@ -4185,6 +4185,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue operator()(const WitnessUnknown& id) const { return UniValue(UniValue::VOBJ); }
|
UniValue operator()(const WitnessUnknown& id) const { return UniValue(UniValue::VOBJ); }
|
||||||
|
UniValue operator()(const NullData& id) const { return NullUniValue; }
|
||||||
};
|
};
|
||||||
|
|
||||||
static UniValue DescribeWalletAddress(CWallet* pwallet, const CTxDestination& dest)
|
static UniValue DescribeWalletAddress(CWallet* pwallet, const CTxDestination& dest)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue