Reading this thread about determining the sending address of a bitcoin transaction. I'm a bit confused, how do you differentiate between the change address and the "receiving" address of the last transaction?
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])
}
Would addresses not include other outputs that are unrelated to the sending address? I'm trying to build a block explorer and I'm uncertain how to determine which address sent coins in each transaction. Is it possible to tell?