find a CTransaction from a prevout in Bitcoin source code I'm trying to come up with this function: CTransaction getTxFromPrevout(COutPoint prevo);

The idea being... when a new transaction is about to be validated, it will go through all of it's tx.vin[i].prevout and check for them funds (utxo).

So I want to find and identify the CTransaction tx such that tx.vout (of type vector&lt;CTxOut&gt; ) has any i element such that it's CScript is a normal payment (tx.vout[i].scriptPubKey.IsNormalPayment() == true) and the tx.vout[i].scriptPubKey has within it a match for the prevo

If I use a web based explorer I can take the prevo and extract the hash from it, then search the web for the tx... but that doesn't help me, since I want to be able to use this within the code itself, adding this new function. I tried following the code on an explorer and it uses the rpc api, and it was not easy to follow.

What I'm thinking is that there should be a utxo database structure or class that will make this easier to crawl through. If I suppose there is such a class named UTxODatabase - that I know there isn't, but just imagine there is - then the function I need to code would look like this:

CTransaction UTxODatabase::getTxFromPrevout(COutPoint prevo);

/*************************************************/

EDIT 1:
I put this at the very end of the CheckTransaction() function, in main.cpp

BOOST_FOREACH (const CTxIn&amp; txin, tx.vin){
        std::cout &lt;&lt; "txin.prevPubKey.ToString(): " &lt;&lt; txin.prevPubKey.ToString() &lt;&lt; std::endl;

Then I've ran the wallet and the output shown for each txin was just: txin.prevPubKey.ToString:, without any prevPubKey data.
I am really confused about this.

My thinking was that if I'm able to get those prevPubKeys from the CTxIn, then I'll be able to track the utxo. But why would there be no information on that member of the txin at that stage?
I think what you want is to use this function:

bool CCoinsViewMemPool::GetCoin(const COutPoint &amp;outpoint, Coin &amp;coin) const

You can find the definition here: https://github.com/bitcoin/bitcoin/blob/v0.17.0.1/src/txmempool.cpp#L885

It will set the Coin object you pass as an argument. For an example of usage, see bool CheckSequenceLocks(const CTransaction &amp;tx, int flags, LockPoints* lp, bool useExistingLockPoints) in https://github.com/bitcoin/bitcoin/blob/v0.17.0.1/src/validation.cpp#L364

This is supposed to "provide access to all Coins which are either unspent in the
 * base CCoinsView, or are outputs from any mempool transaction".