<p>A <code>vin</code> contains both a <code>txid</code> and a <code>vout</code>.  As you've correctly identified, the <code>txid</code> part is the transaction that contains the <a href="https://bitcoin.org/en/glossary/unspent-transaction-output" rel="nofollow">unspent transaction output</a> (UTXO) being used for this input.  The <code>vout</code> part is a <a href="https://en.wikipedia.org/wiki/Zero-based_numbering" rel="nofollow">zero-based index</a> for which output on the transaction is being used.</p>

<p>For example, if <code>vout</code> is 0, this input points to the first output of the transaction.  If <code>vout</code> is 3, it points to the fourth output.  Think of the these parts of the <code>vin</code> structure as being an address for a particular UTXO on the blockchain.</p>

CC BY-SA 3.0
2016-05-27T14:33:04.057Z
thank you ... i found it yet... [vin][0][vout] sending onto [vin][0][txid][vout][0]
Petr Kamen Spinar
CC BY-SA 3.0
2016-05-26T13:28:58.993Z
2016-05-26T13:28:58.993Z
Jestin
<p>I want to find out which address's coins will be used in a transaction.</p>

<p>I have the <code>txid</code> of a transaction.
In <code>vin</code> I see the <code>txid</code> of the input transaction, but how can I know which output of this transaction is used?</p>

<p>I am using <code>rpc</code> calls called from <code>php</code>.</p>

<p>This is the transaction for which I want to know from which address the coins come:</p>

<pre><code>    "txid" : "6470db622271c3a2910affae11f11d08b278ba790ee13180fbf1b151bd1bb0f5",
    "version" : 1,
    "time" : 1464138669,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "21129d09deaf685e2d95eec49f6481a2d148183f0dbf226942cfbbf698a7cdea",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "304402205626172faba89dc29d97a1f1638a6341387bc39a2444706a7f6ed95b51b1048102204f64e3c967149bf386b05fb10da0d52257d75074e012abb6ec034d1a00ef5a2701 032200b135d5c1301db7d8afa971871ad24d499e7ac0c15cb374a8e950c7b3d4ae",
                "hex" : "47304402205626172faba89dc29d97a1f1638a6341387bc39a2444706a7f6ed95b51b1048102204f64e3c967149bf386b05fb10da0d52257d75074e012abb6ec034d1a00ef5a270121032200b135d5c1301db7d8afa971871ad24d499e7ac0c15cb374a8e950c7b3d4ae"
            },
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 15499.99310000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 ea491757c90b6e83e208b00fcccab53f9aff37b1 OP_EQUALVERIFY OP_CHECKSIG",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "Ad8fKrKKNiFEv2TY5tSFp6WXXvWtGehKFX"
                ]
            }
        },
        {
            "value" : 500.00000000,
            "n" : 1,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 bb265fe2e77350425890fb5ad6abda3e28394e20 OP_EQUALVERIFY OP_CHECKSIG",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "AYqRygUrwzeh371VZffxu5Emo6XZczxiYQ"
                ]
            }
        }
    ],
    "blockhash" : "000008d45d6cb4ad076c7edfac237917f751a94ea01cd1c0d5d9ca5c4d5ab8cd",
    "confirmations" : 277
}
</code></pre>

<p>This transaction is referenced in <code>vin</code>:</p>

<pre><code>{
    "txid" : "21129d09deaf685e2d95eec49f6481a2d148183f0dbf226942cfbbf698a7cdea",
    "version" : 1,
    "time" : 1464138667,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "0b2b23719e83482bf98d0d3770a523a2c730ea75104a53dd5fa704f0c6d8c6b8",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "3045022100f01c5764fdfbc2e845f87d7e7ed4675027bea854278764d39ce6592f048eeeeb02200fb7d0e2f95720237659d464cfd314881995235222754734792fd14f1cde797301 02e02c24b096413d31648eae4f41e78294c78390a0499e151530d1d388d1edb1a2",
                "hex" : "483045022100f01c5764fdfbc2e845f87d7e7ed4675027bea854278764d39ce6592f048eeeeb02200fb7d0e2f95720237659d464cfd314881995235222754734792fd14f1cde7973012102e02c24b096413d31648eae4f41e78294c78390a0499e151530d1d388d1edb1a2"
            },
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 15999.99320000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 6e43b6760addf0a08af83cf1f3fac7e81d404f2a OP_EQUALVERIFY OP_CHECKSIG",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "ARpu6N2Bf24JmmRy2gbZfPr8xJqdHbvimY"
                ]
            }
        },
        {
            "value" : 500.00000000,
            "n" : 1,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 bb265fe2e77350425890fb5ad6abda3e28394e20 OP_EQUALVERIFY OP_CHECKSIG",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "AYqRygUrwzeh371VZffxu5Emo6XZczxiYQ"
                ]
            }
        }
    ],
    "blockhash" : "000008d45d6cb4ad076c7edfac237917f751a94ea01cd1c0d5d9ca5c4d5ab8cd",
    "confirmations" : 277
}
</code></pre>

<p>There are two <code>vout</code> and I don't know how to find which one is right.</p>

