<p>It appears that Bitcoin Wallet for Android uses the <a href="https://github.com/bitcoinj/bitcoinj/blob/f416dec2eabb5941c6f7f4790cc4ef45fafd05f7/core/src/main/java/org/bitcoinj/wallet/DefaultCoinSelector.java#L34" rel="nofollow">DefaultCoinSelector from bitcoinj</a>.</p>

<p>The DefaultCoinSelector sorts the available UTXO by diminishing age and value:</p>

<pre><code>value [satoshi] * age [confirmations]
</code></pre>

<p>Should two UTXO compare as equal, larger value is preferred.</p>

<p>The CoinSelection then picks from the front until the target is reached.</p>

<hr>

<p><em>Still trying to figure out whether I understood this correctly:</em><br>
If the resulting change is large enough to pay for the fee and remain above dust level, the transaction goes ahead.<br>
Else, change will be increased by 0.01 BTC. If it satisfies neither option, the change will be added to the fee.</p>

CC BY-SA 3.0
2016-08-02T09:40:10.927Z
2016-08-02T09:40:10.927Z
Murch
<p>What is the algorithm in Bitcoin Wallet for Android to select the inputs to create a new transaction?</p>

<bitcoin-wallet-app><coin-selection>
How does the Coin Selection in Bitcoin Wallet for Android work?
Murch
# How does the Coin Selection in Bitcoin Wallet for Android work?

(Asked by: username_0 on 2016-07-02)

What is the algorithm in Bitcoin Wallet for Android to select the inputs to create a new transaction?

**Tags:** bitcoin-wallet-app, coin-selection


---

## 1 answers

### Answer by username_0 on 2016-08-02. Score: 2 | Accepted answer

It appears that Bitcoin Wallet for Android uses the [DefaultCoinSelector from bitcoinj](https://github.com/bitcoinj/bitcoinj/blob/f416dec2eabb5941c6f7f4790cc4ef45fafd05f7/core/src/main/java/org/bitcoinj/wallet/DefaultCoinSelector.java#L34).

The DefaultCoinSelector sorts the available UTXO by diminishing age and value:

```
value [satoshi] * age [confirmations]

```

Should two UTXO compare as equal, larger value is preferred.

The CoinSelection then picks from the front until the target is reached.

---

*Still trying to figure out whether I understood this correctly:*  
If the resulting change is large enough to pay for the fee and remain above dust level, the transaction goes ahead.  
Else, change will be increased by 0.01 BTC. If it satisfies neither option, the change will be added to the fee.


---

