<p>You're misunderstanding the code. That variable tracks whether BnB <em>was</em> used. Not whether we attempt to use it.</p>
<p>BnB does not always yield an acceptable result, as it requires a solution with no change to exist. It is attempted, but if no such solution can be found, Bitcoin Core's coin selection falls back to other algorithms. The <code>bnb_used</code> variable remembers whether that was the case.</p>

CC BY-SA 4.0
2021-02-02T04:30:00.067Z
2021-02-02T04:30:00.067Z
Pieter Wuille
<p>BnB is one of the best coin selection algorithms existing and its implementation is in the Bitcoin source code. But as seen from this line: <a href="https://github.com/bitcoin/bitcoin/blob/f72d80b07af8ecbb2f9df1e87344eb465186f19d/src/wallet/wallet.cpp#L2403" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/f72d80b07af8ecbb2f9df1e87344eb465186f19d/src/wallet/wallet.cpp#L2403</a> it is not enabled by default. Why is that or have I been mistaken?</p>

<coin-selection>
why is BnB coin selection algorithm not enabled by default?
3tbraden
# why is BnB coin selection algorithm not enabled by default?

(Asked by: username_0 on 2021-02-02)

BnB is one of the best coin selection algorithms existing and its implementation is in the Bitcoin source code. But as seen from this line: <https://github.com/bitcoin/bitcoin/blob/f72d80b07af8ecbb2f9df1e87344eb465186f19d/src/wallet/wallet.cpp#L2403> it is not enabled by default. Why is that or have I been mistaken?

**Tags:** coin-selection


---

## 1 answers

### Answer by username_1 on 2021-02-02. Score: 2 | Accepted answer

You're misunderstanding the code. That variable tracks whether BnB *was* used. Not whether we attempt to use it.

BnB does not always yield an acceptable result, as it requires a solution with no change to exist. It is attempted, but if no such solution can be found, Bitcoin Core's coin selection falls back to other algorithms. The `bnb_used` variable remembers whether that was the case.


---

