Test
This commit is contained in:
@@ -359,9 +359,6 @@ uint8_t DecodeOpRet(const CScript &scriptPubKey,uint256 &assetid,uint256 &asseti
|
|||||||
case 't': case 'x': case 'o':
|
case 't': case 'x': case 'o':
|
||||||
if ( E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> assetid) != 0 )
|
if ( E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> assetid) != 0 )
|
||||||
{
|
{
|
||||||
int32_t i; for (i=0; i<32; i++)
|
|
||||||
fprintf(stderr,"%02x",((uint8_t *)&assetid)[i]);
|
|
||||||
fprintf(stderr," got assetid\n");
|
|
||||||
assetid = revuint256(assetid);
|
assetid = revuint256(assetid);
|
||||||
return(funcid);
|
return(funcid);
|
||||||
}
|
}
|
||||||
@@ -370,7 +367,7 @@ uint8_t DecodeOpRet(const CScript &scriptPubKey,uint256 &assetid,uint256 &asseti
|
|||||||
if ( E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> assetid; ss >> price; ss >> origpubkey) != 0 )
|
if ( E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> assetid; ss >> price; ss >> origpubkey) != 0 )
|
||||||
{
|
{
|
||||||
assetid = revuint256(assetid);
|
assetid = revuint256(assetid);
|
||||||
fprintf(stderr,"got price %llu\n",(long long)price);
|
//fprintf(stderr,"got price %llu\n",(long long)price);
|
||||||
return(funcid);
|
return(funcid);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -698,30 +695,30 @@ std::string CreateAsset(uint64_t txfee,uint64_t assetsupply,std::string name,std
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CreateAssetTransfer(uint64_t txfee,uint256 assetid,std::vector<CPubKey>outputs,std::vector<uint64_t>amounts)
|
std::string AssetTransfer(uint64_t txfee,uint256 assetid,std::vector<uint8_t> destpubkey,uint64_t total)
|
||||||
{
|
{
|
||||||
CMutableTransaction mtx; CPubKey mypk; int32_t i,n; uint64_t CCchange=0,inputs=0,total=0;
|
CMutableTransaction mtx; CPubKey mypk; uint64_t CCchange=0,inputs=0; //int32_t i,n;
|
||||||
if ( txfee == 0 )
|
if ( txfee == 0 )
|
||||||
txfee = 10000;
|
txfee = 10000;
|
||||||
mypk = pubkey2pk(Mypubkey());
|
mypk = pubkey2pk(Mypubkey());
|
||||||
if ( AddNormalinputs(mtx,mypk,txfee,1) > 0 )
|
if ( AddNormalinputs(mtx,mypk,txfee,1) > 0 )
|
||||||
{
|
{
|
||||||
n = outputs.size();
|
/*n = outputs.size();
|
||||||
if ( n == amounts.size() )
|
if ( n == amounts.size() )
|
||||||
{
|
{
|
||||||
for (i=0; i<n; i++)
|
for (i=0; i<n; i++)
|
||||||
total += amounts[i];
|
total += amounts[i];*/
|
||||||
if ( (inputs= AddCCinputs(mtx,mypk,assetid,total)) > 0 )
|
if ( (inputs= AddCCinputs(mtx,mypk,assetid,total)) > 0 )
|
||||||
{
|
{
|
||||||
if ( inputs > total )
|
if ( inputs > total )
|
||||||
CCchange = (inputs - total);
|
CCchange = (inputs - total);
|
||||||
for (i=0; i<n; i++)
|
//for (i=0; i<n; i++)
|
||||||
mtx.vout.push_back(MakeAssetsVout(amounts[i],outputs[i]));
|
mtx.vout.push_back(MakeAssetsVout(total,pubkey2pk(pubkey)));
|
||||||
if ( CCchange != 0 )
|
if ( CCchange != 0 )
|
||||||
mtx.vout.push_back(MakeAssetsVout(CCchange,mypk));
|
mtx.vout.push_back(MakeAssetsVout(CCchange,mypk));
|
||||||
return(FinalizeCCTx(EVAL_ASSETS,mtx,mypk,txfee,EncodeOpRet('t',assetid,zeroid,0,Mypubkey())));
|
return(FinalizeCCTx(EVAL_ASSETS,mtx,mypk,txfee,EncodeOpRet('t',assetid,zeroid,0,Mypubkey())));
|
||||||
} else fprintf(stderr,"not enough CC asset inputs for %.8f\n",(double)total/COIN);
|
} else fprintf(stderr,"not enough CC asset inputs for %.8f\n",(double)total/COIN);
|
||||||
} else fprintf(stderr,"numoutputs.%d != numamounts.%d\n",n,(int32_t)amounts.size());
|
//} else fprintf(stderr,"numoutputs.%d != numamounts.%d\n",n,(int32_t)amounts.size());
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@@ -1107,9 +1104,6 @@ bool ProcessAssets(Eval* eval, std::vector<uint8_t> paramsNull,const CTransactio
|
|||||||
return eval->Invalid("no-vouts");
|
return eval->Invalid("no-vouts");
|
||||||
else if ( (funcid= DecodeOpRet(tx.vout[n-1].scriptPubKey,assetid,assetid2,amount,origpubkey)) == 0 )
|
else if ( (funcid= DecodeOpRet(tx.vout[n-1].scriptPubKey,assetid,assetid2,amount,origpubkey)) == 0 )
|
||||||
return eval->Invalid("Invalid opreturn payload");
|
return eval->Invalid("Invalid opreturn payload");
|
||||||
for (i=31; i>=0; i--)
|
|
||||||
fprintf(stderr,"%02x",((uint8_t *)&assetid)[i]);
|
|
||||||
fprintf(stderr," got assetid\n");
|
|
||||||
if ( eval->GetTxUnconfirmed(assetid,createTx,hashBlock) == 0 )
|
if ( eval->GetTxUnconfirmed(assetid,createTx,hashBlock) == 0 )
|
||||||
return eval->Invalid("cant find asset create txid");
|
return eval->Invalid("cant find asset create txid");
|
||||||
if ( assetid2 != zero && eval->GetTxUnconfirmed(assetid2,createTx,hashBlock) == 0 )
|
if ( assetid2 != zero && eval->GetTxUnconfirmed(assetid2,createTx,hashBlock) == 0 )
|
||||||
|
|||||||
@@ -4831,7 +4831,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string CreateAsset(uint64_t txfee,uint64_t assetsupply,std::string name,std::string description);
|
std::string CreateAsset(uint64_t txfee,uint64_t assetsupply,std::string name,std::string description);
|
||||||
std::string CreateAssetTransfer(uint64_t txfee,uint256 assetid,std::vector<CPubKey>outputs,std::vector<uint64_t>amounts);
|
std::string AssetTransfer(uint64_t txfee,uint256 assetid,std::vector<uint8_t> destpubkey,uint64_t total);
|
||||||
std::string CreateBuyOffer(uint64_t txfee,uint64_t bidamount,uint256 assetid,uint64_t pricetotal);
|
std::string CreateBuyOffer(uint64_t txfee,uint64_t bidamount,uint256 assetid,uint64_t pricetotal);
|
||||||
std::string CancelBuyOffer(uint64_t txfee,uint256 assetid,uint256 bidtxid);
|
std::string CancelBuyOffer(uint64_t txfee,uint256 assetid,uint256 bidtxid);
|
||||||
std::string FillBuyOffer(uint64_t txfee,uint256 assetid,uint256 bidtxid,uint256 filltxid,int32_t fillvout);
|
std::string FillBuyOffer(uint64_t txfee,uint256 assetid,uint256 bidtxid,uint256 filltxid,int32_t fillvout);
|
||||||
@@ -4858,13 +4858,24 @@ UniValue tokencreate(const UniValue& params, bool fHelp)
|
|||||||
{
|
{
|
||||||
result.push_back(Pair("result", "success"));
|
result.push_back(Pair("result", "success"));
|
||||||
result.push_back(Pair("hex", hex));
|
result.push_back(Pair("hex", hex));
|
||||||
} else result.push_back(Pair("error", "could create transaction"));
|
} else result.push_back(Pair("error", "couldnt create transaction"));
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue tokentransfer(const UniValue& params, bool fHelp)
|
UniValue tokentransfer(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ); std::string hex; uint64_t amount; uint256 tokenid;
|
||||||
|
if ( fHelp || params.size() != 3 )
|
||||||
|
throw runtime_error("tokentransfer tokenid destpubkey amount\n");
|
||||||
|
tokenid = Parseuint256((char *)params[0].get_str().c_str());
|
||||||
|
std::vector<unsigned char> pubkey(ParseHex(params[1].get_str().c_str()));
|
||||||
|
amount = atol(params[2].get_str().c_str());
|
||||||
|
hex = AssetTransfer(0,tokenid,pubkey,amount);
|
||||||
|
if ( hex.size() > 0 )
|
||||||
|
{
|
||||||
|
result.push_back(Pair("result", "success"));
|
||||||
|
result.push_back(Pair("hex", hex));
|
||||||
|
} else result.push_back(Pair("error", "couldnt transfer assets"));
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4882,7 +4893,7 @@ UniValue tokenbid(const UniValue& params, bool fHelp)
|
|||||||
{
|
{
|
||||||
result.push_back(Pair("result", "success"));
|
result.push_back(Pair("result", "success"));
|
||||||
result.push_back(Pair("hex", hex));
|
result.push_back(Pair("hex", hex));
|
||||||
} else result.push_back(Pair("error", "could create bid"));
|
} else result.push_back(Pair("error", "couldnt create bid"));
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4898,7 +4909,7 @@ UniValue tokencancelbid(const UniValue& params, bool fHelp)
|
|||||||
{
|
{
|
||||||
result.push_back(Pair("result", "success"));
|
result.push_back(Pair("result", "success"));
|
||||||
result.push_back(Pair("hex", hex));
|
result.push_back(Pair("hex", hex));
|
||||||
} else result.push_back(Pair("error", "could cancel bid"));
|
} else result.push_back(Pair("error", "couldnt cancel bid"));
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user