user4596: Context
I was looking for a simple way to get exact TxOut on on-chain code to validate if funds are to be unlocked to correct wallet address. While looking in plutus haddoc I have found this function:
{-# INLINABLE findOwnInput #-}
-- | Find the input currently being validated.
findOwnInput :: ScriptContext -> Maybe TxInInfo
findOwnInput ScriptContext{scriptContextTxInfo=TxInfo{txInfoInputs}, scriptContextPurpose=Spending txOutRef} =
    find (\TxInInfo{txInInfoOutRef} -> txInInfoOutRef == txOutRef) txInfoInputs
findOwnInput _ = Nothing

This function returns:
-- | An input of a pending transaction.
data TxInInfo = TxInInfo
    { txInInfoOutRef   :: TxOutRef
    , txInInfoResolved :: TxOut
    } deriving stock (Generic, Haskell.Show, Haskell.Eq)

And here is where most of my confusion comes from - getOwnInput returns TxInInfo which has TxOut. All I see is TxIn is TxOut.
This makes it really unclear to me exactly which part of locking or unlocking transaction UTXO getOwnInput function returns.
Lets say that I have 10 Ada in wallet A and I'm creating locking transaction TX1 of 2 Ada to SC1. The way I see it TX1 should look like this:

UTXO1 of 10 ADA is created by taking all the funds from wallet A.
UTXO2 of 10 ADA - 2 ADA - fees1 is created and is sent back to wallet A.
UTXO3 of 2 ADA is created and sent to SC1.

Lets say that now I'm trying to unlock 2 ADA from SC1 back to wallet A by creating TX2:

UTXO4 10 ADA - 2 ADA - fees1 are taken from wallet A to pay for fees2
UTXO5 2 ADA is being taken from SC1
UTXO6 2 ADA are sent to wallet A
UTXO7 10 ADA - 2 ADA - fees1 - fees2 are sent back to wallet A


Main question
So my main question is. Which of these UTXOs does the function getOwnInput return as a txInInfoResolved when TX2 is created?
Bonus question
When TX2 is created, from Plutus validator point of view, which of UTXOs are TxOut and which are TxIn?

user2537: Calling findOwnInput in a validator returns the value contained in the Script-UTxO that is currently being validated. In your example above it is the one with 2 Ada in it.
Your example above is, however, not correctly formulated: UTXO4 is in fact UTXO2 and UTXO5 is UTXO3, also UTXO7 and UTXO4 are not necessary.

4596: <h1>Context</h1>
<p>I was looking for a simple way to get exact <code>TxOut</code> on on-chain code to validate if funds are to be unlocked to correct wallet address. While looking in plutus haddoc I have found this function:</p>
<pre><code>{-# INLINABLE findOwnInput #-}
-- | Find the input currently being validated.
findOwnInput :: ScriptContext -&gt; Maybe TxInInfo
findOwnInput ScriptContext{scriptContextTxInfo=TxInfo{txInfoInputs}, scriptContextPurpose=Spending txOutRef} =
    find (\TxInInfo{txInInfoOutRef} -&gt; txInInfoOutRef == txOutRef) txInfoInputs
findOwnInput _ = Nothing
</code></pre>
<p>This function returns:</p>
<pre><code>-- | An input of a pending transaction.
data TxInInfo = TxInInfo
    { txInInfoOutRef   :: TxOutRef
    , txInInfoResolved :: TxOut
    } deriving stock (Generic, Haskell.Show, Haskell.Eq)
</code></pre>
<p>And here is where most of my confusion comes from - <code>getOwnInput</code> returns <code>TxInInfo</code> which has <code>TxOut</code>. All I see is <code>TxIn</code> is <code>TxOut</code>.
This makes it really unclear to me exactly which part of <strong>locking</strong> or <strong>unlocking</strong> transaction <em>UTXO</em> <code>getOwnInput</code> function returns.</p>
<p>Lets say that I have <code>10 Ada</code> in <code>wallet A</code> and I'm creating locking transaction <code>TX1</code> of <code>2 Ada</code> to <code>SC1</code>. The way I see it <code>TX1</code> should look like this:</p>
<ol>
<li><strong>UTXO1</strong> of <code>10 ADA</code> is created by taking all the funds from <code>wallet A</code>.</li>
<li><strong>UTXO2</strong> of <code>10 ADA - 2 ADA - fees1</code> is created and is sent back to <code>wallet A</code>.</li>
<li><strong>UTXO3</strong> of <code>2 ADA</code> is created and sent to <code>SC1</code>.</li>
</ol>
<p>Lets say that now I'm trying to unlock <code>2 ADA</code> from <code>SC1</code> back to <code>wallet A</code> by creating <code>TX2</code>:</p>
<ol>
<li><strong>UTXO4</strong> <code>10 ADA - 2 ADA - fees1</code> are taken from <code>wallet A</code> to pay for <code>fees2</code></li>
<li><strong>UTXO5</strong> <code>2 ADA</code> is being taken from <code>SC1</code></li>
<li><strong>UTXO6</strong> <code>2 ADA</code> are sent to <code>wallet A</code></li>
<li><strong>UTXO7</strong> <code>10 ADA - 2 ADA - fees1 - fees2</code> are sent back to <code>wallet A</code></li>
</ol>
<hr />
<h1>Main question</h1>
<p>So my main question is. Which of these <strong>UTXO</strong>s does the function <code>getOwnInput</code> return as a <code>txInInfoResolved</code> when <code>TX2</code> is created?</p>
<h3>Bonus question</h3>
<p>When <code>TX2</code> is created, from Plutus validator point of view, which of <strong>UTXO</strong>s are <code>TxOut</code> and which are <code>TxIn</code>?</p>
 2537: <p>Calling <code>findOwnInput</code> in a validator returns the value contained in the Script-UTxO that is currently being validated. In your example above it is the one with 2 Ada in it.</p>
<p>Your example above is, however, not correctly formulated: UTXO4 is in fact UTXO2 and UTXO5 is UTXO3, also UTXO7 and UTXO4 are not necessary.</p>
