Test
This commit is contained in:
@@ -479,7 +479,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,std::vector<CPubKey>
|
|||||||
|
|
||||||
std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,uint256 deposittxid,std::vector<uint8_t> claimpubkey,int64_t amount)
|
std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,uint256 deposittxid,std::vector<uint8_t> 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<CPubKey> 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<CPubKey> 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);
|
cp = CCinit(&C,EVAL_GATEWAYS);
|
||||||
assetscp = CCinit(&C2,EVAL_ASSETS);
|
assetscp = CCinit(&C2,EVAL_ASSETS);
|
||||||
memcpy(cp->unspendablepriv2,assetscp->CCpriv,32);
|
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));
|
fprintf(stderr,"cant find bindtxid %s\n",uint256_str(str,bindtxid));
|
||||||
return("");
|
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("");
|
return("");
|
||||||
}
|
}
|
||||||
if ( AddNormalinputs(mtx,mypk,txfee,1) > 0 )
|
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 )
|
if ( inputs > amount )
|
||||||
CCchange = (inputs - amount);
|
CCchange = (inputs - amount);
|
||||||
mtx.vin.push_back(CTxIn(deposittxid,0,CScript()));
|
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 )
|
if ( CCchange != 0 )
|
||||||
mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,CCchange,gatewayspk));
|
mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,CCchange,gatewayspk));
|
||||||
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeAssetOpRet('t',assetid,zeroid,0,Mypubkey())));
|
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<uint8_t> withdrawpub,int64_t amount)
|
std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin,std::vector<uint8_t> 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<CPubKey> 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<CPubKey> msigpubkeys; char depositaddr[64],str[65];
|
||||||
cp = CCinit(&C,EVAL_GATEWAYS);
|
cp = CCinit(&C,EVAL_GATEWAYS);
|
||||||
assetscp = CCinit(&C2,EVAL_ASSETS);
|
assetscp = CCinit(&C2,EVAL_ASSETS);
|
||||||
if ( txfee == 0 )
|
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());
|
fprintf(stderr,"invalid bindtxid %s coin.%s\n",uint256_str(str,bindtxid),coin.c_str());
|
||||||
return("");
|
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 )
|
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 )
|
if ( CCchange != 0 )
|
||||||
mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,CCchange,mypk));
|
mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,CCchange,mypk));
|
||||||
mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(withdrawpub)) << OP_CHECKSIG));
|
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");
|
fprintf(stderr,"cant find enough inputs or mismatched total\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user