Can anyone explain this pseudocode to find a returning address?

Can anyone explain this pseudocode to find a returning address?

I was reading a popular answer which explains how to find the address of the person who sent a transaction and the pseudocode in that answer does not make much sense to me.

txid = <relevant transaction id>
addresses = []
raw_tx = decoderawtransaction(getrawtransaction(txid))
for(input in raw_tx['vin']) {
  input_raw_tx = decoderawtransaction(getrawtransaction(input['txid']))
  addresses.push(input_raw_tx['vout'][input['vout']]['scriptPubKey']['addresses'][0])
}

Here is the part which I understood. A wallet which created txid can use many inputs from different addresses to send that amount of money. This is why we iterate over input in raw_tx['vin'] and create a list of addresses addresses = [].

Here is a part which is unclear for me:

input_raw_tx['vout'][input['vout']]['scriptPubKey']['addresses'][0]

input_raw_tx['vout'] returns the list. So input['vout'] should return the index of that list. But it also returns a list. Can anyone explain what is going on?

Also that answer was written in old 2013. Has anything changed in these 4 years and is there an easier way to find the returning address as of the beginning of 2918?

http://ift.tt/2C9UnLP

Comments

Popular posts from this blog

bitcoin node: what is the difference between simnet and regtest?

How to check if Electrum is masking my IP with the Tor proxy?

How generic miner connects to bitcoin or ethereum network and does it needs to store entire blockchain?