From 1f9a4106c5301fe4b4d23b32982fc55e0933a554 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 2 Aug 2018 00:04:29 -1100 Subject: [PATCH] myGettxout --- src/cc/CCinclude.h | 1 + src/cc/CCtx.cpp | 3 ++- src/main.cpp | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 64987a236..43e10ab22 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -53,6 +53,7 @@ static const uint256 zeroid; bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock); int32_t is_hexstr(char *str,int32_t n); bool myAddtomempool(CTransaction &tx); +uint64_t myGettxout(uint256 hash,int32_t n); // CCcustom CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv); diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index b0fb5e78e..5863197c5 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -220,7 +220,8 @@ uint64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,uint64_t total,in break; if ( j != mtx.vin.size() ) continue; - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.IsCoinBase() == 0 ) + if ( myGettxout(txid,vout) == out.tx->vout[out.i].nValue ) + //if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.IsCoinBase() == 0 ) { mtx.vin.push_back(CTxIn(txid,vout,CScript())); nValue = out.tx->vout[out.i].nValue; diff --git a/src/main.cpp b/src/main.cpp index 2ec680009..d604b4eec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1603,6 +1603,19 @@ bool GetAddressUnspent(uint160 addressHash, int type, return true; } +uint64_t myGettxout(uint256 hash,int32_t n) +{ + CCoins coins; + LOCK(cs_main); + LOCK(mempool.cs); + CCoinsViewMemPool view(pcoinsTip, mempool); + if (!view.GetCoins(hash, coins)) + return(0); + if ( n<0 || (unsigned int)n>=coins.vout.size() || coins.vout[n].IsNull() ) + return(0); + else return(coins.vout[n].nValue); +} + bool myAddtomempool(CTransaction &tx) { CValidationState state; CTransaction Ltx; bool fMissingInputs,fOverrideFees = false;