diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index ba414bf3f5..b4925c9583 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -120,6 +120,14 @@ public: obj.pushKV("witness_program", HexStr(id.program, id.program + id.length)); 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) diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 0b0bee05fc..7dc1199a85 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -177,6 +177,11 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) if (!Solver(scriptPubKey, whichType, vSolutions)) return false; + if (whichType == TX_NULL_DATA) { + // This is data, not addresses + return false; + } + if (whichType == TX_PUBKEY) { CPubKey pubKey(vSolutions[0]); @@ -303,6 +308,16 @@ public: *script << CScript::EncodeOP_N(id.version) << std::vector(id.program, id.program + id.length); 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 diff --git a/src/script/standard.h b/src/script/standard.h index cae9ac6d37..95a1f24ffd 100644 --- a/src/script/standard.h +++ b/src/script/standard.h @@ -111,6 +111,21 @@ struct WitnessUnknown } }; +// ELEMENTS: +class NullData +{ +public: + std::vector> 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 b) + { + null_data.push_back(b); + return *this; + } +}; + /** * A txout script template with a specific destination. It is either: * * CNoDestination: no destination set @@ -119,9 +134,10 @@ struct WitnessUnknown * * WitnessV0ScriptHash: TX_WITNESS_V0_SCRIPTHASH destination (P2WSH) * * WitnessV0KeyHash: TX_WITNESS_V0_KEYHASH destination (P2WPKH) * * 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 */ -typedef boost::variant CTxDestination; +typedef boost::variant CTxDestination; /** Check whether a CTxDestination is a CNoDestination. */ bool IsValidDestination(const CTxDestination& dest); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index aab9c39598..e3af4c18ff 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4185,6 +4185,7 @@ public: } 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)