Skip to main content
The FewestCoinSelector class provides a coin selection algorithm that selects the fewest UTXOs required to meet the target amount. This algorithm is useful for minimizing the size of the transaction and the fees associated with it. This class is a sub-class of AbstractCoinSelector | AbstractCoinSelector and implements the AbstractCoinSelector.performSelection | performSelection method to provide the actual coin selection logic.

Extends

  • AbstractCoinSelector

Constructors

new FewestCoinSelector()

Constructs a new AbstractCoinSelector instance with an empty UTXO array.

Parameters

Returns

FewestCoinSelector

Inherited from

AbstractCoinSelector.constructor

Source

transaction/abstract-coinselector.ts:61

Methods

decreaseFee()

Decreases the fee by removing inputs if possible and adjusting change outputs.

Parameters

Returns

SelectedCoinsResult

Source

transaction/coinselector-fewest.ts:280

increaseFee()

Increases the total fee by first reducing change outputs, then selecting additional inputs if necessary.

Parameters

Returns

SelectedCoinsResult Returns true if successful, false if insufficient funds.

Source

transaction/coinselector-fewest.ts:226

performSelection()

Performs coin selection to meet the target amount plus fee, using the smallest possible denominations and minimizing the number of inputs and outputs.

Parameters

Returns

SelectedCoinsResult The selected UTXOs and outputs.

Overrides

AbstractCoinSelector.performSelection

Source

transaction/coinselector-fewest.ts:24