From 2f51e8fae5ebdd4b0c3b82b27cb0a24a7fa1d4cd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 9 Sep 2018 21:48:22 -1100 Subject: [PATCH] Test --- src/cc/gateways.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index cfca40f65..26711483c 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -479,7 +479,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,std::vector std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,uint256 deposittxid,std::vector claimpubkey,int64_t amount) { - CMutableTransaction mtx; CTransaction tx; CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C,*assetscp,C2; uint8_t M,N,taddr,prefix,prefix2; std::string coin; std::vector msigpubkeys; int64_t totalsupply,amount,inputs,CCchange=0; int32_t numvouts; uint256 hashBlock,assetid,oracletxid; char str[65],depositaddr[64]; + CMutableTransaction mtx; CTransaction tx; CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C,*assetscp,C2; uint8_t M,N,taddr,prefix,prefix2; std::string coin; std::vector msigpubkeys; int64_t totalsupply,depositamount,inputs,CCchange=0; int32_t numvouts; uint256 hashBlock,assetid,oracletxid; char str[65],depositaddr[64]; cp = CCinit(&C,EVAL_GATEWAYS); assetscp = CCinit(&C2,EVAL_ASSETS); memcpy(cp->unspendablepriv2,assetscp->CCpriv,32); @@ -502,9 +502,9 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui fprintf(stderr,"cant find bindtxid %s\n",uint256_str(str,bindtxid)); return(""); } - if ( (amount= GatewaysDepositval(tx)) == 0 ) + if ( (depositamount= GatewaysDepositval(tx)) != amount ) { - fprintf(stderr,"invalid Gateways deposittxid %s\n",uint256_str(str,deposittxid)); + fprintf(stderr,"invalid Gateways deposittxid %s %.8f != %.8f\n",uint256_str(str,deposittxid),(double)depositamount/COIN,(double)amount/COIN); return(""); } if ( AddNormalinputs(mtx,mypk,txfee,1) > 0 ) @@ -514,7 +514,7 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui if ( inputs > amount ) CCchange = (inputs - amount); mtx.vin.push_back(CTxIn(deposittxid,0,CScript())); - mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,total,mypk)); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,amount,mypk)); if ( CCchange != 0 ) mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,CCchange,gatewayspk)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeAssetOpRet('t',assetid,zeroid,0,Mypubkey()))); @@ -526,7 +526,7 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin,std::vector withdrawpub,int64_t amount) { - CMutableTransaction mtx; CTransaction tx; CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C,*assetscp,C2; uint256 assetid,hashBlock; int32_t numvouts; int64_t totalsupply,inputs,CCchange=0; uint8_t M,N,taddr,prefix,prefix2; std::string coin; std::vector msigpubkeys; char depositaddr[64]; + CMutableTransaction mtx; CTransaction tx; CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C,*assetscp,C2; uint256 assetid,hashBlock,oracletxid; int32_t numvouts; int64_t totalsupply,inputs,CCchange=0; uint8_t M,N,taddr,prefix,prefix2; std::string coin; std::vector msigpubkeys; char depositaddr[64],str[65]; cp = CCinit(&C,EVAL_GATEWAYS); assetscp = CCinit(&C2,EVAL_ASSETS); if ( txfee == 0 ) @@ -543,7 +543,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin fprintf(stderr,"invalid bindtxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str()); return(""); } - if ( AddNormalinputs(mtx,mypk,2*txfee,1) > 0 ) + if ( AddNormalinputs(mtx,mypk,2*txfee,1) > 0 ) { if ( (inputs= AddAssetInputs(assetscp,mtx,mypk,assetid,amount,60)) > 0 ) { @@ -553,7 +553,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin if ( CCchange != 0 ) mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,CCchange,mypk)); mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG)); - return(FinalizeCCTx(mask,assetscp,mtx,mypk,txfee,EncodeAssetOpRet('t',assetid,zeroid,0,Mypubkey()))); + return(FinalizeCCTx(0,assetscp,mtx,mypk,txfee,EncodeAssetOpRet('t',assetid,zeroid,0,Mypubkey()))); } } fprintf(stderr,"cant find enough inputs or mismatched total\n");