Class: Txref

Txref

This class provides functions for Txrefs. There isn't any need to createan instance of this class so only static methods are provided.

new Txref()

Members


BECH32_HRP_MAINNET

Human readable part of bech32 data to signify the bitcoin mainnet chain

BECH32_HRP_TESTNET

Human readable part of bech32 data to signify the bitcoin testnet chain

TYPE_MAINNET

The initial byte of the bech32 data to signify the bitcoin mainnet chain

TYPE_MAINNET_EXT

The initial byte of the bech32 data to signify the bitcoin mainnet chain with utxoIndex data

TYPE_TESTNET

The initial byte of the bech32 data to signify the bitcoin testnet chain

TYPE_TESTNET_EXT

The initial byte of the bech32 data to signify the bitcoin testnet chain with utxoIndex data

Methods


<static> binaryEncode(chain, block_height, block_index, utxo_index)

The txref is binary data encoded over a set number of bytes, determined by whether a utxoIndex is supplied.
Parameters:
Name Type Description
chain string chain The name of the btc chain mainnet or testnet
block_height Number The block in which the transaction is found
block_index Number The position in the block where the transaction is found
utxo_index Number The position of the utxo in the transaction input
Returns:
txref A binary encoded txref
Type
binary

<static> binaryToString(data)

Convert binary txref to a bech32 formatted string with delimiters to make it more human readable.
Parameters:
Name Type Description
data binary The binary encoded bech32 txref.
Returns:
txref - The txref in human readable form
Type
string

<static> decode(txref)

Convert a txref to ttransaction data
Parameters:
Name Type Description
txref Txref The txref encoding the transaction position
Returns:
tx - The transaction data encoded in the txref
Type
Object

<static> encode(chain, blockHeight, blockIndex, utxoIndex)

Encode transaction location data into a txref
Parameters:
Name Type Description
chain string chain The name of the btc chain mainnet or testnet
blockHeight Number The block in which the transaction is found
blockIndex Number The position in the block where the transaction is found
utxoIndex Number The position of the utxo in the transaction input
Returns:
txref - The Bech32 txref
Type
string