From e51e9274e1a1d479f9fcdfbce625721edfdc71cd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 21 Jul 2018 08:26:59 -1100 Subject: [PATCH] Test --- src/cc/assets.cpp | 22 ++++++++-------------- src/wallet/rpcwallet.cpp | 21 ++++++++++++++++----- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 59042b911..813437970 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -359,9 +359,6 @@ uint8_t DecodeOpRet(const CScript &scriptPubKey,uint256 &assetid,uint256 &asseti case 't': case 'x': case 'o': 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); 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 ) { assetid = revuint256(assetid); - fprintf(stderr,"got price %llu\n",(long long)price); + //fprintf(stderr,"got price %llu\n",(long long)price); return(funcid); } break; @@ -698,30 +695,30 @@ std::string CreateAsset(uint64_t txfee,uint64_t assetsupply,std::string name,std return(0); } -std::string CreateAssetTransfer(uint64_t txfee,uint256 assetid,std::vectoroutputs,std::vectoramounts) +std::string AssetTransfer(uint64_t txfee,uint256 assetid,std::vector 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 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); if ( AddNormalinputs(mtx,mypk,txfee,1) > 0 ) { - n = outputs.size(); + /*n = outputs.size(); if ( n == amounts.size() ) { for (i=0; i 0 ) { if ( inputs > total ) CCchange = (inputs - total); - for (i=0; i paramsNull,const CTransactio return eval->Invalid("no-vouts"); else if ( (funcid= DecodeOpRet(tx.vout[n-1].scriptPubKey,assetid,assetid2,amount,origpubkey)) == 0 ) 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 ) return eval->Invalid("cant find asset create txid"); if ( assetid2 != zero && eval->GetTxUnconfirmed(assetid2,createTx,hashBlock) == 0 ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 13816496f..c1352dfe2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -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 CreateAssetTransfer(uint64_t txfee,uint256 assetid,std::vectoroutputs,std::vectoramounts); +std::string AssetTransfer(uint64_t txfee,uint256 assetid,std::vector destpubkey,uint64_t total); 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 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("hex", hex)); - } else result.push_back(Pair("error", "could create transaction")); + } else result.push_back(Pair("error", "couldnt create transaction")); return(result); } 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 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); } @@ -4882,7 +4893,7 @@ UniValue tokenbid(const UniValue& params, bool fHelp) { result.push_back(Pair("result", "success")); 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); } @@ -4898,7 +4909,7 @@ UniValue tokencancelbid(const UniValue& params, bool fHelp) { result.push_back(Pair("result", "success")); 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); }