Decode CC opret RPC
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
#include "timedata.h"
|
#include "timedata.h"
|
||||||
#include "txmempool.h"
|
#include "txmempool.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "cc/eval.h"
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
#include "wallet/wallet.h"
|
#include "wallet/wallet.h"
|
||||||
#include "wallet/walletdb.h"
|
#include "wallet/walletdb.h"
|
||||||
@@ -1339,6 +1340,52 @@ UniValue txnotarizedconfirmed(const UniValue& params, bool fHelp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniValue decodeccopret(const UniValue& params, bool fHelp)
|
||||||
|
{
|
||||||
|
CTransaction tx; uint256 txid,hashBlock;
|
||||||
|
std::vector<uint8_t> vopret; uint8_t *script;
|
||||||
|
UniValue result(UniValue::VOBJ);
|
||||||
|
|
||||||
|
if (fHelp || params.size() < 1 || params.size() > 1)
|
||||||
|
{
|
||||||
|
string msg = "decodeccopret hex\n"
|
||||||
|
"\nReturns eval code and function id for CC OP RETURN data.\n"
|
||||||
|
|
||||||
|
"\nArguments:\n"
|
||||||
|
"1. txid (string, required) Transaction id.\n"
|
||||||
|
|
||||||
|
"\nResult:\n"
|
||||||
|
"{\n"
|
||||||
|
" eval_code, (string) Eval code name.\n"
|
||||||
|
" function, (char) Function id char.\n"
|
||||||
|
"}\n"
|
||||||
|
;
|
||||||
|
throw runtime_error(msg);
|
||||||
|
}
|
||||||
|
txid = uint256S((char *)params[0].get_str().c_str());
|
||||||
|
{
|
||||||
|
LOCK(cs_main);
|
||||||
|
if (!GetTransaction(txid, tx, hashBlock, true))
|
||||||
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction");
|
||||||
|
}
|
||||||
|
GetOpReturnData(tx.vout[tx.vout.size()-1].scriptPubKey,vopret);
|
||||||
|
script = (uint8_t *)vopret.data();
|
||||||
|
if ( vopret.size() > 1)
|
||||||
|
{
|
||||||
|
char func[5];
|
||||||
|
sprintf(func,"%c",script[1]);
|
||||||
|
result.push_back(Pair("result", "success"));
|
||||||
|
result.push_back(Pair("eval_code", EvalToStr(script[0])));
|
||||||
|
result.push_back(Pair("function", func));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.push_back(Pair("result", "error"));
|
||||||
|
result.push_back(Pair("error", "invalid or no CC opret data"));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static const CRPCCommand commands[] =
|
static const CRPCCommand commands[] =
|
||||||
{ // category name actor (function) okSafeMode
|
{ // category name actor (function) okSafeMode
|
||||||
// --------------------- ------------------------ ----------------------- ----------
|
// --------------------- ------------------------ ----------------------- ----------
|
||||||
|
|||||||
@@ -503,6 +503,7 @@ static const CRPCCommand vRPCCommands[] =
|
|||||||
{ "util", "validateaddress", &validateaddress, true }, /* uses wallet if enabled */
|
{ "util", "validateaddress", &validateaddress, true }, /* uses wallet if enabled */
|
||||||
{ "util", "verifymessage", &verifymessage, true },
|
{ "util", "verifymessage", &verifymessage, true },
|
||||||
{ "util", "txnotarizedconfirmed", &txnotarizedconfirmed, true },
|
{ "util", "txnotarizedconfirmed", &txnotarizedconfirmed, true },
|
||||||
|
{ "util", "decodeccopret", &decodeccopret, true },
|
||||||
{ "util", "estimatefee", &estimatefee, true },
|
{ "util", "estimatefee", &estimatefee, true },
|
||||||
{ "util", "estimatepriority", &estimatepriority, true },
|
{ "util", "estimatepriority", &estimatepriority, true },
|
||||||
{ "util", "z_validateaddress", &z_validateaddress, true }, /* uses wallet if enabled */
|
{ "util", "z_validateaddress", &z_validateaddress, true }, /* uses wallet if enabled */
|
||||||
|
|||||||
@@ -356,6 +356,7 @@ extern UniValue walletlock(const UniValue& params, bool fHelp);
|
|||||||
extern UniValue encryptwallet(const UniValue& params, bool fHelp);
|
extern UniValue encryptwallet(const UniValue& params, bool fHelp);
|
||||||
extern UniValue validateaddress(const UniValue& params, bool fHelp);
|
extern UniValue validateaddress(const UniValue& params, bool fHelp);
|
||||||
extern UniValue txnotarizedconfirmed(const UniValue& params, bool fHelp);
|
extern UniValue txnotarizedconfirmed(const UniValue& params, bool fHelp);
|
||||||
|
extern UniValue decodeccopret(const UniValue& params, bool fHelp);
|
||||||
extern UniValue getinfo(const UniValue& params, bool fHelp);
|
extern UniValue getinfo(const UniValue& params, bool fHelp);
|
||||||
extern UniValue setpubkey(const UniValue& params, bool fHelp);
|
extern UniValue setpubkey(const UniValue& params, bool fHelp);
|
||||||
extern UniValue getwalletinfo(const UniValue& params, bool fHelp);
|
extern UniValue getwalletinfo(const UniValue& params, bool fHelp);
|
||||||
|
|||||||
Reference in New Issue
Block a user