This commit is contained in:
jl777
2018-07-22 11:56:10 -11:00
parent 5a06f2ff60
commit 21f17b8816
3 changed files with 45 additions and 5 deletions

View File

@@ -327,15 +327,20 @@ bool ProcessAssets(Eval* eval, std::vector<uint8_t> 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");

View File

@@ -87,8 +87,10 @@ bool Eval::GetSpendsConfirmed(uint256 hash, std::vector<CTransaction> &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);
}

View File

@@ -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)
{