Utils

compileMemo

Compile memo.

Parameters

  • memo string The memo to be compiled.

Returns Buffer The compiled memo.

getVaultFee

Get the vault transaction fee.

Parameters

  • inputs UTXOs The UTXOs.
  • data Buffer The compiled memo.
  • feeRate FeeRate The fee rate.

Returns number The fee amount.

getNormalFee

Get the normal transaction fee.

Parameters

  • inputs UTXOs The UTXOs.
  • feeRate FeeRate The fee rate.

Returns number The fee amount.

arrayAverage

Get the average value of an array.

Parameters

Returns number The average value.

isTestnet

Check if give network is a testnet.

Parameters

  • network Network

Returns boolean true or false

btcNetwork

Get Bitcoin network to be used with bitcoinjs.

Parameters

  • network Network

Returns Bitcoin.Network The BTC network.

getBalance

Get the balances of an address.

Parameters

  • address string
  • nodeUrl string Blockchair Node URL.
  • nodeApiKey string Blockchair API key.

Returns Array<Balance> The balances of the give address.

getChange

Get the balance changes amount.

Parameters

Returns number The change amount.

validateAddress

Validate the BTC address.

Parameters

  • address string
  • network Network

Returns boolean true or false.

scanUTXOs

Scan UTXOs from blockchair.

Parameters

  • address string
  • nodeUrl string Blockchair Node URL.
  • nodeApiKey string Blockchair API key.

Returns Array<UTXO> The UTXOs of the given address.

buildTx

Build transcation.

Parameters

  • params BuildParams The transaction build options.
    • params.amount
    • params.recipient
    • params.memo
    • params.feeRate
    • params.sender
    • params.network
    • params.nodeUrl
    • params.nodeApiKey

Returns Transaction

broadcastTx

Broadcast the transaction.

Parameters

  • params BroadcastTxParams The transaction broadcast options.
    • params.txHex
    • params.nodeUrl
    • params.nodeApiKey

Returns TxHash The transaction hash.

getDerivePath

Get DerivePath.

Parameters

  • index number (optional) (optional, default 0)

Returns DerivePath The bitcoin derivation path by the index. (both mainnet and testnet)

calcFee

Calculate fees based on fee rate and memo.

Parameters

Returns BaseAmount The calculated fees based on fee rate and the memo.

getDefaultFeesWithRates

Get the default fees with rates.

Returns FeesWithRates The default fees and rates.

getDefaultFees

Get the default fees.

Returns Fees The default fees.

getPrefix

Get address prefix based on the network.

Parameters

Returns string The address prefix based on the network.*