CC BY-SA 3.0
2016-05-26T08:35:35.657Z
f**k kick me between my eyes... vout : 0 is what i find :D
Petr Kamen Spinar
<raw-transaction><transaction-input>
How to recognize which output is used as input for a new transaction
Petr Kamen Spinar
# How to recognize which output is used as input for a new transaction

(Asked by: username_0 on 2016-05-26)

I want to find out which address's coins will be used in a transaction.
I have the txid of a transaction.
In vin I see the txid of the input transaction, but how can I know which output of this transaction is used?
I am using rpc calls called from php.
This is the transaction for which I want to know from which address the coins come:
    "txid" : "6470db622271c3a2910affae11f11d08b278ba790ee13180fbf1b151bd1bb0f5",
    "version" : 1,
    "time" : 1464138669,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "21129d09deaf685e2d95eec49f6481a2d148183f0dbf226942cfbbf698a7cdea",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "304402205626172faba89dc29d97a1f1638a6341387bc39a2444706a7f6ed95b51b1048102204f64e3c967149bf386b05fb10da0d52257d75074e012abb6ec034d1a00ef5a2701 032200b135d5c1301db7d8afa971871ad24d499e7ac0c15cb374a8e950c7b3d4ae",
                "hex" : "47304402205626172faba89dc29d97a1f1638a6341387bc39a2444706a7f6ed95b51b1048102204f64e3c967149bf386b05fb10da0d52257d75074e012abb6ec034d1a00ef5a270121032200b135d5c1301db7d8afa971871ad24d499e7ac0c15cb374a8e950c7b3d4ae"
            },
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 15499.99310000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 ea491757c90b6e83e208b00fcccab53f9aff37b1 OP_EQUALVERIFY OP_CHECKSIG",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "Ad8fKrKKNiFEv2TY5tSFp6WXXvWtGehKFX"
                ]
            }
        },
        {
            "value" : 500.00000000,
            "n" : 1,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 bb265fe2e77350425890fb5ad6abda3e28394e20 OP_EQUALVERIFY OP_CHECKSIG",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "AYqRygUrwzeh371VZffxu5Emo6XZczxiYQ"
                ]
            }
        }
    ],
    "blockhash" : "000008d45d6cb4ad076c7edfac237917f751a94ea01cd1c0d5d9ca5c4d5ab8cd",
    "confirmations" : 277
}

This transaction is referenced in vin:
{
    "txid" : "21129d09deaf685e2d95eec49f6481a2d148183f0dbf226942cfbbf698a7cdea",
    "version" : 1,
    "time" : 1464138667,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "0b2b23719e83482bf98d0d3770a523a2c730ea75104a53dd5fa704f0c6d8c6b8",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "3045022100f01c5764fdfbc2e845f87d7e7ed4675027bea854278764d39ce6592f048eeeeb02200fb7d0e2f95720237659d464cfd314881995235222754734792fd14f1cde797301 02e02c24b096413d31648eae4f41e78294c78390a0499e151530d1d388d1edb1a2",
                "hex" : "483045022100f01c5764fdfbc2e845f87d7e7ed4675027bea854278764d39ce6592f048eeeeb02200fb7d0e2f95720237659d464cfd314881995235222754734792fd14f1cde7973012102e02c24b096413d31648eae4f41e78294c78390a0499e151530d1d388d1edb1a2"
            },
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 15999.99320000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 6e43b6760addf0a08af83cf1f3fac7e81d404f2a OP_EQUALVERIFY OP_CHECKSIG",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "ARpu6N2Bf24JmmRy2gbZfPr8xJqdHbvimY"
                ]
            }
        },
        {
            "value" : 500.00000000,
            "n" : 1,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 bb265fe2e77350425890fb5ad6abda3e28394e20 OP_EQUALVERIFY OP_CHECKSIG",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "AYqRygUrwzeh371VZffxu5Emo6XZczxiYQ"
                ]
            }
        }
    ],
    "blockhash" : "000008d45d6cb4ad076c7edfac237917f751a94ea01cd1c0d5d9ca5c4d5ab8cd",
    "confirmations" : 277
}

There are two vout and I don't know how to find which one is right.

**Tags:** raw-transaction, transaction-input

> **Comments:**
> **username_0**: f**k kick me between my eyes... vout : 0 is what i find :D  

---

## 1 answers

### Answer by username_1 on 2016-05-26. Score: 0 | Accepted answer

A `vin` contains both a `txid` and a `vout`. As you've correctly identified, the `txid` part is the transaction that contains the [unspent transaction output](https://bitcoin.org/en/glossary/unspent-transaction-output) (UTXO) being used for this input. The `vout` part is a [zero-based index](https://en.wikipedia.org/wiki/Zero-based_numbering) for which output on the transaction is being used.

For example, if `vout` is 0, this input points to the first output of the transaction. If `vout` is 3, it points to the fourth output. Think of the these parts of the `vin` structure as being an address for a particular UTXO on the blockchain.

> **Comments:**
> **username_0**: thank you ... i found it yet... [vin][0][vout] sending onto [vin][0][txid][vout][0]  

---

