Fix 'b'/'B' vout0 exemption
This commit is contained in:
@@ -238,7 +238,7 @@ uint64_t IsAssetvout(uint64_t &price,std::vector<uint8_t> &origpubkey,const CTra
|
||||
if ( refassetid == tx.GetHash() && v == 0 )
|
||||
return(nValue);
|
||||
}
|
||||
else if ( funcid == 'b' || funcid == 'B' )
|
||||
else if ( (funcid == 'b' || funcid == 'B') && v == 0 ) // critical! 'b'/'B' vout0 is NOT asset
|
||||
return(0);
|
||||
else if ( funcid != 'E' )
|
||||
{
|
||||
@@ -319,22 +319,31 @@ bool AssetExactAmounts(uint64_t &inputs,uint64_t &outputs,Eval* eval,const CTran
|
||||
numvins = tx.vin.size();
|
||||
numvouts = tx.vout.size();
|
||||
inputs = outputs = 0;
|
||||
for (i=1; i<numvins; i++)
|
||||
for (i=0; i<numvins; i++)
|
||||
{
|
||||
if ( IsAssetsInput(tx.vin[i].scriptSig) != 0 )
|
||||
{
|
||||
if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 )
|
||||
return eval->Invalid("always should find vin, but didnt");
|
||||
else if ( (assetoshis= IsAssetvout(tmpprice,tmporigpubkey,vinTx,tx.vin[i].prevout.n,assetid)) != 0 )
|
||||
{
|
||||
fprintf(stderr,"vin%d %llu, ",i,(long long)assetoshis)
|
||||
inputs += assetoshis;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i=0; i<numvouts; i++)
|
||||
{
|
||||
if ( (assetoshis= IsAssetvout(tmpprice,tmporigpubkey,tx,i,assetid)) != 0 )
|
||||
{
|
||||
fprintf(stderr,"vout%d %llu, ",i,(long long)assetoshis)
|
||||
outputs += assetoshis;
|
||||
}
|
||||
}
|
||||
if ( inputs != outputs )
|
||||
{
|
||||
fprintf(stderr,"inputs %.8f vs %.8f outputs\n",(double)inputs/COIN,(double)outputs/COIN);
|
||||
return(false);
|
||||
}
|
||||
else return(true);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ bool AssetValidate(Eval* eval,const CTransaction &tx,int32_t numvouts,uint8_t fu
|
||||
if ( assetid == zero )
|
||||
return eval->Invalid("illegal assetid");
|
||||
else if ( AssetExactAmounts(inputs,outputs,eval,tx,assetid) == false )
|
||||
eval->Invalid("asset inputs != outputs");
|
||||
return eval->Invalid("asset inputs != outputs");
|
||||
}
|
||||
switch ( funcid )
|
||||
{
|
||||
@@ -310,11 +310,11 @@ bool AssetValidate(Eval* eval,const CTransaction &tx,int32_t numvouts,uint8_t fu
|
||||
|
||||
bool ProcessAssets(Eval* eval, std::vector<uint8_t> paramsNull,const CTransaction &ctx, unsigned int nIn)
|
||||
{
|
||||
static uint256 zero;
|
||||
CTransaction createTx; uint256 assetid,assetid2,hashBlock; uint8_t funcid; int32_t i,n; uint64_t amount; std::vector<uint8_t> origpubkey;
|
||||
//txid = ctx.GetHash();
|
||||
//if ( txid == prevtxid )
|
||||
// return(true);
|
||||
static uint256 zero,prevtxid;
|
||||
CTransaction createTx; uint256 txid,assetid,assetid2,hashBlock; uint8_t funcid; int32_t i,n; uint64_t amount; std::vector<uint8_t> origpubkey;
|
||||
txid = ctx.GetHash();
|
||||
if ( txid == prevtxid )
|
||||
return(true);
|
||||
fprintf(stderr,"ProcessAssets\n");
|
||||
if ( paramsNull.size() != 0 ) // Don't expect params
|
||||
return eval->Invalid("Cannot have params");
|
||||
@@ -328,9 +328,7 @@ bool ProcessAssets(Eval* eval, std::vector<uint8_t> paramsNull,const CTransactio
|
||||
return eval->Invalid("cant find asset2 create txid");
|
||||
else if ( AssetValidate(eval,ctx,n,funcid,assetid,assetid2,amount,origpubkey) != 0 )
|
||||
{
|
||||
//prevtxid = txid;
|
||||
if ( funcid == 'B' )
|
||||
return(false);
|
||||
prevtxid = txid;
|
||||
fprintf(stderr,"AssetValidate.(%c) passed\n",funcid);
|
||||
return(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user