Class: UTXOPlasmaBlockChain

UTXOPlasmaBlockChain(config)

UTXOPlasmaBlockChain, a UTXO plasma chain

Constructor

new UTXOPlasmaBlockChain(config)

Create UTXO plasma chain
Parameters:
Name Type Description
config Object configuration object
Source:

Methods

(async) appendBlock(newBlock)

Append block to the chain, checking that it is linked correctly.
Parameters:
Name Type Description
newBlock *
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
Source:

canSpendUTXO(tx)

Check whether the transaction can be spent.
Parameters:
Name Type Description
tx Transaction transaction
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
Source:

(async) connect()

Connect to the DB
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
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
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
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
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
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
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
Source:

(async) generateNextBlock()

Generate next block
Source:

(async) getNextBlockNumber()

Get next block number
Source:

(async) getTransactionProofInBlock(blockNumber, txIndex)

Get transaction proof in a block
Parameters:
Name Type Description
blockNumber number block number
txIndex number transaction index
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
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
Source:

getTXPool()

Get pending transaction pool.
Source:

getUTXO()

Get UTXOs
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
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
Source:

isValidTransaction(tx)

Check whether the transaction is valid
Parameters:
Name Type Description
tx Transaction transaction object
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
Source:

(async) spendUTXO(tx)

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

(async) submitTransaction(tx, confirmSig)

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