<p>I just answered <a href="https://bitcoin.stackexchange.com/questions/2667/whats-the-best-way-for-a-website-to-detect-payments-from-green-addresses/5981#5981">a similar question</a>. The relevant parts are:</p>

<p>It is now possible to determine the list of addresses that sent a transaction using the raw transaction <a href="https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list" rel="nofollow noreferrer">JSON-RPC API</a> calls that were released with bitcoind and bitcoin-qt version 0.7. The pseudo-code to accomplish this is:</p>

<pre><code>txid = &lt;relevant transaction id&gt;
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])
}
</code></pre>

CC BY-SA 3.0
2013-06-03T03:44:12.007Z
Trying to find out the same thing, your  "decoderawtransaction(getrawtransaction(input['txid']))" instruction failed at first. However, the problem fixed itself and your example worked after I waited for raw_tx['confirmation'] and raw_tx['blockhash'] to be defined.
adamrmcd
CC BY-SA 3.0
2014-03-25T02:17:31.737Z
this basically scans through the blockchain for the output transaction corresponding to the hash value in the later input-transaction. is there not a way of getting the answer using the input scriptsig though?
mulllhausen
CC BY-SA 3.0
2017-12-29T08:37:14.980Z
Asked a [question](https://bitcoin.stackexchange.com/q/66900/1891) related to your pseudocode. Would appreciate if you can take a look.
Salvador Dali
CC BY-SA 4.0
2022-03-04T01:03:12.167Z
Note that if your wallet did not sent the previous transaction, you will need to [enable `txindex=1`](https://bitcoin.stackexchange.com/questions/35707/what-are-pros-and-cons-of-txindex-option) in bitcoin.conf to track non-wallet transactions. Otherwise, the call to `getrawtransaction` will fail
Ron
CC BY-SA 3.0
2013-01-03T20:13:39.660Z
2013-01-03T20:13:39.660Z
2017-04-13T12:47:33.743Z
Stephen McCarthy
<p>The Bitcoin.org client doesn't provide this.</p>

<p>I believe your options are:</p>

<ul>
<li>Armory</li>
<li>libbitcoin</li>
<li>ABE blockchain explorer</li>
<li>BitcoinJ <a href="http://code.google.com/p/bitcoinj" rel="nofollow">http://code.google.com/p/bitcoinj</a></li>
</ul>

CC BY-SA 3.0
2012-06-05T10:11:44.143Z
i thought about using ABE but i were told uses about 1,4GB of ram, which is just to much for my "small" vps with 2GB of ram in total. Are the other more "lightweight" ?
Frederick Behrends
CC BY-SA 3.0
2012-06-05T09:44:07.517Z
2012-06-05T09:44:07.517Z
Stephen Gornick
<p>How do I find out which addresses are the inputs of a given transaction, given its transaction ID?
I know there is a way, as satoshidice.com uses this.
I would like to do this with own software and not rely on some third party provider, which could easily kill their service.</p>

<p>EDIT:</p>

<p>Basically I'm creating a PHP project, where I need to find out when a new transaction arrives and which address sent it. So I need a way to get a notification or start a PHP script (called with needed variables [txid, sender address, receiving address, value]) when a new transaction arrives.</p>

CC BY-SA 3.0
2012-06-05T10:41:18.413Z
I edited your question to tidy up the grammar and spelling, but also fixed the assumption that there is a single "sender" address.  It's quite possible that the transaction has multiple inputs and multiple outputs, so there's no single "sender".  SatoshiDICE doesn't care; it just sends the winnings to one of the sending addresses.
Chris Moore
<bitcoind>
How to findout the sender of a transaction
Frederick Behrends
# How to findout the sender of a transaction

(Asked by: username_0 on 2012-06-05)

How do I find out which addresses are the inputs of a given transaction, given its transaction ID?
I know there is a way, as satoshidice.com uses this.
I would like to do this with own software and not rely on some third party provider, which could easily kill their service.

EDIT:

Basically I'm creating a PHP project, where I need to find out when a new transaction arrives and which address sent it. So I need a way to get a notification or start a PHP script (called with needed variables [txid, sender address, receiving address, value]) when a new transaction arrives.

**Tags:** bitcoind

> **Comments:**
> **username_1**: I edited your question to tidy up the grammar and spelling, but also fixed the assumption that there is a single "sender" address.  It's quite possible that the transaction has multiple inputs and multiple outputs, so there's no single "sender".  SatoshiDICE doesn't care; it just sends the winnings to one of the sending addresses.  

---

## 2 answers

### Answer by username_2 on 2013-01-03. Score: 10

I just answered a similar question. The relevant parts are:
It is now possible to determine the list of addresses that sent a transaction using the raw transaction JSON-RPC API calls that were released with bitcoind and bitcoin-qt version 0.7. The pseudo-code to accomplish this is:
txid = 
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])
}

> **Comments:**
> **username_3**: Trying to find out the same thing, your  "decoderawtransaction(getrawtransaction(input['txid']))" instruction failed at first. However, the problem fixed itself and your example worked after I waited for raw_tx['confirmation'] and raw_tx['blockhash'] to be defined.  
> **username_4**: this basically scans through the blockchain for the output transaction corresponding to the hash value in the later input-transaction. is there not a way of getting the answer using the input scriptsig though?  
> **username_5**: Asked a [question](https://bitcoin.stackexchange.com/q/66900/1891) related to your pseudocode. Would appreciate if you can take a look.  
> **username_6**: Note that if your wallet did not sent the previous transaction, you will need to [enable `txindex=1`](https://bitcoin.stackexchange.com/questions/35707/what-are-pros-and-cons-of-txindex-option) in bitcoin.conf to track non-wallet transactions. Otherwise, the call to `getrawtransaction` will fail  

---

### Answer by username_7 on 2012-06-05. Score: 2

The Bitcoin.org client doesn't provide this.

I believe your options are:

* Armory
* libbitcoin
* ABE blockchain explorer
* BitcoinJ <http://code.google.com/p/bitcoinj>

> **Comments:**
> **username_0**: i thought about using ABE but i were told uses about 1,4GB of ram, which is just to much for my "small" vps with 2GB of ram in total. Are the other more "lightweight" ?  

---

