Module: lib/blockchains/bitcoin/accounts

Module for managing Bitcoin accounts for Whiteflag

Source:

Methods

(inner) checkAccount(address) → {Promise}

Verifies if an account exists and is not syncing

Parameters:
Name Type Description
address string

the Bitcoin account address

Source:
Returns:

the account data

Type
Promise

(inner) createAccount(wifopt) → {Promise}

Creates a new Bitcoin account from an existing or a new key pair

Parameters:
Name Type Attributes Description
wif string <optional>

hexadecimal string with with private key in Wallet Import Format (WIF)

Source:
Returns:

resolves to the account data

Type
Promise

(inner) deleteAccount(address, callback)

Deletes a Bitcoin blockchain account

Parameters:
Name Type Description
address string

the address of the account information object with updated informationto be deleted

callback bcDeleteAccountCb

function called on completion

Source:

(inner) getAccount(address) → {Promise}

Gets account data of a Bitcoin blockchain account by address

Parameters:
Name Type Description
address string

the Bitcoin account address

Source:
Returns:

the account data

Type
Promise

(inner) getAddress(btcPublicKey, btcNetworkopt, scriptopt) → {Promise}

Derives a Bitcoin address from a public key

Parameters:
Name Type Attributes Description
btcPublicKey string

a hexadecimal encoded public key

btcNetwork Object <optional>

the Bitcoin network

script string <optional>

the script to locks an output to a public key hash

Source:
Returns:

resolves to the the Bitcoin address

Type
Promise

(inner) getKeypair(privateKey, btcNetworkopt) → {Promise}

Creates a Bitcoin keypair from a hexadecimal private key

Parameters:
Name Type Attributes Description
privateKey string

the hexadecimal private key

btcNetwork Object <optional>

the Bitcoin network to create the keypair for

Source:
Returns:

resolves to a keypair

Type
Promise

(inner) initAccounts(btcConfig, btcState)

Initialises Bitcoin accounts management

Parameters:
Name Type Description
btcConfig Object

the Bitcoin blockchain configuration

btcState Object

the Bitcoin blockchain state

Source:

(inner) processBlockUtxos(blockNumber, block)

Processes block to check for incoming UTXOs for each account

Parameters:
Name Type Description
blockNumber number

the blocknumer

block Object

the full block including transactions

Source:

(inner) updateAccount(account) → {Promise}

Updates a Bitcoin blockchain account attributes

Parameters:
Name Type Description
account string

the account information object with updated information

Source:
Returns:

resolves to the account data

Type
Promise

(inner) updateAccountBalance(account)

Updates the account balance based on unspent UTXOs

Parameters:
Name Type Description
account wfAccount

the account to be updated

Source:

(inner) updateAccountUtxosSpent(account, spentUtxos)

Updates the status of the UTXOs for an account

Parameters:
Name Type Description
account wfAccount

the Bitcoin account

spentUtxos Array

the UTXOs spent by a transaction

Source: