Class: BeOnBlockChain

BeOnBlockChain(config)

BeOn block chain

Constructor

new BeOnBlockChain(config)

Create a BeOn block chain with the configuration object
Parameters:
Name Type Description
config Object configuration object
Source:

Extends

Methods

(async) appendBlock(newBlock)

Append block to the chain, checking that it is linked correctly.
Parameters:
Name Type Description
newBlock *
Inherited From:
Source:

canCreateUTXO(blockNumber, tx, txIndex)

Check whether this transaction can create a UTXO
Parameters:
Name Type Description
blockNumber number block number
tx Transaction a transaction object
txIndex number transaction index
Inherited From:
Source:

canSpendUTXO(tx)

Check whether the transaction can be spent.
Parameters:
Name Type Description
tx Transaction transaction
Inherited From:
Source:

(async) collectTransactions(blockNumber, deposits, withdrawals)

Collect all transactions
Parameters:
Name Type Description
blockNumber number block number
deposits Array.<Transaction> deposit transactions
withdrawals Array.<Transaction> withdrawal transactions
Inherited From:
Source:

(async) connect()

Connect to the DB
Inherited From:
Source:

createDepositTransactions(deposits)

Create deposit transactions from deposit objects collected from deposit events
Parameters:
Name Type Description
deposits Array.<Object> deposit objects collected from deposit events
Inherited From:
Source:

createMergeTransaction(owner, token)

Create a merge transaction to combine UTXO of the same owner and token
Parameters:
Name Type Description
owner string hex string of owner address
token string hex string of token address
Inherited From:
Source:

(async) createTransaction(token, from, to, amount, confirmSigopt, key)

Create a transaction
Parameters:
Name Type Attributes Description
token string hex string of token address
from string hex string of from address
to string hex string of to address
amount string the amount to transfer in ether unit
confirmSig string <optional>
the confirmation signature
key string the hex string of the private key
Inherited From:
Source:

(async) createUnsignedTransaction(token, from, to, amount, confirmSigopt)

Create an unsigned transaction
Parameters:
Name Type Attributes Description
token string hex string of token address
from string hex string of from address
to string hex string of to address
amount string the amount to transfer in ether unit
confirmSig string <optional>
the confirmation signature
Inherited From:
Source:

(async) createUTXO(blockNumber, tx, txIndex)

Create UTXO
Parameters:
Name Type Description
blockNumber number block number
tx Transaction a transaction object
txIndex number transaction index
Inherited From:
Source:

createWithdrawalTransactions(withdrawals)

Create withdrawal transactions from withdrawal objects collected from withdrawal events
Parameters:
Name Type Description
withdrawals Array.<Object> withdrawal objects collected from withdrawal events
Inherited From:
Source:

(async) generateConfirmSig(blkNum, txIndex, key)

Generate confirmation signature
Parameters:
Name Type Description
blkNum number block number
txIndex number transaction index
key string hex string of the private key
Inherited From:
Source:

(async) generateNextBlock()

Generate next block
Inherited From:
Source:

(async) getNextBlockNumber()

Get next block number
Inherited From:
Source:

(async) getTransactionProofInBlock(blockNumber, txIndex)

Get transaction proof in a block
Parameters:
Name Type Description
blockNumber number block number
txIndex number transaction index
Inherited From:
Source:

getTwoUTXOsByAddress(owner, token)

Get two UTXOs by address
Parameters:
Name Type Description
owner string hex string of owner address
token string hex string of token address
Inherited From:
Source:

(async) getTxHashRoot(blkNum, txIndex)

Get transaction hash, its merkle root and signature
Parameters:
Name Type Description
blkNum number block number
txIndex number transaction index
Inherited From:
Source:

getTXPool()

Get pending transaction pool.
Inherited From:
Source:

getUTXO()

Get UTXOs
Inherited From:
Source:

getUTXOByAddress(owner, token, startopt)

Get UTXO by owner address
Parameters:
Name Type Attributes Default Description
owner string hex string of owner address
token string hex string of token address
start number <optional>
0 starting UTXO index to find
Inherited From:
Source:

getUTXOByIndex(blkNum, txIndex, oIndex, token)

Get UTXO by index
Parameters:
Name Type Description
blkNum number block number
txIndex number transaction index
oIndex number output index
token string hex string of token address
Inherited From:
Source:

isValidTransaction(tx)

Check whether the transaction is valid
Parameters:
Name Type Description
tx Transaction transaction object
Inherited From:
Source:

(async) setConfirmSignature(blkNum, txIndex, confirmSignature)

Set confirmation signature
Parameters:
Name Type Description
blkNum number block number
txIndex number transaction index
confirmSignature string confirmation signature in hex string
Inherited From:
Source:

(async) spendUTXO(tx)

Spend UTXO
Parameters:
Name Type Description
tx Transaction transaction
Inherited From:
Source:

startMining(checkInterval)

Start mining process on the chain
Parameters:
Name Type Default Description
checkInterval number 500 interval to check for pending transactions and generate a block
Source:

(async) submitTransaction(tx, confirmSig)

Submit Transaction
Parameters:
Name Type Description
tx Transaction a transaction object
confirmSig string a confirmation signature
Inherited From:
Source: