Represents a Bitcoin client.
- broadcast
- findAllUnspentTransactionOutputs
- getHeadersChain
- getNetwork
- getRawTransaction
- getTransaction
- getTransactionConfirmations
- getTransactionHistory
- getTransactionMerkle
- getTxHashesForPublicKeyHash
- latestBlockHeight
▸ broadcast(transaction
): Promise
<void
>
Broadcasts the given transaction over the network.
Name | Type | Description |
---|---|---|
transaction |
BitcoinRawTx |
Transaction to broadcast. |
Promise
<void
>
▸ findAllUnspentTransactionOutputs(address
): Promise
<BitcoinUtxo
[]>
Finds all unspent transaction outputs (UTXOs) for given Bitcoin address. The list includes UTXOs from both the blockchain and the mempool, sorted by age with the newest ones first. Mempool UTXOs are listed at the beginning.
Name | Type | Description |
---|---|---|
address |
string |
Bitcoin address UTXOs should be determined for. |
Promise
<BitcoinUtxo
[]>
List of UTXOs.
▸ getHeadersChain(blockHeight
, chainLength
): Promise
<Hex
>
Gets concatenated chunk of block headers built on a starting block.
Name | Type | Description |
---|---|---|
blockHeight |
number |
Starting block height. |
chainLength |
number |
Number of subsequent blocks built on the starting block. |
Promise
<Hex
>
Concatenation of block headers in a hexadecimal format.
▸ getNetwork(): Promise
<BitcoinNetwork
>
Gets the network supported by the server the client connected to.
Promise
<BitcoinNetwork
>
Bitcoin network.
▸ getRawTransaction(transactionHash
): Promise
<BitcoinRawTx
>
Gets the raw transaction data for given transaction hash.
Name | Type | Description |
---|---|---|
transactionHash |
BitcoinTxHash |
Hash of the transaction. |
Promise
<BitcoinRawTx
>
Raw transaction.
▸ getTransaction(transactionHash
): Promise
<BitcoinTx
>
Gets the full transaction object for given transaction hash.
Name | Type | Description |
---|---|---|
transactionHash |
BitcoinTxHash |
Hash of the transaction. |
Promise
<BitcoinTx
>
Transaction object.
▸ getTransactionConfirmations(transactionHash
): Promise
<number
>
Gets the number of confirmations that a given transaction has accumulated so far.
Name | Type | Description |
---|---|---|
transactionHash |
BitcoinTxHash |
Hash of the transaction. |
Promise
<number
>
The number of confirmations.
▸ getTransactionHistory(address
, limit?
): Promise
<BitcoinTx
[]>
Gets the history of confirmed transactions for given Bitcoin address. Returned transactions are sorted from oldest to newest. The returned result does not contain unconfirmed transactions living in the mempool at the moment of request.
Name | Type | Description |
---|---|---|
address |
string |
Bitcoin address transaction history should be determined for. |
limit? |
number |
Optional parameter that can limit the resulting list to a specific number of last transaction. For example, limit = 5 will return only the last 5 transactions for the given address. |
Promise
<BitcoinTx
[]>
▸ getTransactionMerkle(transactionHash
, blockHeight
): Promise
<BitcoinTxMerkleBranch
>
Get Merkle branch for a given transaction.
Name | Type | Description |
---|---|---|
transactionHash |
BitcoinTxHash |
Hash of a transaction. |
blockHeight |
number |
Height of the block where transaction was confirmed. |
Promise
<BitcoinTxMerkleBranch
>
Merkle branch.
▸ getTxHashesForPublicKeyHash(publicKeyHash
): Promise
<BitcoinTxHash
[]>
Gets hashes of confirmed transactions that pay the given public key hash using either a P2PKH or P2WPKH script. The returned transactions hashes are ordered by block height in the ascending order, i.e. the latest transaction hash is at the end of the list. The returned list does not contain unconfirmed transactions hashes living in the mempool at the moment of request.
Name | Type | Description |
---|---|---|
publicKeyHash |
Hex |
Hash of the public key for which to find corresponding transaction hashes. |
Promise
<BitcoinTxHash
[]>
Array of confirmed transaction hashes related to the provided public key hash.
▸ latestBlockHeight(): Promise
<number
>
Gets height of the latest mined block.
Promise
<number
>
Height of the last mined block.