diff --git a/src/main.cpp b/src/main.cpp index aeacbbe4f..62cfb7bb0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1292,9 +1292,32 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock return false; } - - - +char *komodo_getspendscript(uint256 hash,int32_t n) +{ + CTransaction tx; uint256 hashBlock; CBlockIndex *pindexSlow = NULL; int nHeight = -1; + CBlock block; CCoinsViewCache &view = *pcoinsTip; + const CCoins* coins = view.AccessCoins(hash); + if ( coins ) + nHeight = coins->nHeight; + if ( nHeight > 0 ) + pindexSlow = chainActive[nHeight]; + if ( pindexSlow != 0 ) + { + if ( ReadBlockFromDisk(block,pindexSlow,0) ) + { + BOOST_FOREACH(const CTransaction &tx,block.vtx) + { + if ( tx.GetHash() == hash ) + { + if ( n >= 0 && n < tx.vout.size() ) + return((char *)tx.vout[n].scriptPubKey.ToString().c_str()); + else printf("getspendscript illegal n.%d\n",n); + } + } + } + } + return(0); +} ////////////////////////////////////////////////////////////////////////////// diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 012bfbf65..2a767616d 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -240,18 +240,6 @@ Value getrawtransaction(const Array& params, bool fHelp) return result; } -char *komodo_getspendscript(uint256 hash,int32_t n) -{ - CTransaction tx; uint256 hashBlock; - LOCK(cs_main); - if ( GetTransaction(hash,tx,hashBlock,true) != 0 ) - { - if ( n >= 0 && n < tx.vout.size() ) - return((char *)tx.vout[n].scriptPubKey.ToString().c_str()); - } else printf("null GetTransaction\n"); - return(0); -} - Value gettxoutproof(const Array& params, bool fHelp) { if (fHelp || (params.size() != 1 && params.size() != 2))