<p>As of right now there's only two green addresses, MtGox and Instawallet. A simple string comparison would suffice. In the near future a dictionary would be the way to go and after that there'll most likely be a service that offers a "green address check".</p>

<p>TL;DR: Code is trivial right now. Proven code will come when it's needed but will also be fairly trivial.</p>

CC BY-SA 3.0
2012-01-21T22:56:03.170Z
2012-01-21T22:56:03.170Z
Lodewijk
<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">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>

<p>Once you have the list of sending addresses stored in the <code>addresses</code> array, you can compare these addresses to a list of pre-approved green addresses. In most cases, you should expect there to only be a single unique address in the <code>addresses</code> array.</p>

<p>In order to get a list of suitable green addresses, you could hard-code it into your application, or you could use a dynamic source, such as <a href="https://deepbit.net/green.json">Deepbit's JSON feed</a>. This feed however, is notably missing <a href="https://blockchain.info/address/1LNWw6yCxkUmkhArb2Nf2MPw6vG7u5WG7q">Mt. Gox's Green Address</a></p>

CC BY-SA 3.0
2013-01-03T20:10:48.690Z
2013-01-03T20:10:48.690Z
Stephen McCarthy
<p>Does any proven third party code exist for this? </p>

<p>Edit* </p>

<p>To be more specific, what I haven't been able to find out is how to get the sender's bitcoin address when receiving a transaction. As far as I know, bitcoind doesn't have a command that shows the prev_out hash.</p>

<bitcoind><json-rpc><green-address>
What's the best way for a website to detect payments from green addresses?
Amin
# What's the best way for a website to detect payments from green addresses?

(Asked by: username_0 on 2012-01-21)

Does any proven third party code exist for this?

Edit\*

To be more specific, what I haven't been able to find out is how to get the sender's bitcoin address when receiving a transaction. As far as I know, bitcoind doesn't have a command that shows the prev\_out hash.

**Tags:** bitcoind, json-rpc, green-address


---

## 2 answers

### Answer by username_2 on 2013-01-03. Score: 8 | Accepted answer

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])
}

Once you have the list of sending addresses stored in the addresses array, you can compare these addresses to a list of pre-approved green addresses. In most cases, you should expect there to only be a single unique address in the addresses array.
In order to get a list of suitable green addresses, you could hard-code it into your application, or you could use a dynamic source, such as Deepbit's JSON feed. This feed however, is notably missing Mt. Gox's Green Address


---

### Answer by username_1 on 2012-01-21. Score: 2

As of right now there's only two green addresses, MtGox and Instawallet. A simple string comparison would suffice. In the near future a dictionary would be the way to go and after that there'll most likely be a service that offers a "green address check".

TL;DR: Code is trivial right now. Proven code will come when it's needed but will also be fairly trivial.


---

