Test
This commit is contained in:
@@ -301,7 +301,6 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
|
|||||||
if ( othertokenscond != 0 )
|
if ( othertokenscond != 0 )
|
||||||
cc_free(othertokenscond);
|
cc_free(othertokenscond);
|
||||||
std::string strHex = EncodeHexTx(mtx);
|
std::string strHex = EncodeHexTx(mtx);
|
||||||
fprintf(stderr,"hex.(%s)\n",strHex.c_str());
|
|
||||||
if ( strHex.size() > 0 )
|
if ( strHex.size() > 0 )
|
||||||
return(strHex);
|
return(strHex);
|
||||||
else return("0");
|
else return("0");
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ UniValue payments_rawtxresult(UniValue &result,std::string rawtx,int32_t broadca
|
|||||||
result.push_back(Pair("hex",rawtx));
|
result.push_back(Pair("hex",rawtx));
|
||||||
if ( DecodeHexTx(tx,rawtx) != 0 )
|
if ( DecodeHexTx(tx,rawtx) != 0 )
|
||||||
{
|
{
|
||||||
|
fprintf(stderr,"decoded\n");
|
||||||
if ( broadcastflag != 0 && myAddtomempool(tx) != 0 )
|
if ( broadcastflag != 0 && myAddtomempool(tx) != 0 )
|
||||||
RelayTransaction(tx);
|
RelayTransaction(tx);
|
||||||
result.push_back(Pair("txid",tx.GetHash().ToString()));
|
result.push_back(Pair("txid",tx.GetHash().ToString()));
|
||||||
@@ -295,7 +296,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
|
|||||||
{
|
{
|
||||||
int32_t latestheight,nextheight = komodo_nextheight();
|
int32_t latestheight,nextheight = komodo_nextheight();
|
||||||
CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); uint256 createtxid,hashBlock;
|
CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); uint256 createtxid,hashBlock;
|
||||||
CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,numoprets=0,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64],destaddr[64]; std::vector<uint256> txidoprets; std::string rawtx;
|
CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,m,numoprets=0,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64],destaddr[64]; std::vector<uint256> txidoprets;
|
||||||
cJSON *params = payments_reparse(&n,jsonstr);
|
cJSON *params = payments_reparse(&n,jsonstr);
|
||||||
mypk = pubkey2pk(Mypubkey());
|
mypk = pubkey2pk(Mypubkey());
|
||||||
Paymentspk = GetUnspendable(cp,0);
|
Paymentspk = GetUnspendable(cp,0);
|
||||||
@@ -324,7 +325,8 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
|
|||||||
}
|
}
|
||||||
txidpk = CCtxidaddr(txidaddr,createtxid);
|
txidpk = CCtxidaddr(txidaddr,createtxid);
|
||||||
mtx.vout.push_back(MakeCC1of2vout(EVAL_PAYMENTS,0,Paymentspk,txidpk));
|
mtx.vout.push_back(MakeCC1of2vout(EVAL_PAYMENTS,0,Paymentspk,txidpk));
|
||||||
for (i=0; i<txidoprets.size(); i++)
|
m = txidoprets.size();
|
||||||
|
for (i=0; i<m; i++)
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> scriptPubKey,opret;
|
std::vector<uint8_t> scriptPubKey,opret;
|
||||||
vout.nValue = 0;
|
vout.nValue = 0;
|
||||||
@@ -343,7 +345,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
|
|||||||
} else break;
|
} else break;
|
||||||
mtx.vout.push_back(vout);
|
mtx.vout.push_back(vout);
|
||||||
}
|
}
|
||||||
if ( i != txidoprets.size() )
|
if ( i != m )
|
||||||
{
|
{
|
||||||
result.push_back(Pair("result","error"));
|
result.push_back(Pair("result","error"));
|
||||||
result.push_back(Pair("error","invalid txidoprets[i]"));
|
result.push_back(Pair("error","invalid txidoprets[i]"));
|
||||||
@@ -371,13 +373,14 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
|
|||||||
free_json(params);
|
free_json(params);
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
for (i=0; i<txidoprets.size(); i++)
|
for (i=0; i<m; i++)
|
||||||
{
|
{
|
||||||
mtx.vout[i+1].nValue *= amount;
|
mtx.vout[i+1].nValue *= amount;
|
||||||
mtx.vout[i+1].nValue /= totalallocations;
|
mtx.vout[i+1].nValue /= totalallocations;
|
||||||
}
|
}
|
||||||
if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,amount+PAYMENTS_TXFEE,60,createtxid,latestheight)) >= amount )
|
if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,amount+PAYMENTS_TXFEE,60,createtxid,latestheight)) >= amount )
|
||||||
{
|
{
|
||||||
|
std::string rawtx;
|
||||||
if ( (CCchange= (inputsum - amount)) >= PAYMENTS_TXFEE )
|
if ( (CCchange= (inputsum - amount)) >= PAYMENTS_TXFEE )
|
||||||
mtx.vout[0].nValue = CCchange;
|
mtx.vout[0].nValue = CCchange;
|
||||||
mtx.vout.push_back(CTxOut(0,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG));
|
mtx.vout.push_back(CTxOut(0,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG));
|
||||||
@@ -386,6 +389,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
|
|||||||
rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret);
|
rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,onlyopret);
|
||||||
if ( params != 0 )
|
if ( params != 0 )
|
||||||
free_json(params);
|
free_json(params);
|
||||||
|
fprintf(stderr,"got rawtx.(%s)\n",rawtx.c_str());
|
||||||
return(payments_rawtxresult(result,rawtx,0));
|
return(payments_rawtxresult(result,rawtx,0));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user