142 / 691SELECT

Coin Selection

Selecting UTXOs for a transaction

Coin Selection determines which UTXOs a wallet spends. It affects today's fee, change, future costs and links between payment histories.

Coin Selection is the wallet procedure that selects UTXOs to fund transaction outputs and fees. It is a local decision, not a consensus rule requiring every wallet to use the same algorithm.

Each input spends an entire specific UTXO. The difference between total inputs and outputs is the fee; funds returned to the sender require a separate output. In an illustrative example, a 100000 sat input, a 60000 sat payment and a 1000 sat fee leave 39000 sat in change. [Bitcoin Developer Guide — Transactions]

Face value alone is insufficient: adding an input enlarges the transaction. Effective value subtracts the cost of spending the UTXO at the chosen fee rate. An illustrative 10000 sat input estimated at 68 vB at 10 sat/vB contributes 9320 sat; the rest of the transaction still needs its own fee. Actual size depends on script and signature. [Bitcoin Core — Coin selection implementation] [Bitcoin Core 29.0 — Transaction creation]

Branch-and-bound (BnB) searches input combinations for a changeless payment. Its target range permits excess up to the cost of creating and later spending change; that excess becomes fees. It does not require an exact match. A bounded search may fail to find a solution or the global optimum. [Bitcoin Core — Coin selection implementation]

Bitcoin Core 29.0 considers BnB, Knapsack and Single Random Draw (SRD); CoinGrinder participates when the effective fee rate exceeds three times the long-term rate. It compares candidates using the waste metric. It skips BnB when subtracting fees from outputs. This describes a specific version, not a universal algorithm sequence for all wallets. [Bitcoin Core 29.0 — Transaction creation]

The waste metric compares input costs now and at a long-term fee rate, together with change costs or excess given to fees. The long-term rate is an assumption, not a forecast. Consolidation can reduce future input counts, but costs fees today and links the outputs used; the smallest immediate fee is therefore not the sole objective. [Bitcoin Core — Coin selection implementation] [Bitcoin Design — Coin selection and privacy]

Jointly spending different receipts gives analysts a clue linking them, not proof of one person. Coin Control and labels help keep payment contexts separate. BIP 329 describes transferring labels and spendability metadata; it does not select coins itself, and an export can expose sensitive links. Even a lack of change does not guarantee anonymity. [BIP 329 — Wallet Labels Export Format] [Bitcoin Design — Coin selection and privacy]

Selection must respect spendability, confirmations, locked outputs and transaction limits. In Core 29.0's walletcreatefundedpsbt RPC, include_unsafe also permits risky unconfirmed inputs; if their transactions disappear, the constructed payment may become invalid. Unconfirmed ancestors can additionally require extra fees. A large balance alone does not guarantee a suitable input combination. [Bitcoin Core 29.0 — Transaction creation] [Bitcoin Core 29.0 — walletcreatefundedpsbt RPC]

In Core 29.0 walletcreatefundedpsbt, inputs can be specified by txid and vout; add_inputs controls adding others. fee_rate uses sat/vB, whereas feeRate uses BTC/kvB. The resulting PSBT is preparation for further processing, not a confirmed payment. Recipients, total fee and one's own change are checked before signing; manual selection does not remove that responsibility. [Bitcoin Core 29.0 — walletcreatefundedpsbt RPC]

For the clearest picture, read this entry together with UTXO, Coin Control, Change output, Fee Rate, PSBT, Bitcoin Privacy. The reverse links also lead from Watch-only Wallet, Change output.

DOC · 001Bitcoin Developer Guide — TransactionsDocumentationDOC · 002Bitcoin Core — Coin selection implementationPrimaryDOC · 003Bitcoin Core 29.0 — Transaction creationPrimaryDOC · 004BIP 329 — Wallet Labels Export FormatSpecificationDOC · 005Bitcoin Core 29.0 — walletcreatefundedpsbt RPCDocumentationDOC · 006Bitcoin Design — Coin selection and privacyDocumentation
Source-first · No investment advice