BlockStream

swapchain documentationBlockStream

Handler to fetch and push data from the Blockstream API.

implements {BitcoinAPI}

Hierarchy

  • BlockStream

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

+ new BlockStream(network: string): BlockStream

Defined in pkg/bitcoin/api/blockstream.ts:11

Creates an instance of BlockStream.

memberof BlockStream

Parameters:

NameTypeDescription
networkstringThe network type, either "testnet" or "mainnet".

Returns: BlockStream

Properties

baseURL

baseURL: string

Defined in pkg/bitcoin/api/blockstream.ts:11

Methods

getBlockHeight

getBlockHeight(transactionID: string): Promise‹number | undefined›

Defined in pkg/bitcoin/api/blockstream.ts:207

Return the block height of the transaction.

memberof BlockStream

Parameters:

NameTypeDescription
transactionIDstringID of any bitcoin transaction.

Returns: Promise‹number | undefined›

Blockheight or undefined if block is not mined/broadcasted yet.


getFeeEstimates

getFeeEstimates(): Promise‹number[]›

Defined in pkg/bitcoin/api/blockstream.ts:222

Get fee estimates

memberof BlockStream

Returns: Promise‹number[]›

Array with fee estimates for high, mid and low priority in satoshis/vbyte. If fee estimates are too close, it returns only one or two values.


getLastBlock

getLastBlock(): Promise‹object›

Defined in pkg/bitcoin/api/blockstream.ts:29

Get information of last block broadcasted

memberof BlockStream

Returns: Promise‹object›

Height and timestamp of the last block.


getOutput

getOutput(transactionID: string, address: string): Promise‹object›

Defined in pkg/bitcoin/api/blockstream.ts:175

Return the vout and value of the transaction.

memberof BlockStream

Parameters:

NameTypeDescription
transactionIDstringID of any bitcoin transaction.
addressstringThe address to look for.

Returns: Promise‹object›

vout and value


getPreimageFromLastTransaction

getPreimageFromLastTransaction(address: string): Promise‹string›

Defined in pkg/bitcoin/api/blockstream.ts:98

Return the Preimage of the last transacction.

memberof BlockStream

Parameters:

NameTypeDescription
addressstringThe address to look for transactions.

Returns: Promise‹string›

Preimage where address was found in vin.


getTimestampAtHeight

getTimestampAtHeight(blockHeight: number): Promise‹number›

Defined in pkg/bitcoin/api/blockstream.ts:54

Get timestamp of block for given height

memberof BlockStream

Parameters:

NameTypeDescription
blockHeightnumberThe desired block height.

Returns: Promise‹number›

Timestamp of a block defined by its height.


getValueFromLastTransaction

getValueFromLastTransaction(address: string): Promise‹object›

Defined in pkg/bitcoin/api/blockstream.ts:135

Get value and transaction id from last transaction

memberof BlockStream

Parameters:

NameTypeDescription
addressstringThe address to look for transactions.

Returns: Promise‹object›

Spendable value and the transaction id where the address occured in vout.


pushTX

pushTX(txHex: string): Promise‹string›

Defined in pkg/bitcoin/api/blockstream.ts:78

Push transaction to the bitcoin network

memberof BlockStream

Parameters:

NameTypeDescription
txHexstringAn encoded transaction in hex format.

Returns: Promise‹string›

Transaction id on success or throws error on failure.