Questions tagged [coin-selection]

Algorithms, schemes, and strategies used to determine which UTXOs are used to fund transactions.

Filter by
Sorted by
Tagged with
1 vote
1 answer
57 views

How bitcoin node selects the output unspent transactions when sending bitcoin?

please help me understand the algorithm for selecting UTXO when forming a new transaction in Bitcoin. For example, my wallet has a lot of incoming transactions (thousands of transactions in amounts of ...
Ketut Bakle's user avatar
5 votes
1 answer
128 views

How does the Branch and Bound coin selection algorithm work?

Murch described in his Master thesis [PDF] an algorithm for coin selection called "Branch and Bound" or "BnB". It subsequently got implemented into multiple bitcoin wallet ...
Murch's user avatar
  • 72.6k
0 votes
1 answer
124 views

Understanding fee calculation in Bitcoin Core

In the following post Calculating fee based on fee rate for bitcoin transaction the respondent describes how the fees can be calculated. Since your transaction building starts with a known target ...
yancy's user avatar
  • 1
0 votes
1 answer
45 views

Bitcoin-qt constructing a transaction and choosing the index of the ins and outs

While using Bitcoin-qt I understand there is the "Coin Selection" option. Is there also a way to choose the ordering index of the utxo's for the inputs or outputs? I'm trying to avoid the ...
Michael Tidwell's user avatar
0 votes
0 answers
25 views

Mobile wallet with unnecesary input heuristic

The iOS wallet I use leaks privacy by not implementing an option to use the unnecesary input heuristic. I would prefer a wallet that defaults to the unnecesary input heuristic, or at least allows an ...
Mercedes's user avatar
  • 797
5 votes
1 answer
261 views

What does "Waste Metric" mean in the context of Coin Selection?

I was attending a Bitcoin Core PR review club, and in the context of the wallet behavior changes that were discussed, participants were mentioning something called "waste metric". Can ...
Murch's user avatar
  • 72.6k
1 vote
1 answer
100 views

Is there a concept of tolerance used in coin selection algos in Bitcoin Core?

Does any of the coin selection algorithms used in Bitcoin Core use 'tolerance' in it? Context: Tolerance here is used for the amount that can be added to fees. In case of BnB if the user does not have ...
user avatar
0 votes
0 answers
29 views

Should you prefer spending smaller or bigger UTxOs first? [duplicate]

I'm building a bitcoin wallet and I'm not sure if it's better to spend smaller UTxOs first or bigger UTxOs?
Вања Хочак's user avatar
3 votes
1 answer
380 views

Why are there round numbers after the fees and no change?

I am looking into a cluster of addresses that seem to be repeatedly sending transactions with a round number output and no change. How/why is this happening? For example c809850a2d8b… and 718fd33c7307…...
Shm's user avatar
  • 48
4 votes
2 answers
142 views

Is there a way to avoid sendtoaddress from "sweeping"?

I have a wallet that has several hundred small amounts residing at multiple addresses. I noticed yesterday that, when sending a relatively small amount to a third party that the bitcoind "swept&...
David Hoelzer's user avatar
1 vote
1 answer
48 views

Testing `avoidpartialspends` option in Bitcoin Core

I have lot of UTXOs in a test wallet (Bitcoin Core v0.21.1). Sent random amounts to same address in 9 transactions. So tb1qyqd9p9d2rc5a9v6cphucn999ljfcvdhymthypy has 9 UTXOs: Saved avoidpartialspends=...
user avatar
1 vote
2 answers
593 views

How does a wallet decide which utxo to use?

I am using a cold wallet and made a few tx two days ago. However, though what I wanted to send was a very small amount of btc, the wallet made multiple utxo of huge amounts get involved and now all my ...
Rich's user avatar
  • 11
3 votes
1 answer
392 views

bitcoin-core automatic coin selection

for business reason i need to use the bitcoin-core (v0.20.1) automatic coin selection feature and few days ago i saw a transaction come out that left me puzzled, it was like that: input 0.00017[...]...
leevancleef's user avatar
2 votes
2 answers
457 views

Calculating fee based on fee rate for bitcoin transaction

I'm writing an algorithm for calculating fee based on fee rate and amount to be sent (requested amount) in order to propose the fee to user; Sorting UTXOs ascending based on value Take enough UTXOs ...
Andrija's user avatar
  • 131
1 vote
2 answers
84 views

Address Reuse vs. Coin Selection

I have read at length that address reuse should be avoided, for instance the bitcoin wiki describes numerous reasons here. I have also read Murch's master thesis on coin selection. These two concepts ...
Prince M's user avatar
  • 340
1 vote
1 answer
114 views

why is BnB coin selection algorithm not enabled by default?

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/...
3tbraden's user avatar
  • 229
2 votes
2 answers
255 views

Bitcoin-cli 0.19.1 Wallet not Sending from Addresses with Closest Amount?

I have a weird issue that I thought was fixed a few years back with Bitcoin wallet to reduce fees. I guess not, or I am missing something... My wallet received a transaction for the amount of 0....
Duetschpire's user avatar
9 votes
3 answers
1k views

What's the most efficient way to create a raw transaction with a specific fee rate?

There seems to be a chicken and egg problem when it comes to creating a transaction that has a specific fee rate (sat/kW). In order to set a specific fee rate, you need to know what the total weight ...
Darius's user avatar
  • 779
5 votes
2 answers
88 views

Is there a way to determine the optimal size of a batched transaction to save on fees?

I've been looking at other questions about fees and batching, but it seems no one asked if there is some way to determine the optimal size of a transaction to save on fees (assuming all inputs are ...
Sosthène's user avatar
  • 623
4 votes
1 answer
222 views

Is there a way to allow use of unconfirmed RBF outputs in transaction building?

Bitcoin Core seems to not consider unconfirmed outputs that are marked replaceable in input selection. Is there a way to override this protection and allow use anyway? The transaction is created using ...
Murch's user avatar
  • 72.6k
3 votes
1 answer
668 views

Coin selection algorithm

Playing around with Bitcoin Core Client v0.18.0, I used this command: $ bitcoin-cli sendtoaddress "mozazucvLK179u41bF5Vd2Agp4wsm7HsPo" 0.1 which created this transaction. I noticed that the ...
azavalla's user avatar
1 vote
1 answer
141 views

How does a Bitcoin (Core) wallet use inputs?

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 (...
Bart DV's user avatar
  • 71
3 votes
2 answers
357 views

What's partial spending? What does avoidpartialspend do?

Group outputs by address, selecting all or none, instead of selecting on a per-output basis. Privacy is improved as an address is only used once (unless someone sends to it after spending from it), ...
Chris Chen's user avatar
5 votes
1 answer
445 views

Are all UTXOs locked by an address spent in a transaction?

Imagine I have 2 UTXOs locked by my address, each of which allows me to spend 5 bitcoins. If I subsequently want to send just 2 bitcoins to someone else, will both UTXOs be used as inputs in the ...
Simon O'Hanlon's user avatar
1 vote
2 answers
266 views

How would I need to change ElectrumX to use FIFO selection of UTXOs?

By default, UTXOs are picked randomly in ElectrumX. I want to change this behaviour and spend UTXOs on 'FIFO' basis. What changes do I need to make?
Shahr_96's user avatar
3 votes
1 answer
111 views

How do Schnorr signatures impact coin selection and the utxo growth?

Will Schnorr signature incentivise different practices in coin selection? How do they impact the utxo set in the long run?
domegabri's user avatar
6 votes
2 answers
577 views

Has UTXO selection methods changed since activation of Segwit?

Before Segwit, transactions were penalized higher fees for having more inputs than outputs due to the input size being larger despite those transactions actually decreasing the global UTXO set. Segwit ...
satoshi_ghost's user avatar
2 votes
1 answer
629 views

How to get unspents for inputs using bitcoinjs-lib?

I would like my simple wallet app to automatically select UTXOs for inputs. I realize that I can't accomplish this with just bitcoinjs, but is there something I can add to it to keep track of unspents?...
Setheroni's user avatar
2 votes
2 answers
93 views

coin selection - why selecting transactions with confirmations first better

I know that selecting transactions with confirmations first are much better than spending transactions with 0 confirmations direct. But why is that?
Adam's user avatar
  • 3,649
2 votes
4 answers
3k views

Why do some transactions have more than one input?

I know a normal transaction has 1 input and 2 outputs (if there is change that is the second output). But what about this scenario? Lets say I'm withdrawing bitcoin from my gemini account and want ...
Marc Alexander's user avatar
5 votes
2 answers
6k views

Send BTC with Electrum: which address is used?

I'm new to bitcoin and I've downloaded Electrum. I can see the new wallet generated a few addresses for me. If I want to receive BTC, I just need to give one of those addresses. But if I want to ...
JDoe's user avatar
  • 53
3 votes
1 answer
624 views

Coin selection algorithm in Python to optimally select UTXO

Does anyone know of a good coin selection algorithm in Python that's perhaps similar to the one in Bitcoin Core (currently this: github/bitcoin/src/wallet.cpp (per guidance from stackexchange/1077))? ...
kumarz's user avatar
  • 231
2 votes
1 answer
257 views

How does the Coin Selection in Bitcoin Wallet for Android work?

What is the algorithm in Bitcoin Wallet for Android to select the inputs to create a new transaction?
Murch's user avatar
  • 72.6k
8 votes
3 answers
1k views

Why is the witness data fee discounted by a factor of four?

I've read that it encourages users to consolidate UTXO sets. How would it be doing that?
Murch's user avatar
  • 72.6k
6 votes
2 answers
441 views

Which inputs will be spent?

Say someone holds 100,000 btc. Over time, this address has been spammed with dust by numerous parties. Now, the oldest funds come from the previous large transaction. If the dust is, say 0....
linhares's user avatar
  • 399
4 votes
2 answers
371 views

How does Bitcoin Core's Coin Selection prevent change to be a dust output?

Bitcoin Core's Coin Selection optimizes for minimal change outputs. How does Bitcoin Core prevent Change outputs of sizes below dust threshold from occurring?
Murch's user avatar
  • 72.6k
1 vote
1 answer
750 views

Do all UTXO get moved to the newest change address?

There is one thing I do not understand about unspent outputs and change addresses. For example, let's say a person has 5BTC in a wallet, and they have 2 unspent outputs of 3BTC and 2BTC. They one ...
patchariadog's user avatar
2 votes
1 answer
214 views

How to spend bitcoins From Account and specify Fee

I am writing an application that uses bitcoin wallet accounts to specify what addresses belong to what user. I have been reading the documentation trying to find a way to spend Bitcoins specifying the ...
mesafria's user avatar
2 votes
1 answer
131 views

What order does Bitcoin Core place the inputs it spends in?

What order does Bitcoin core place the inputs it spends in? Is it random? Is it sorted by anything? What, if anything, can you tell about the originator of a transaction by the input ordering?
Nick ODell's user avatar
  • 29.3k
11 votes
2 answers
9k views

What does Bitcoin Core's "Coin Control Features" do and how do I use it?

What is Bitcoin Core's "Coin Control Features"? How do I use it, and what can I do with it?
Geremia's user avatar
  • 4,556
8 votes
1 answer
2k views

What are the trade-offs between the different algorithms for deciding which UTXOs to spend?

When someone would like to make a transaction, their software has to choose which of their UTXOs to spend. Here are a few different ways that one might prioritize which UTXOs get spent. Oldest UTXOs ...
morsecoder's user avatar
9 votes
3 answers
746 views

How can I control which coins to spend in a transaction?

When creating a bitcoin transaction, you have to choose which coins to use in them. The standard client does this in a way to avoid unconfirmed inputs and minimize the number of inputs and amount of ...
Thilo's user avatar
  • 4,749
45 votes
2 answers
9k views

What is the coin selection algorithm?

When creating a transaction in the standard client, what is the algorithm used to determine which unspent outputs will be used as inputs? Has this changed since the first version? What different ...
Andrew Jones's user avatar