|
|
@ -29,6 +29,7 @@ |
|
|
|
#include "txmempool.h" |
|
|
|
#include "util.h" |
|
|
|
#include "cc/eval.h" |
|
|
|
#include "cc/CCinclude.h" |
|
|
|
#ifdef ENABLE_WALLET |
|
|
|
#include "wallet/wallet.h" |
|
|
|
#include "wallet/walletdb.h" |
|
|
@ -1343,17 +1344,17 @@ UniValue txnotarizedconfirmed(const UniValue& params, bool fHelp) |
|
|
|
|
|
|
|
UniValue decodeccopret(const UniValue& params, bool fHelp) |
|
|
|
{ |
|
|
|
CTransaction tx; uint256 txid,hashBlock; |
|
|
|
std::vector<uint8_t> vopret; uint8_t *script; |
|
|
|
UniValue result(UniValue::VOBJ); |
|
|
|
CTransaction tx; uint256 tokenid,txid,hashblock; |
|
|
|
std::vector<uint8_t> vopret,vOpretExtra; uint8_t *script,tokenevalcode; |
|
|
|
UniValue result(UniValue::VOBJ),array(UniValue::VARR); std::vector<CPubKey> pubkeys; |
|
|
|
|
|
|
|
if (fHelp || params.size() < 1 || params.size() > 1) |
|
|
|
{ |
|
|
|
string msg = "decodeccopret hex\n" |
|
|
|
string msg = "decodeccopret scriptPubKey\n" |
|
|
|
"\nReturns eval code and function id for CC OP RETURN data.\n" |
|
|
|
|
|
|
|
"\nArguments:\n" |
|
|
|
"1. txid (string, required) Transaction id.\n" |
|
|
|
"1. scriptPubKey (string, required) Hex of scriptPubKey with OP_RETURN data.\n" |
|
|
|
|
|
|
|
"\nResult:\n" |
|
|
|
"{\n" |
|
|
@ -1363,21 +1364,38 @@ UniValue decodeccopret(const UniValue& params, bool fHelp) |
|
|
|
; |
|
|
|
throw runtime_error(msg); |
|
|
|
} |
|
|
|
txid = uint256S((char *)params[0].get_str().c_str()); |
|
|
|
std::vector<unsigned char> hex(ParseHex(params[0].get_str())); |
|
|
|
CScript scripthex(hex.begin(),hex.end()); |
|
|
|
if (DecodeTokenOpRet(scripthex,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0) |
|
|
|
{ |
|
|
|
LOCK(cs_main); |
|
|
|
if (!GetTransaction(txid, tx, hashBlock, true)) |
|
|
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction"); |
|
|
|
UniValue obj(UniValue::VOBJ); |
|
|
|
GetOpReturnData(scripthex,vopret); |
|
|
|
script = (uint8_t *)vopret.data(); |
|
|
|
if ( vopret.size() > 1) |
|
|
|
{ |
|
|
|
char func[5]; |
|
|
|
sprintf(func,"%c",script[1]); |
|
|
|
obj.push_back(Pair("eval_code", EvalToStr(script[0]))); |
|
|
|
obj.push_back(Pair("function", func)); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
obj.push_back(Pair("error", "invalid or no CC opret data for Token OP_RETURN")); |
|
|
|
} |
|
|
|
array.push_back(obj); |
|
|
|
if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0); |
|
|
|
} |
|
|
|
GetOpReturnData(tx.vout[tx.vout.size()-1].scriptPubKey,vopret); |
|
|
|
else GetOpReturnData(scripthex,vopret); |
|
|
|
script = (uint8_t *)vopret.data(); |
|
|
|
if ( vopret.size() > 1) |
|
|
|
{ |
|
|
|
char func[5]; |
|
|
|
sprintf(func,"%c",script[1]); |
|
|
|
char func[5]; UniValue obj(UniValue::VOBJ); |
|
|
|
result.push_back(Pair("result", "success")); |
|
|
|
result.push_back(Pair("eval_code", EvalToStr(script[0]))); |
|
|
|
result.push_back(Pair("function", func)); |
|
|
|
sprintf(func,"%c",script[1]); |
|
|
|
obj.push_back(Pair("eval_code", EvalToStr(script[0]))); |
|
|
|
obj.push_back(Pair("function", func)); |
|
|
|
array.push_back(obj); |
|
|
|
result.push_back(Pair("OpRets",array)); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|