Skip to main content

Module coin_select

Module coin_select 

Source
Expand description

Simple UTXO coin selection for eCash (XEC) transactions.

Strategy: largest-first. Pick the biggest UTXOs until we have enough to cover the target amount + estimated fee. Produces change output if there’s surplus above a dust threshold.

This is a cold-path construction utility (Tier-2). It allocates internally but the public output is caller-buffered via return values.

Structs§

CoinSelection
Result of coin selection.

Constants§

BASE_FEE_SATS
Estimated transaction fee in satoshis for a simple P2PKH tx. ~1 input + 2 outputs ≈ 226 bytes × 1 sat/byte = 226 sats. We use a conservative estimate.
DUST_THRESHOLD_SATS
Minimum output value (in satoshis) below which we skip creating a change output. For XEC: 546 satoshis = 5.46 XEC dust threshold.
PER_INPUT_FEE_SATS
Per-input fee contribution in satoshis (~148 bytes per additional input).

Functions§

select_token_utxos
Select UTXOs that contain a specific SLP/ALP token. Returns the token UTXOs + plain XEC UTXOs needed to cover the fee.
select_utxos
Select UTXOs to cover target_sats using largest-first strategy.