Class: Provider

Provider

new Provider(db)

Represents Wallet Provider. This is what allows the Wallet object to access transactions and utxos, as well as listen for events like confirmations, etc. Any object that follows this model can be used as a wallet provider.

Parameters:
Name Type Description
db WalletDB
Properties:
Name Type Attributes Description
db WalletDB
id WalletID <nullable>
Source:

Methods

addTX(tx, callback)

Add a transaction to the provider backend (not technically necessary if you're implementing a provider).

Parameters:
Name Type Description
tx TX
callback function
Source:

close(callback)

Close the provider, unlisten on wallet.

Parameters:
Name Type Description
callback function
Source:

fillCoins(tx, callback)

Fill a transaction with coins.

Parameters:
Name Type Description
tx TX
callback function

Returns [Error, TX].

Source:

fillHistory(tx, callback)

Fill a transaction with coins (all historical coins).

Parameters:
Name Type Description
tx TX
callback function

Returns [Error, TX].

Source:

getBalance(callback)

Calculate wallet balance.

Parameters:
Name Type Description
callback function

Returns [Error, Balance].

Source:

getCoin(hash, index, callback)

Get coin.

Parameters:
Name Type Description
hash Hash
index Number
callback function

Returns [Error, Coin].

Source:

getCoins(callback)

Get all coins for wallet.

Parameters:
Name Type Description
callback function

Returns [Error, Coin[]].

Source:

getHistory(callback)

Get all transactions for wallet.

Parameters:
Name Type Description
callback function

Returns [Error, TX[]].

Source:

getLast(limit, callback)

Get last N transactions.

Parameters:
Name Type Description
limit Number

Max number of transactions.

callback function

Returns [Error, TX[]].

Source:

getLastTime(callback)

Get last active timestamp and height.

Parameters:
Name Type Description
callback function

Returns [Error, Number(ts), Number(height)].

Source:

getRange(options, callback)

Get transactions by timestamp range.

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Description
start Number

Start time.

end Number

End time.

limit Number <nullable>

Max number of records.

reverse Boolean <nullable>

Reverse order.

callback function

Returns [Error, TX[]].

Source:

getTX(hash, callback)

Get transaction.

Parameters:
Name Type Description
hash Hash
callback function

Returns [Error, TX].

Source:

getUnconfirmed(callback)

Get all unconfirmed transactions for wallet.

Parameters:
Name Type Description
callback function

Returns [Error, TX[]].

Source:

open(callback)

Open the provider, wait for the database to load.

Parameters:
Name Type Description
callback function
Source:

setID(id)

Set the ID, telling the provider backend which wallet we want to listen for events on.

Parameters:
Name Type Description
id WalletID
Source:

update(wallet, address)

Notify the provider backend that a new address was derived (not technically necessary if you're implementing a provider).

Parameters:
Name Type Description
wallet Wallet
address Address
Source:

zap(now, age, callback)

Zap stale transactions.

Parameters:
Name Type Description
now Number

Current time.

age Number

Age delta (delete transactions older than now - age).

callback function
Source: