Chance for AssetConvert to validate
This commit is contained in:
@@ -490,8 +490,9 @@ bool AssetExactAmounts(struct CCcontract_info *cp,int64_t &inputs,int32_t starti
|
|||||||
fprintf(stderr,"i.%d starti.%d numvins.%d\n",i,starti,numvins);
|
fprintf(stderr,"i.%d starti.%d numvins.%d\n",i,starti,numvins);
|
||||||
return eval->Invalid("always should find vin, but didnt");
|
return eval->Invalid("always should find vin, but didnt");
|
||||||
}
|
}
|
||||||
else if ( (assetoshis= IsAssetvout(tmpprice,tmporigpubkey,vinTx,tx.vin[i].prevout.n,assetid)) != 0 )
|
else if ( (assetoshis= IsAssetvout(tmpprice,tmporigpubkey,vinTx,tx.vin[i].prevout.n,assetid)) != 0 || vinTx.vout[i].scriptPubKey.IsPayToCryptoCondition() != 0 )
|
||||||
{
|
{
|
||||||
|
assetoshis = vinTx.vout[i].nValue;
|
||||||
fprintf(stderr,"vin%d %llu, ",i,(long long)assetoshis);
|
fprintf(stderr,"vin%d %llu, ",i,(long long)assetoshis);
|
||||||
inputs += assetoshis;
|
inputs += assetoshis;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -261,9 +261,8 @@ std::string AssetConvert(int64_t txfee,uint256 assetid,std::vector<uint8_t> dest
|
|||||||
{
|
{
|
||||||
if ( inputs > total )
|
if ( inputs > total )
|
||||||
CCchange = (inputs - total);
|
CCchange = (inputs - total);
|
||||||
|
mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,CCchange,mypk));
|
||||||
mtx.vout.push_back(MakeCC1vout(evalcode,total,pubkey2pk(destpubkey)));
|
mtx.vout.push_back(MakeCC1vout(evalcode,total,pubkey2pk(destpubkey)));
|
||||||
if ( CCchange != 0 )
|
|
||||||
mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,CCchange,mypk));
|
|
||||||
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())));
|
||||||
} 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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,7 +167,6 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx
|
|||||||
//vout.n-1: opreturn [EVAL_ASSETS] ['c'] [{"<assetname>":"<description>"}]
|
//vout.n-1: opreturn [EVAL_ASSETS] ['c'] [{"<assetname>":"<description>"}]
|
||||||
return eval->Invalid("unexpected AssetValidate for createasset");
|
return eval->Invalid("unexpected AssetValidate for createasset");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't': // transfer
|
case 't': // transfer
|
||||||
//vin.0: normal input
|
//vin.0: normal input
|
||||||
//vin.1 .. vin.n-1: valid CC outputs
|
//vin.1 .. vin.n-1: valid CC outputs
|
||||||
|
|||||||
@@ -134,7 +134,11 @@
|
|||||||
Implementation Issues:
|
Implementation Issues:
|
||||||
When thinking about validation, it is clear that we cant use EVAL_ASSETS for the locked coins as there wont be any enforcement of the gateways locking. This means we need a way to transfer assets into gateways outputs and back. It seems a tokenconvert rpc will be needed and hopefully that will be enough to make it all work properly.
|
When thinking about validation, it is clear that we cant use EVAL_ASSETS for the locked coins as there wont be any enforcement of the gateways locking. This means we need a way to transfer assets into gateways outputs and back. It seems a tokenconvert rpc will be needed and hopefully that will be enough to make it all work properly.
|
||||||
|
|
||||||
Care must be taken so that tokens are not lost and can be converted back
|
Care must be taken so that tokens are not lost and can be converted back.
|
||||||
|
|
||||||
|
This changes the usage to require tokenconvert before doing the bind and also tokenconvert before doing a withdraw. EVAL_GATEWAYS has evalcode of 251
|
||||||
|
|
||||||
|
The gatewaysclaim automatically converts the deposit amount of tokens back to EVAL_ASSETS.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user