<p>As the above poster mentioned, refunding to an input address can be unreliable due to shared wallets.</p>

<p>The merchant protocol (BIP 70) <a href="https://en.bitcoin.it/wiki/BIP_0070" rel="nofollow">https://en.bitcoin.it/wiki/BIP_0070</a> offers a good solution to this long term, but it is still gaining adoption, and not widely used yet.</p>

<p>The solution we proposed to Overstock.com and other merchants at Coinbase was to send the refund to an email address (merchant's typically have these on file for the customer, who is signed in at checkout).  This delivers their refund to a Coinbase account (via email), which is either their actual Coinbase account, or at an address where they can sign in to claim it.  They can then move the funds anywhere they'd like.</p>

<p>While not perfect, this has been the best solution we've seen merchants adopt to date for refunds.</p>

CC BY-SA 3.0
2014-03-25T06:45:38.680Z
2014-03-25T06:45:38.680Z
Brian Armstrong
<p>So called "block chain based refund" is not reliable with bitcoin.</p>

<p>The sending wallet may be a shared web wallet (blockchain.info, MtGox, e.g. any web site) and thus you cannot guarantee that any of <a href="https://en.bitcoin.it/wiki/Change" rel="nofollow noreferrer">change addresses</a> in the transaction are controlled by the user. Even by exploring the block chain and knowing from which address the bitcoins arrived and where unspent change went, it is not guaranteed that if you make a refund to any of these addresses the sender receives the payment.</p>

<p>Instead, all refunds must be handled off-band and the refund bitcoin address must be asked separately.</p>

<p>E.g. <a href="http://satoshidice.com" rel="nofollow noreferrer">SatoshiDice</a> includes the following disclaimer (players basically must use a desktop wallet where the wallet software generates a change address and the wallet is not shared with other users):</p>

<pre><code>  IMPORTANT: Only use wallets that allow you to receive Bitcoin from the same address you sent from. If you're not sure, test by sending a bet for the minimum amount. If you get nothing back, then your wallet is not compatible. Note that some bets may require one confirmation before the win/loss value is sent back. 
</code></pre>

<p><a href="https://just-dice.com/#a11" rel="nofollow noreferrer">A just-dice.com FAQ regarding shared web wallet.</a> </p>

<p>In the case you still want to pursuit change-address based refund you might find these links useful</p>

<ul>
<li><p><a href="https://bitcoin.stackexchange.com/a/9152/5464">https://bitcoin.stackexchange.com/a/9152/5464</a></p></li>
<li><p><a href="https://bitcoin.stackexchange.com/a/5982/5464">https://bitcoin.stackexchange.com/a/5982/5464</a></p></li>
<li><p><a href="https://bitcointalk.org/index.php?topic=138752.msg1481892#msg1481892" rel="nofollow noreferrer">https://bitcointalk.org/index.php?topic=138752.msg1481892#msg1481892</a></p></li>
</ul>

<p>Here is some more info (I have written this down some time ago, but I have not verified whether this is still valid):</p>

<p>Your bitcoind must run in a special: Since bitcoind/Bitcoin-qt 0.8, no transaction index is kept anymore by default, as it is not necessary for validation in the new database model. Instead, there is only a database of unspent transaction outputs, which has enough information to (slowly) locate transactions in block files. getrawtransaction uses this, but it only works for transactions that are not yet spent in the block chain. If you want to be able to look up historical transactions, you need to set the txindex=1 configuration option (or start with the -txindex command line flag). As this setting can only be set when the database is created, you'll need to rebuild it from scratch (using -reindex).</p>

CC BY-SA 3.0
2013-12-16T21:00:01.250Z
I know it is unreliable, but just like SatoshiDice, I would include a disclamer.
rrrrrrrrrrrrrrrr
CC BY-SA 3.0
2013-12-16T21:05:42.190Z
Ok, let me edit the question for you
Mikko Ohtamaa
CC BY-SA 3.0
2013-12-16T21:18:45.690Z
I'm new to StackExchange. Would it be ok to answer my own question with a precise solution that I found out by analyzing the information you provided me?
rrrrrrrrrrrrrrrr
CC BY-SA 3.0
2013-12-16T22:17:22.113Z
The last link contains the answer how to do it with API calls (and Python script snippet). However I am reclutant to put it into an answer, as I am not sure if it still works unmodified.
Mikko Ohtamaa
CC BY-SA 3.0
2013-12-16T22:18:01.907Z
@RiccardoBestetti its okay to answer your own question and mark it as correct
CQM
CC BY-SA 3.0
2013-12-16T22:21:31.393Z
Tomorrow I will post my own answer base on the information provided by @MikkoOhtamaa and my own (working) code snippets.
rrrrrrrrrrrrrrrr
CC BY-SA 3.0
2013-12-16T22:24:17.330Z
Added some additional info to the answer.
Mikko Ohtamaa
CC BY-SA 3.0
2013-12-19T20:55:45.627Z
Any luck yet with the scripting?
Mikko Ohtamaa
CC BY-SA 3.0
2013-12-21T10:58:30.797Z
No, I've been really busy in the last days. I'm going to work on it today!
rrrrrrrrrrrrrrrr
CC BY-SA 3.0
2013-12-21T23:32:56.067Z
I'm reindexing.
rrrrrrrrrrrrrrrr
CC BY-SA 3.0
2013-12-16T20:55:25.667Z
2013-12-16T22:24:06.407Z
2017-04-13T12:47:32.940Z
Mikko Ohtamaa
<p>How do I send Bitcoins back to the person that sent me them without asking that person for a address without querying a block explorer?</p>

<p>I already know that (given that the person has his own wallet and doesn't use a shared wallet service) I can look up the transaction with its txid on a block explorer and just use one of the source addresses, but can I do it without needing a block explorer, directly with bitcoind API calls?</p>

<transactions>
Send Bitcoins back where they came from
rrrrrrrrrrrrrrrr
# Send Bitcoins back where they came from

(Asked by: username_0 on 2013-12-16)

How do I send Bitcoins back to the person that sent me them without asking that person for a address without querying a block explorer?

I already know that (given that the person has his own wallet and doesn't use a shared wallet service) I can look up the transaction with its txid on a block explorer and just use one of the source addresses, but can I do it without needing a block explorer, directly with bitcoind API calls?

**Tags:** transactions


---

## 2 answers

### Answer by username_2 on 2013-12-16. Score: 5 | Accepted answer

So called "block chain based refund" is not reliable with bitcoin.
The sending wallet may be a shared web wallet (blockchain.info, MtGox, e.g. any web site) and thus you cannot guarantee that any of change addresses in the transaction are controlled by the user. Even by exploring the block chain and knowing from which address the bitcoins arrived and where unspent change went, it is not guaranteed that if you make a refund to any of these addresses the sender receives the payment.
Instead, all refunds must be handled off-band and the refund bitcoin address must be asked separately.
E.g. SatoshiDice includes the following disclaimer (players basically must use a desktop wallet where the wallet software generates a change address and the wallet is not shared with other users):
  IMPORTANT: Only use wallets that allow you to receive Bitcoin from the same address you sent from. If you're not sure, test by sending a bet for the minimum amount. If you get nothing back, then your wallet is not compatible. Note that some bets may require one confirmation before the win/loss value is sent back. 

A just-dice.com FAQ regarding shared web wallet. 
In the case you still want to pursuit change-address based refund you might find these links useful

https://bitcoin.stackexchange.com/a/9152/5464
https://bitcoin.stackexchange.com/a/5982/5464
https://bitcointalk.org/index.php?topic=138752.msg1481892#msg1481892

Here is some more info (I have written this down some time ago, but I have not verified whether this is still valid):
Your bitcoind must run in a special: Since bitcoind/Bitcoin-qt 0.8, no transaction index is kept anymore by default, as it is not necessary for validation in the new database model. Instead, there is only a database of unspent transaction outputs, which has enough information to (slowly) locate transactions in block files. getrawtransaction uses this, but it only works for transactions that are not yet spent in the block chain. If you want to be able to look up historical transactions, you need to set the txindex=1 configuration option (or start with the -txindex command line flag). As this setting can only be set when the database is created, you'll need to rebuild it from scratch (using -reindex).

> **Comments:**
> **username_0**: I know it is unreliable, but just like SatoshiDice, I would include a disclamer.  
> **username_2**: Ok, let me edit the question for you  
> **username_0**: I'm new to StackExchange. Would it be ok to answer my own question with a precise solution that I found out by analyzing the information you provided me?  
> **username_2**: The last link contains the answer how to do it with API calls (and Python script snippet). However I am reclutant to put it into an answer, as I am not sure if it still works unmodified.  
> **username_3**: @RiccardoBestetti its okay to answer your own question and mark it as correct  
> **username_0**: Tomorrow I will post my own answer base on the information provided by @MikkoOhtamaa and my own (working) code snippets.  
> **username_2**: Added some additional info to the answer.  
> **username_2**: Any luck yet with the scripting?  
> **username_0**: No, I've been really busy in the last days. I'm going to work on it today!  
> **username_0**: I'm reindexing.  

---

### Answer by username_1 on 2014-03-25. Score: 0

As the above poster mentioned, refunding to an input address can be unreliable due to shared wallets.

The merchant protocol (BIP 70) <https://en.bitcoin.it/wiki/BIP_0070> offers a good solution to this long term, but it is still gaining adoption, and not widely used yet.

The solution we proposed to Overstock.com and other merchants at Coinbase was to send the refund to an email address (merchant's typically have these on file for the customer, who is signed in at checkout). This delivers their refund to a Coinbase account (via email), which is either their actual Coinbase account, or at an address where they can sign in to claim it. They can then move the funds anywhere they'd like.

While not perfect, this has been the best solution we've seen merchants adopt to date for refunds.


---

