I am using the BitcoinJ API to create my wallet. When I create a transaction, I provide the change address to which change should be sent. For example: let there be 1 bitcoin at address A; then I create a transaction to send 0.1 bitcoins to address B and the change (0.9 bitcoins) back to address A.

In the BitcoinJ wallet, I see that the change (0.9 bitcoins) is not received back. To try to fix that, I created a custom coin selector to explicitly select unconfirmed transactions which are generated by myself---but still I do not see the change (0.9 bitcoins) in my wallet.

This is the transaction view https://www.biteasy.com/testnet/transactions/db66d5058e5773f353447ffa2174a417867e9aa134113f01359576f5e6f2b4c6

And this is my wallet https://www.biteasy.com/testnet/addresses/mnj3589DHMoCyhxDSvWKubjkUoTenmrGkE.

According to my address on Biteasy, there is a balance of 4BTC, but my BitcoinJ wallet shows only 0.069BTC

Now my question is: Why can't I send return change to same address it is being sent from?


1 Answer 1


You can send bitcoins to the same address you are sending from, if you create a raw transaction manually, or if you use a wallet that does not create a new change address each time a transaction is made.

One reason why this new address process exists is to protect privacy. If you consider that the outputs of a transaction with change, where one of the outputs points back to itself, you will immediately be able to determine how much you paid, and factually, that you paid that amount to someone else, keeping the change.

If on the other had a different address is used for change, an independent observer cannot determine which of the two amounts was change and which was the payment.

However what I suspect you are doing is the classic mistake of thinking that the difference between what you are paying to the other address and what was in the originating address is automatically sent back to you.

I cannot emphasize this enough - the difference is sent to the miner as a mining fee. You have in effect not explicitly told the transaction what to do with the difference and it is therefore assumed that this is a fee that you are paying, and is collected by the miner who mines the block containing your transaction.

In order to avoid this, each transaction must have a minimum of two explicit payments, and one implicit payment:

  • Input amount

  • Payment to address 1 (must be less than input)

  • Payment to address 2 (must be change minus the fee that you want to pay)

The input must be explicitly greater than the sum of payment 1 and 2, and anything left over is implicitly the miners fee

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.