BitcoinAPI
swapchain documentation › BitcoinAPI
This interface defines the data required for the HTLC creation on the bitcoin blockchain. You are welcome to implement this yourself and pass it to the HTLC class.
The return objects are explicitly stated here as these are the only values we require. Anything else returned from your api of choice can be ignored.
interface
BitcoinAPI
Hierarchy
- BitcoinAPI
Implemented by
Index
Properties
- getBlockHeight
- getFeeEstimates
- getLastBlock
- getOutput
- getPreimageFromLastTransaction
- getTimestampAtHeight
- getValueFromLastTransaction
- pushTX
Properties
getBlockHeight
• getBlockHeight: function
Defined in pkg/types/bitcoinApi.ts:67
Return the blockheight of a transaction.
param
ID of any bitcoin transaction.
returns
Blockheight or undefined if block is not mined/broadcasted yet.
Type declaration:
▸ (transactionID
: string): Promise‹number | undefined›
Parameters:
Name | Type |
---|---|
transactionID | string |
getFeeEstimates
• getFeeEstimates: function
Defined in pkg/types/bitcoinApi.ts:75
Get fee estimates
returns
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.
memberof
BlockStream
Type declaration:
▸ (): Promise‹number[]›
getLastBlock
• getLastBlock: function
Defined in pkg/types/bitcoinApi.ts:22
Return height and timestamp of the last block. Used for timelock calculations.
Type declaration:
▸ (): Promise‹object›
getOutput
• getOutput: function
Defined in pkg/types/bitcoinApi.ts:59
Return the vout and value of the transaction.
param
ID of any bitcoin transaction.
param
The address to look for.
returns
vout and value
Type declaration:
▸ (transactionID
: string, address
: string): Promise‹object›
Parameters:
Name | Type |
---|---|
transactionID | string |
address | string |
getPreimageFromLastTransaction
• getPreimageFromLastTransaction: function
Defined in pkg/types/bitcoinApi.ts:43
Returns the preimage of the last incoming transaction.
param
Any bitcoin address.
returns
Returns the preimage of the last incoming transaction.
Type declaration:
▸ (address
: string): Promise‹string›
Parameters:
Name | Type |
---|---|
address | string |
getTimestampAtHeight
• getTimestampAtHeight: function
Defined in pkg/types/bitcoinApi.ts:28
Return the timestamp of a block defined by its height. Used for timelock calculations
Type declaration:
▸ (n
: number): Promise‹number›
Parameters:
Name | Type |
---|---|
n | number |
getValueFromLastTransaction
• getValueFromLastTransaction: function
Defined in pkg/types/bitcoinApi.ts:50
Returns the outgoing transaction of an address.
param
Any bitcoin address.
returns
Amount of the transaction and its ID.
Type declaration:
▸ (address
: string): Promise‹object›
Parameters:
Name | Type |
---|---|
address | string |
pushTX
• pushTX: function
Defined in pkg/types/bitcoinApi.ts:35
Pushes a transaction hex to the blockchain. Returns the transactionID on success. Throws on failure
Type declaration:
▸ (transactionHex
: string): Promise‹string›
Parameters:
Name | Type |
---|---|
transactionHex | string |