diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 05bdcad8e..059e0939c 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -327,15 +327,20 @@ bool ProcessAssets(Eval* eval, std::vector paramsNull,const CTransactio txid = ctx.GetHash(); if ( txid == prevtxid ) return(true); - { fprintf(stderr,"ProcessAssets\n"); + { + fprintf(stderr,"ProcessAssets\n"); if ( paramsNull.size() != 0 ) // Don't expect params return eval->Invalid("Cannot have params"); - else if ( (n= ctx.vout.size()) == 0 ) + fprintf(stderr,"ProcessAssets2\n"); + if ( (n= ctx.vout.size()) == 0 ) return eval->Invalid("no-vouts"); - else if ( (funcid= DecodeAssetOpRet(ctx.vout[n-1].scriptPubKey,assetid,assetid2,amount,origpubkey)) == 0 ) + fprintf(stderr,"ProcessAssets3\n"); + if ( (funcid= DecodeAssetOpRet(ctx.vout[n-1].scriptPubKey,assetid,assetid2,amount,origpubkey)) == 0 ) return eval->Invalid("Invalid opreturn payload"); + fprintf(stderr,"ProcessAssets4\n"); if ( eval->GetTxUnconfirmed(assetid,createTx,hashBlock) == 0 ) return eval->Invalid("cant find asset create txid"); + fprintf(stderr,"ProcessAssets5\n"); if ( assetid2 != zero && eval->GetTxUnconfirmed(assetid2,createTx,hashBlock) == 0 ) return eval->Invalid("cant find asset2 create txid"); fprintf(stderr,"AssetValidate skipped\n"); diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index 2f77ced1a..60d87361f 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -87,8 +87,10 @@ bool Eval::GetSpendsConfirmed(uint256 hash, std::vector &spends) c bool Eval::GetTxUnconfirmed(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock) const { - bool fAllowSlow = false; // Don't allow slow - return GetTransaction(hash, txOut, hashBlock, fAllowSlow); + bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock); + //bool fAllowSlow = false; // Don't allow slow + //return GetTransaction(hash, txOut, hashBlock, fAllowSlow); + return myGetTransaction(hash, txOut,hashBlock); } diff --git a/src/main.cpp b/src/main.cpp index 6f3a19822..9be55a845 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1603,6 +1603,39 @@ bool GetAddressUnspent(uint160 addressHash, int type, return true; } +bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock) +{ + fprintf(stderr,"check mempool\n"); + if (mempool.lookup(hash, txOut)) + { + fprintf(stderr,"found in mempool\n"); + return true; + } + fprintf(stderr,"check disk\n"); + + if (fTxIndex) { + CDiskTxPos postx; + if (pblocktree->ReadTxIndex(hash, postx)) { + CAutoFile file(OpenBlockFile(postx, true), SER_DISK, CLIENT_VERSION); + if (file.IsNull()) + return error("%s: OpenBlockFile failed", __func__); + CBlockHeader header; + try { + file >> header; + fseek(file.Get(), postx.nTxOffset, SEEK_CUR); + file >> txOut; + } catch (const std::exception& e) { + return error("%s: Deserialize or I/O error - %s", __func__, e.what()); + } + hashBlock = header.GetHash(); + if (txOut.GetHash() != hash) + return error("%s: txid mismatch", __func__); + return true; + } + } + return false; +} + /** Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock */ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow) {