Class: CoinSelector

primitives~CoinSelector(tx, optionsnullable)

Coin Selector

Constructor

new CoinSelector(tx, optionsnullable)

Create a coin selector.

Parameters:
Name Type Attributes Description
tx TX
options Object <nullable>
Source:

Members

(static, constant) FEE_RATE :Amount

Default fee rate for coin selection.

Type:
Default Value:
  • 10000
Source:

(static, constant) MAX_FEE :Amount

Maximum fee to allow after coin selection.

Type:
Source:

(static, constant) MIN_FEE :Amount

Minimum fee to start with during coin selection.

Type:
Default Value:
  • 10000
Source:

Methods

(private) fromOptions(options)

Initialize selector options.

Parameters:
Name Type Description
options Object
Source:

fund()

Fund the transaction with more coins if the output value + fee total was updated.

Source:

getFee(size) → {Amount}

Get the current fee based on a size.

Parameters:
Name Type Description
size Number
Source:
Returns:
Type
Amount

init(coins)

Initialize the selector with coins to select from.

Parameters:
Name Type Description
coins Array.<Coin>
Source:

(private) injectInputs()

Attempt to inject existing inputs.

Source:

isFull() → {Boolean}

Test whether the selector has completely funded the transaction.

Source:
Returns:
Type
Boolean

isSpendable(coin) → {Boolean}

Test whether a coin is spendable with regards to the options.

Parameters:
Name Type Description
coin Coin
Source:
Returns:
Type
Boolean

(async) select(coins) → {CoinSelector}

Initiate selection from coins.

Parameters:
Name Type Description
coins Array.<Coin>
Source:
Returns:
Type
CoinSelector

(async) selectEstimate()

Initialize selection based on size estimate.

Source:

selectHard()

Initiate selection based on a hard fee.

Source:

total() → {Amount}

Calculate total value required.

Source:
Returns:
Type
Amount