From 1d504829f16a1c69191eee0b66cdad69f79313b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 23 Jul 2018 00:24:32 -1100 Subject: [PATCH] Fix 'b'/'B' vout0 exemption --- src/cc/CCassetsCore.cpp | 13 +++++++++++-- src/cc/assets.cpp | 16 +++++++--------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index ba0769d46..d19fa6aad 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -238,7 +238,7 @@ uint64_t IsAssetvout(uint64_t &price,std::vector &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; iGetTxUnconfirmed(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; iInvalid("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 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 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 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 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); }