When creating a new transaction, how does the Bitcoin Core wallet (or any other wallet) handle/use the outputs (UTXO's)?

e.g. when 2 outputs have to be used, will Bitcoin spend the highest address (most BTC) first and then the second highest or are the UTXO's used in another way?

Which output will be used for the change (if there is any)?

1 Answer 1


Bitcoin Core uses a Branch and Bound algorithm to search for an input set that exactly matches the send request. To that end, it will deterministically search the combination space of all of its available utxos and pick the set that is the most efficient if there are multiple solutions. The Branch and Bound algorithm is briefly described in the sourcecode and more comprehensively in my master's thesis.

If no matching solution is found with the Branch and Bound algorithm, Bitcoin Core will fall back to its previous strategy. This entails sorting all unspents descendingly by their value and iteratively picking a subset by randomly including or skipping list elements.

  • Interesting, gonna check out your thesis. Thanks!
    – Bart DV
    May 15, 2019 at 18:28

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.