Raw-Transaction

如何辨識哪個輸出用作新交易的輸入

  • June 13, 2016

我想找出交易中將使用哪個地址的硬幣。

我有txid一筆交易。在vin我看到txid輸入交易的,但我怎麼知道這個交易的哪個輸出被使用了?

我正在使用rpcphp.

這是我想知道硬幣來自哪個地址的交易:

   "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
}

本次交易引用於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
}

有兩個vout,我不知道如何找到哪個是正確的。

Avin包含 atxid和 a vout。正如您正確辨識的那樣,該txid部分是包含用於此輸入的未使用交易輸出(UTXO) 的交易。vout部分是一個從零開始的索引,正在使用交易的輸出。

例如,如果vout為 0,則此輸入指向交易的第一個輸出。如果vout為 3,則指向第四個輸出。將結構的這些部分vin視為區塊鏈上特定 UTXO 的地址。

引用自:https://bitcoin.stackexchange.com/questions/44377