change to work for all contracts
This commit is contained in:
@@ -20,8 +20,8 @@
|
||||
#include "komodo_defs.h"
|
||||
#include "CCinclude.h"
|
||||
int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks);
|
||||
extern void GetFeeAddress();
|
||||
extern CScript KOMODO_PRICES_FEE_SCRIPTPUB;
|
||||
extern void GetKomodoEarlytxidScriptPub();
|
||||
extern CScript KOMODO_EARLYTXID_SCRIPTPUB;
|
||||
|
||||
// #define PRICES_DAYWINDOW ((3600*24/ASSETCHAINS_BLOCKTIME) + 1) // defined in komodo_defs.h
|
||||
#define PRICES_TXFEE 10000
|
||||
|
||||
@@ -12,23 +12,34 @@
|
||||
* Removal or modification of this copyright notice is prohibited. *
|
||||
* *
|
||||
*****************************************************************************
|
||||
To create payments plan start a chain with -ac_snapshot=1440 (or for test something shorter, if you like.)
|
||||
then in very early block < 10 or so, do paymentsairdrop eg.
|
||||
`./komodo-cli -ac_name=TESTDP paymentsairdrop '[10,10,0,3999,0,0]'
|
||||
copy the txid of this transaction after it is confirmed, then do:
|
||||
'./komodo-cli -ac_name=TESTDP opreturn_burn 1 4a8f6469f713251a0381170e275d68899d481270a5e48586276dbbbadff91b57'
|
||||
To create payments plan start a chain with the following ac_params:
|
||||
-ac_snapshot=1440 (or for test chain something smaller, if you like.)
|
||||
- this enables the payments airdrop cc to work.
|
||||
-ac_earlytxidcontract=237 (Eval code for prices cc.)
|
||||
- this allows to know what contract this chain is paying with the scriptpubkey in the earlytxid op_return.
|
||||
|
||||
./komodod -ac_name=TESTPRC -ac_supply=100000000 -ac_reward=1000000000 -ac_nk=96,5 -ac_blocktime=20 -ac_cc=2 -ac_snapshot=50 -ac_sapling=1 -ac_earlytxidcontract=237 -testnode=1 -gen -genproclimit=1
|
||||
|
||||
Then in very early block < 10 or so, do paymentsairdrop eg.
|
||||
`./komodo-cli -ac_name=TESTPRC paymentsairdrop '[10,10,0,3999,0,0]'
|
||||
Once this tx is confirmed, do `paymentsfund` and decode the raw hex. You can edit the source to not send the tx if requried.
|
||||
Get the full `hex` of the vout[0] that pays to CryptoCondition. then place it on chain with the following command: with the hex you got in place of the hex below.
|
||||
'./komodo-cli -ac_name=TESTPRC opreturn_burn 1 2ea22c8020292ba5c8fd9cc89b12b35bf8f5d00196990ecbb06102b84d9748d11d883ef01e81031210008203000401cc'
|
||||
copy the hex, and sendrawtransaction, copy the txid returned.
|
||||
this places the txid that locates the plan into an op_return before block 100, allowing us to retreive it.
|
||||
Restart the daemon with -earlytxid=<txid of opreturn_burn transaction>
|
||||
this places the scriptpubkey that pays the plan into an op_return before block 100, allowing us to retreive it, and nobody to change it.
|
||||
Restart the daemon with -earlytxid=<txid of opreturn_burn transaction> eg:
|
||||
|
||||
./komodod -ac_name=TESTPRC -ac_supply=100000000 -ac_reward=1000000000 -ac_nk=96,5 -ac_blocktime=20 -ac_cc=2 -ac_snapshot=50 -ac_sapling=1 -ac_earlytxidcontract=237 -earlytxid=cf89d17fb11037f65c160d0749dddd74dc44d9893b0bb67fe1f96c1f59786496 -testnode=1 -gen -genproclimit=1
|
||||
|
||||
mine the chain past block 100, preventing anyone else, creating another payments plan on chain before block 100.
|
||||
|
||||
We call the following in Validation and RPC where the address is needed.
|
||||
if ( KOMODO_PRICES_FEE_SCRIPTPUB.size() == 0 )
|
||||
GetFeeAddress();
|
||||
if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && KOMODO_EARLYTXID_SCRIPTPUB.size() == 0 )
|
||||
GetKomodoEarlytxidScriptPub();
|
||||
|
||||
This will fetch the op_return, calculate the scriptPubKey and save it to the global.
|
||||
On daemon restart as soon as validation for BETTX happens the global will be filled, afte this the transaction never needs to be looked up again.
|
||||
GetFeeAddress is on line #2080 of komodo_bitcoind.h
|
||||
On daemon restart as soon as validation for BETTX happens the global will be filled, after this the transaction never needs to be looked up again.
|
||||
GetKomodoEarlytxidScriptPub is on line #2080 of komodo_bitcoind.h
|
||||
*/
|
||||
|
||||
#include "CCassets.h"
|
||||
@@ -202,8 +213,8 @@ static bool ValidateBetTx(struct CCcontract_info *cp, Eval *eval, const CTransac
|
||||
int16_t leverage;
|
||||
CPubKey pk, pricespk;
|
||||
std::vector<uint16_t> vec;
|
||||
if ( KOMODO_PRICES_FEE_SCRIPTPUB.size() == 0 )
|
||||
GetFeeAddress();
|
||||
if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && KOMODO_EARLYTXID_SCRIPTPUB.size() == 0 )
|
||||
GetKomodoEarlytxidScriptPub();
|
||||
if (bettx.vout.size() < 5 || bettx.vout.size() > 6)
|
||||
return eval->Invalid("incorrect vout number for bet tx");
|
||||
|
||||
@@ -220,7 +231,7 @@ static bool ValidateBetTx(struct CCcontract_info *cp, Eval *eval, const CTransac
|
||||
if (MakeCC1vout(cp->evalcode, bettx.vout[2].nValue, pricespk) != bettx.vout[2] )
|
||||
return eval->Invalid("cannot validate vout2 in bet tx with pk from opreturn");
|
||||
// This should be all you need to verify it, maybe also check amount?
|
||||
if ( bettx.vout[4].scriptPubKey != KOMODO_PRICES_FEE_SCRIPTPUB )
|
||||
if ( bettx.vout[4].scriptPubKey != KOMODO_EARLYTXID_SCRIPTPUB )
|
||||
return eval->Invalid("the fee was paid to wrong address.");
|
||||
|
||||
int64_t betamount = bettx.vout[2].nValue;
|
||||
@@ -1369,6 +1380,15 @@ int64_t prices_enumaddedbets(uint256 &batontxid, std::vector<OneBetData> &bets,
|
||||
// pricesbet rpc impl: make betting tx
|
||||
UniValue PricesBet(int64_t txfee, int64_t amount, int16_t leverage, std::vector<std::string> synthetic)
|
||||
{
|
||||
fprintf(stderr, "assetchains_contract.%i vs eval_prices.%i\n",ASSETCHAINS_EARLYTXIDCONTRACT, EVAL_PRICES);
|
||||
if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && KOMODO_EARLYTXID_SCRIPTPUB.size() == 0 )
|
||||
{
|
||||
// Lock here, as in validation we cannot call lock in the function itself.
|
||||
// may not be needed as the validation call to update the global, is called in a LOCK already, and it can only update there and here.
|
||||
LOCK(cs_main);
|
||||
GetKomodoEarlytxidScriptPub();
|
||||
}
|
||||
/*
|
||||
int32_t nextheight = komodo_nextheight();
|
||||
CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nextheight); UniValue result(UniValue::VOBJ);
|
||||
struct CCcontract_info *cp, C;
|
||||
@@ -1404,15 +1424,14 @@ UniValue PricesBet(int64_t txfee, int64_t amount, int16_t leverage, std::vector<
|
||||
mtx.vout.push_back(MakeCC1vout(cp->evalcode, txfee, pricespk)); // vout1 cc marker (NVOUT_CCMARKER)
|
||||
mtx.vout.push_back(MakeCC1vout(cp->evalcode, betamount, pricespk)); // vout2 betamount
|
||||
mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(pricespk)) << OP_CHECKSIG)); // vout3 normal marker NVOUT_NORMALMARKER - TODO: remove it as we have cc marker now, when move to the new chain
|
||||
if ( KOMODO_PRICES_FEE_SCRIPTPUB.size() == 0 )
|
||||
if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && KOMODO_EARLYTXID_SCRIPTPUB.size() == 0 )
|
||||
{
|
||||
// Lock here, as in validation we cannot call lock in the function itself.
|
||||
// may not be needed as the validation call to update the global, is called in a LOCK already, and it can only update there and here.
|
||||
LOCK(cs_main);
|
||||
GetFeeAddress();
|
||||
GetKomodoEarlytxidScriptPub();
|
||||
}
|
||||
mtx.vout.push_back(CTxOut(amount-betamount, KOMODO_PRICES_FEE_SCRIPTPUB));
|
||||
|
||||
mtx.vout.push_back(CTxOut(amount-betamount, KOMODO_EARLYTXID_SCRIPTPUB));
|
||||
|
||||
rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, prices_betopret(mypk, nextheight - 1, amount, leverage, firstprice, vec, zeroid));
|
||||
return(prices_rawtxresult(result, rawtx, 0));
|
||||
@@ -1420,6 +1439,7 @@ UniValue PricesBet(int64_t txfee, int64_t amount, int16_t leverage, std::vector<
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "not enough funds"));
|
||||
return(result);
|
||||
*/
|
||||
}
|
||||
|
||||
// pricesaddfunding rpc impl: add yet another bet
|
||||
|
||||
@@ -29,7 +29,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
|
||||
unsigned int lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::Params& params);
|
||||
bool EnsureWalletIsAvailable(bool avoidException);
|
||||
extern bool fRequestShutdown;
|
||||
extern CScript KOMODO_PRICES_FEE_SCRIPTPUB;
|
||||
extern CScript KOMODO_EARLYTXID_SCRIPTPUB;
|
||||
|
||||
int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &txNew);
|
||||
uint8_t DecodeMaramaraCoinbaseOpRet(const CScript scriptPubKey,CPubKey &pk,int32_t &height,int32_t &unlockht);
|
||||
@@ -2063,7 +2063,6 @@ bool komodo_appendACscriptpub()
|
||||
{
|
||||
ASSETCHAINS_SCRIPTPUB.pop_back(); ASSETCHAINS_SCRIPTPUB.pop_back(); // remove last 2 chars.
|
||||
// get OP_RETURN from txid and append the HexStr of it to scriptpub
|
||||
// encoded opreturn incorrectly on TESTHC chain, once we no longer need this it can be changed to a straight +1 to drop OP_RETURN opcode.
|
||||
ASSETCHAINS_SCRIPTPUB.append(HexStr(tx.vout[i].scriptPubKey.begin()+3, tx.vout[i].scriptPubKey.end()));
|
||||
//fprintf(stderr, "ac_script.%s\n",ASSETCHAINS_SCRIPTPUB.c_str());
|
||||
didinit = true;
|
||||
@@ -2077,17 +2076,17 @@ bool komodo_appendACscriptpub()
|
||||
return false;
|
||||
}
|
||||
|
||||
void GetFeeAddress()
|
||||
void GetKomodoEarlytxidScriptPub()
|
||||
{
|
||||
if ( KOMODO_EARLYTXID == zeroid )
|
||||
{
|
||||
fprintf(stderr, "PLEASE RESTART DAEMON WITH -earlytxid.\n");
|
||||
fprintf(stderr, "Restart deamon with -earlytxid.\n");
|
||||
StartShutdown();
|
||||
return;
|
||||
}
|
||||
if ( KOMODO_SNAPSHOT_INTERVAL == 0 )
|
||||
if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && KOMODO_SNAPSHOT_INTERVAL == 0 )
|
||||
{
|
||||
fprintf(stderr, "PRICES FEE ADDRESS MUST HAVE -ac_snapshot enabled to pay out.\n");
|
||||
fprintf(stderr, "Prices->paymentsCC contract must have -ac_snapshot enabled to pay out.\n");
|
||||
StartShutdown();
|
||||
return;
|
||||
}
|
||||
@@ -2097,34 +2096,22 @@ void GetFeeAddress()
|
||||
StartShutdown();
|
||||
return;
|
||||
}
|
||||
CTransaction tx; uint256 blockhash, txid = zeroid; char txidaddr[64];
|
||||
CTransaction tx; uint256 blockhash; int32_t i;
|
||||
// get transaction and check that it occured before height 100.
|
||||
if ( myGetTransaction(KOMODO_EARLYTXID,tx,blockhash) && mapBlockIndex[blockhash]->GetHeight() < 100 )
|
||||
{
|
||||
for (int i = 0; i < tx.vout.size(); i++)
|
||||
for (i = 0; i < tx.vout.size(); i++)
|
||||
if ( tx.vout[i].scriptPubKey[0] == OP_RETURN )
|
||||
txid = uint256S(HexStr(tx.vout[i].scriptPubKey.begin()+3, tx.vout[i].scriptPubKey.end()));
|
||||
if ( txid == zeroid )
|
||||
break;
|
||||
if ( i < tx.vout.size() )
|
||||
{
|
||||
fprintf(stderr, "INVALID -earlytxid, restart daemon with correct txid.\n");
|
||||
StartShutdown();
|
||||
KOMODO_EARLYTXID_SCRIPTPUB = CScript(tx.vout[i].scriptPubKey.begin()+3, tx.vout[i].scriptPubKey.end());
|
||||
fprintf(stderr, "KOMODO_EARLYTXID_SCRIPTPUB.%s\n", HexStr(KOMODO_EARLYTXID_SCRIPTPUB.begin(),KOMODO_EARLYTXID_SCRIPTPUB.end()).c_str());
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "txid.%s\n", txid.GetHex().c_str());
|
||||
struct CCcontract_info *cp, C; CPubKey Paymentspk,txidpk;
|
||||
cp = CCinit(&C, EVAL_PAYMENTS);
|
||||
Paymentspk = GetUnspendable(cp,0);
|
||||
txidpk = CCtxidaddr(txidaddr,txid);
|
||||
GetCCaddress1of2(cp,txidaddr,Paymentspk,txidpk);
|
||||
CC *payoutCond = MakeCCcond1of2(EVAL_PAYMENTS,Paymentspk,txidpk);
|
||||
KOMODO_PRICES_FEE_SCRIPTPUB = CCPubKey(payoutCond);
|
||||
cc_free(payoutCond);
|
||||
fprintf(stderr, "KOMODO_PRICES_FEE_SCRIPTPUB.%s address.%s\n", HexStr(KOMODO_PRICES_FEE_SCRIPTPUB.begin(),KOMODO_PRICES_FEE_SCRIPTPUB.end()).c_str(),txidaddr);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "INVALID -earlytxid, restart daemon with correct txid.\n");
|
||||
StartShutdown();
|
||||
}
|
||||
fprintf(stderr, "INVALID -earlytxid, restart daemon with correct txid.\n");
|
||||
StartShutdown();
|
||||
}
|
||||
|
||||
int64_t komodo_checkcommission(CBlock *pblock,int32_t height)
|
||||
|
||||
@@ -84,6 +84,7 @@ extern uint8_t ASSETCHAINS_PRIVATE;
|
||||
extern int32_t USE_EXTERNAL_PUBKEY;
|
||||
extern char NOTARYADDRS[64][64];
|
||||
extern int32_t KOMODO_TESTNODE, KOMODO_SNAPSHOT_INTERVAL;
|
||||
extern int32_t ASSETCHAINS_EARLYTXIDCONTRACT;
|
||||
int tx_height( const uint256 &hash );
|
||||
extern std::vector<std::string> vWhiteListAddress;
|
||||
void komodo_netevent(std::vector<uint8_t> payload);
|
||||
@@ -117,4 +118,4 @@ int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblo
|
||||
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight);
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -110,7 +110,8 @@ extern int32_t KOMODO_LOADINGBLOCKS;
|
||||
unsigned int MAX_BLOCK_SIGOPS = 20000;
|
||||
|
||||
int32_t KOMODO_TESTNODE, KOMODO_SNAPSHOT_INTERVAL;
|
||||
CScript KOMODO_PRICES_FEE_SCRIPTPUB;
|
||||
CScript KOMODO_EARLYTXID_SCRIPTPUB;
|
||||
int32_t ASSETCHAINS_EARLYTXIDCONTRACT;
|
||||
|
||||
struct komodo_kv *KOMODO_KV;
|
||||
pthread_mutex_t KOMODO_KV_mutex,KOMODO_CC_mutex;
|
||||
|
||||
@@ -1759,6 +1759,8 @@ void komodo_args(char *argv0)
|
||||
printf("KOMODO_REWIND %d\n",KOMODO_REWIND);
|
||||
}
|
||||
KOMODO_EARLYTXID = Parseuint256(GetArg("-earlytxid","0").c_str());
|
||||
ASSETCHAINS_EARLYTXIDCONTRACT = GetArg("-ac_earlytxidcontract",0);
|
||||
fprintf(stderr, "ASSETCHAINS_EARLYTXIDCONTRACT.%i\n", ASSETCHAINS_EARLYTXIDCONTRACT);
|
||||
if ( name.c_str()[0] != 0 )
|
||||
{
|
||||
std::string selectedAlgo = GetArg("-ac_algo", std::string(ASSETCHAINS_ALGORITHMS[0]));
|
||||
@@ -2013,7 +2015,7 @@ void komodo_args(char *argv0)
|
||||
fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n");
|
||||
StartShutdown();
|
||||
}
|
||||
if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY[0] != 0 || ASSETCHAINS_BLOCKTIME != 60 || ASSETCHAINS_CBOPRET != 0 || Mineropret.size() != 0 || (ASSETCHAINS_NK[0] != 0 && ASSETCHAINS_NK[1] != 0) || KOMODO_SNAPSHOT_INTERVAL != 0 )
|
||||
if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY[0] != 0 || ASSETCHAINS_BLOCKTIME != 60 || ASSETCHAINS_CBOPRET != 0 || Mineropret.size() != 0 || (ASSETCHAINS_NK[0] != 0 && ASSETCHAINS_NK[1] != 0) || KOMODO_SNAPSHOT_INTERVAL != 0 || ASSETCHAINS_EARLYTXIDCONTRACT != 0 )
|
||||
{
|
||||
fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size());
|
||||
extraptr = extrabuf;
|
||||
@@ -2152,7 +2154,10 @@ void komodo_args(char *argv0)
|
||||
if ( KOMODO_SNAPSHOT_INTERVAL != 0 )
|
||||
{
|
||||
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(KOMODO_SNAPSHOT_INTERVAL),(void *)&KOMODO_SNAPSHOT_INTERVAL);
|
||||
fprintf(stderr, "snapshot interval.%i\n",KOMODO_SNAPSHOT_INTERVAL);
|
||||
}
|
||||
if ( ASSETCHAINS_EARLYTXIDCONTRACT != 0 )
|
||||
{
|
||||
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_EARLYTXIDCONTRACT),(void *)&ASSETCHAINS_EARLYTXIDCONTRACT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8000,6 +8000,7 @@ void RegisterWalletRPCCommands(CRPCTable &tableRPC)
|
||||
|
||||
UniValue opreturn_burn(const UniValue& params, bool fHelp)
|
||||
{
|
||||
std::vector<uint8_t> vHexStr; CScript opret; int32_t txfee = 10000;
|
||||
if (fHelp || (params.size() != 2))
|
||||
throw runtime_error("amount to burn, hexstring to send\n");
|
||||
struct CCcontract_info *cp, C; UniValue ret(UniValue::VOBJ);
|
||||
@@ -8009,30 +8010,22 @@ UniValue opreturn_burn(const UniValue& params, bool fHelp)
|
||||
|
||||
CAmount nAmount = AmountFromValue(params[0]);
|
||||
if (nAmount <= 10000)
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "must send at least 10000 sat");
|
||||
std::string strHex = params[1].get_str();
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "must burn at least 10000 sat");
|
||||
vHexStr = ParseHex(params[1].get_str());
|
||||
if ( vHexStr.size() == 0 )
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "hexstring is not valid.");
|
||||
|
||||
CPubKey myPubkey = pubkey2pk(Mypubkey());
|
||||
CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight());
|
||||
|
||||
int64_t normalInputs = AddNormalinputs(mtx, myPubkey, nAmount, 60);
|
||||
if (normalInputs < nAmount)
|
||||
throw runtime_error("not enough normals\n");
|
||||
|
||||
CScript opret; uint8_t scripthex[8192];
|
||||
|
||||
decode_hex(scripthex,strHex.size()/2,(char *)strHex.c_str());
|
||||
std::string test;
|
||||
test.append((char*)scripthex);
|
||||
std::vector<uint8_t> opretdata(test.begin(), test.end());
|
||||
opret << OP_RETURN << E_MARSHAL(ss << opretdata);
|
||||
/*CScript opret; uint8_t *ptr;
|
||||
opret << OP_RETURN << 0;
|
||||
int32_t len = strlen(strHex.c_str());
|
||||
len >>=1;
|
||||
opret.resize(len+2);
|
||||
ptr = (uint8_t *)&opret[1];
|
||||
decode_hex(ptr,len,(char *)strHex.c_str()); */
|
||||
mtx.vout.push_back(CTxOut(nAmount,opret));
|
||||
ret.push_back(Pair("hex",FinalizeCCTx(0, cp, mtx, myPubkey, 10000, CScript())));
|
||||
|
||||
opret << OP_RETURN << E_MARSHAL(ss << vHexStr);
|
||||
|
||||
mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(myPubkey)) << OP_CHECKSIG));
|
||||
mtx.vout.push_back(CTxOut(nAmount,opret));
|
||||
ret.push_back(Pair("hex",FinalizeCCTx(0, cp, mtx, myPubkey, txfee, CScript())));
|
||||
return(ret);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user