How to recognize which output is used as input for a new transaction

2

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.

Petr Kamen Spinar

Posted 2016-05-26T08:19:43.467

Reputation: 23

f**k kick me between my eyes... vout : 0 is what i find :DPetr Kamen Spinar 2016-05-26T08:35:35.657

Answers

0

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 (UTXO) being used for this input. The vout part is a zero-based index 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.

Jestin

Posted 2016-05-26T08:19:43.467

Reputation: 8 339

thank you ... i found it yet... [vin][0][vout] sending onto [vin][0][txid][vout][0]Petr Kamen Spinar 2016-05-27T14:33:04.057