test_burntx added

This commit is contained in:
dimxy
2019-02-12 00:14:08 +05:00
parent cb0db91e9f
commit 7a4072b4f1
3 changed files with 34 additions and 0 deletions

View File

@@ -539,6 +539,8 @@ static const CRPCCommand vRPCCommands[] =
{ "hidden", "setmocktime", &setmocktime, true },
{ "hidden", "test_ac", &test_ac, true },
{ "hidden", "test_heirmarker", &test_heirmarker, true },
{ "hidden", "test_burntx", &test_burntx, true },
#ifdef ENABLE_WALLET
/* Wallet */

View File

@@ -474,5 +474,7 @@ extern UniValue paxwithdraw(const UniValue& params, bool fHelp);
// test rpc:
extern UniValue test_ac(const UniValue& params, bool fHelp);
extern UniValue test_heirmarker(const UniValue& params, bool fHelp);
extern UniValue test_burntx(const UniValue& params, bool fHelp);
#endif // BITCOIN_RPCSERVER_H

View File

@@ -7818,3 +7818,33 @@ UniValue test_heirmarker(const UniValue& params, bool fHelp)
return(FinalizeCCTx(0, cp, mtx, myPubkey, 10000, opret));
}
UniValue test_burntx(const UniValue& params, bool fHelp)
{
// make fake token tx:
struct CCcontract_info *cp, C;
if (fHelp || (params.size() != 1))
throw runtime_error("incorrect params\n");
if (ensure_CCrequirements(EVAL_TOKENS) < 0)
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n");
uint256 tokenid = Parseuint256((char *)params[0].get_str().c_str());
CPubKey myPubkey = pubkey2pk(Mypubkey());
CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight());
int64_t normalInputs = AddNormalinputs(mtx, myPubkey, 10000, 60);
if (normalInputs < 10000)
throw runtime_error("not enough normals\n");
CPubKey burnpk = pubkey2pk(ParseHex(CC_BURNPUBKEY));
mtx.vin.push_back(CTxIn(tokenid, 1));
mtx.vout.push_back(MakeTokensCC1vout(EVAL_TOKENS, 1, burnpk));
std::vector<CPubKey> voutPubkeys;
voutPubkeys.push_back(burnpk);
cp = CCinit(&C, EVAL_TOKENS);
return(FinalizeCCTx(0, cp, mtx, myPubkey, 10000, EncodeTokenOpRet(tokenid, voutPubkeys, CScript())));
}