From 0588f5dc67a8c6de01690f48ac2960b72b41a527 Mon Sep 17 00:00:00 2001 From: dimxy Date: Wed, 16 Jan 2019 19:21:41 +0500 Subject: [PATCH] corr unspendable addr for 'S' --- src/cc/CCassetsCore.cpp | 17 +++++++++-------- src/cc/assets.cpp | 5 ++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index ebb9ff262..34d773d28 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -365,14 +365,15 @@ bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CT bool GetAssetorigaddrs(struct CCcontract_info *cp,char *CCaddr,char *destaddr,const CTransaction& tx) { - uint256 assetid,assetid2; int64_t price,nValue=0; int32_t n; uint8_t funcid; std::vector origpubkey; + uint256 assetid,assetid2; int64_t price,nValue=0; int32_t n; uint8_t funcid; + std::vector origpubkey; CScript script; uint8_t evalCode; n = tx.vout.size(); - if ( n == 0 || (funcid= DecodeAssetTokenOpRet(tx.vout[n-1].scriptPubKey, evalCode,assetid,assetid2,price,origpubkey)) == 0 ) + if( n == 0 || (funcid= DecodeAssetTokenOpRet(tx.vout[n-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) == 0 ) return(false); - if ( GetCCaddress(cp, CCaddr, pubkey2pk(origpubkey)) != 0 && Getscriptaddress(destaddr, CScript() << origpubkey << OP_CHECKSIG) != 0 ) + if( GetTokensCCaddress(cp, CCaddr, pubkey2pk(origpubkey)) != 0 && Getscriptaddress(destaddr, CScript() << origpubkey << OP_CHECKSIG) != 0 ) return(true); else return(false); @@ -386,11 +387,11 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,ch origaddr[0] = destaddr[0] = CCaddr[0] = 0; - if ( tx.vin.size() < 2 ) + if( tx.vin.size() < 2 ) return eval->Invalid("not enough for CC vins"); - else if ( tx.vin[vini].prevout.n != 0 ) + else if( tx.vin[vini].prevout.n != 0 ) return eval->Invalid("vin1 needs to be buyvin.vout[0]"); - else if ( eval->GetTxUnconfirmed(tx.vin[vini].prevout.hash,vinTx,hashBlock) == 0 ) + else if( eval->GetTxUnconfirmed(tx.vin[vini].prevout.hash, vinTx,hashBlock) == 0 ) { /* int32_t z; for (z=31; z>=0; z--) @@ -399,7 +400,7 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,ch std::cerr << "AssetValidateCCvin cannot load vintx for vin=" << vini << " vintx id=" << tx.vin[vini].prevout.hash.GetHex() << std::endl; return eval->Invalid("always should find CCvin, but didnt"); } - else if ( Getscriptaddress(destaddr, vinTx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 || + else if( Getscriptaddress(destaddr, vinTx.vout[tx.vin[vini].prevout.n].scriptPubKey) == 0 || !GetTokensCCaddress(cp, dualEvalUnspendableAddr, GetUnspendable(cp, NULL)) || strcmp(destaddr, dualEvalUnspendableAddr) != 0 ) { @@ -408,7 +409,7 @@ int64_t AssetValidateCCvin(struct CCcontract_info *cp,Eval* eval,char *CCaddr,ch } //else if ( vinTx.vout[0].nValue < 10000 ) // return eval->Invalid("invalid dust for buyvin"); - else if ( GetAssetorigaddrs(cp,CCaddr,origaddr,vinTx) == 0 ) + else if( GetAssetorigaddrs(cp, CCaddr, origaddr, vinTx) == 0 ) return eval->Invalid("couldnt get origaddr for buyvin"); fprintf(stderr,"AssetValidateCCvin got %.8f to origaddr.(%s)\n",(double)vinTx.vout[tx.vin[vini].prevout.n].nValue/COIN,origaddr); if ( vinTx.vout[0].nValue == 0 ) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 4a5202c44..4efd555b7 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -334,6 +334,9 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti //'S'.vout.2: vin.2 value to original pubkey [origpubkey] //vout.3: normal output for change (if any) //'S'.vout.n-1: opreturn [EVAL_ASSETS] ['S'] [assetid] [amount of coin still required] [origpubkey] + char dualEvalUnspendableAddr[64]; + GetTokensCCaddress(cpAssets, dualEvalUnspendableAddr, GetUnspendable(cpAssets, NULL)); + if( (assetoshis = AssetValidateSellvin(cpAssets, eval, totalunits, tmporigpubkey, tokensCCaddr, origaddr, tx, assetid)) == 0 ) return(false); else if( numvouts < 3 ) @@ -352,7 +355,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti return eval->Invalid("normal vout1 for fillask"); else if( remaining_price != 0 ) { - if ( ConstrainVout(tx.vout[0], 1, (char *)cpAssets->unspendableCCaddr, 0) == 0 ) + if ( ConstrainVout(tx.vout[0], 1, dualEvalUnspendableAddr /*(char *)cpAssets->unspendableCCaddr*/, 0) == 0 ) return eval->Invalid("mismatched vout0 assets unspendable CCaddr for fill sell"); } }