Class: Wallet

wallet.Wallet(options)

Wallet

Constructor

new Wallet(options)

Create a wallet.

Extends:
  • EventEmitter
Parameters:
Name Type Description
options Object
Source:

Extends

  • EventEmitter

Methods

(static) decode(data) → {Wallet}

Instantiate a wallet from serialized data.

Parameters:
Name Type Description
data Buffer
Source:
Returns:
Type
Wallet

(static) fromOptions(wdb, options) → {Wallet}

Instantiate wallet from options.

Parameters:
Name Type Description
wdb WalletDB
options Object
Source:
Returns:
Type
Wallet

(static) isWallet(obj) → {Boolean}

Test an object to see if it is a Wallet.

Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Boolean

(private) _abandon(hash) → {Promise}

Abandon transaction without a lock.

Parameters:
Name Type Description
hash Hash
Source:
Returns:
Type
Promise

(async, private) _add(tx, blockopt, extraopt) → {Promise.<?AddResult>}

Add a transaction to the wallet without a lock. Potentially resolves orphans.

Parameters:
Name Type Attributes Description
tx TX
block BlockMeta <optional>
extra BlockExtraInfo <optional>
Source:
Returns:
Type
Promise.<?AddResult>

(async, private) _addSharedKey(acct, key) → {Promise}

Add a public account key to the wallet without a lock.

Parameters:
Name Type Description
acct Number | String
key HDPublicKey
Source:
Returns:
Type
Promise

(async) _createAccount(options) → {Promise}

Create an account without a lock.

Parameters:
Name Type Description
options Object

See Account options.

Source:
Returns:
  • Returns Account.
Type
Promise

(async) _createAuctionTXs(name, value, lockup, options) → {Object|MTX|MTX}

Create and finalize a bid & a reveal (in advance) MTX without a lock.

Parameters:
Name Type Description
name String
value Number
lockup Number
options Object
Source:
Returns:
  • output

    Type
    Object
  • output.bid

    Type
    MTX
  • output.reveal

    Type
    MTX

(async) _createBatch(actions, options) → {Promise.<MTX>}

Make a batch transaction with multiple actions.

Parameters:
Name Type Description
actions Array
options Object
Source:
Returns:
Type
Promise.<MTX>

(async) _createBid(name, value, lockup, options) → {MTX}

Create and finalize a bid MTX without a lock.

Parameters:
Name Type Description
name String
value Number
lockup Number
options Object
Source:
Returns:
Type
MTX

(async) _createCancel(name, options) → {MTX}

Create and finalize a cancel MTX without a lock.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
MTX

(async) _createClaim(name) → {Claim}

Make a claim MTX.

Parameters:
Name Type Description
name String
Source:
Returns:
Type
Claim

(async) _createFinalize(name, options) → {MTX}

Create and finalize a finalize MTX without a lock.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
MTX

(async, private) _createKey(acctnullable, branche) → {Promise}

Create a new address (increments depth) without a lock.

Parameters:
Name Type Attributes Description
acct Number | String <nullable>
branche Number
Source:
Returns:
  • Returns WalletKey.
Type
Promise

(async) _createOpen(name, options) → {Promise.<MTX>}

Create and finalize an open MTX without a lock.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
Promise.<MTX>

(async) _createRedeem(name, options) → {MTX}

Create and finalize a redeem MTX without a lock.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
MTX

(async) _createRedeemAll(options) → {MTX}

Create and finalize a redeem all MTX without a lock.

Parameters:
Name Type Description
options Object
Source:
Returns:
Type
MTX

(async) _createRenewal(name, options) → {MTX}

Create and finalize a renewal MTX without a lock.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
MTX

(async) _createReveal(name, options) → {MTX}

Create and finalize a reveal MTX without a lock.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
MTX

(async) _createRevealAll(options) → {MTX}

Create and finalize a reveal all MTX without a lock.

Parameters:
Name Type Description
options Object
Source:
Returns:
Type
MTX

(async) _createRevoke(name, options) → {MTX}

Create and finalize a revoke MTX without a lock.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
MTX

(async) _createTransfer(name, address, options) → {MTX}

Create and finalize a transfer MTX without a lock.

Parameters:
Name Type Description
name String
address Address
options Object
Source:
Returns:
Type
MTX

(async) _createTX(options) → {Promise.<MTX>}

Build a transaction, fill and finalize without a lock.

Parameters:
Name Type Description
options Object

See options.

Properties
Name Type Description
outputs Array.<Object>

See MTX#addOutput.

Source:
Returns:
  • MTX with populated inputs and outputs.
Type
Promise.<MTX>

(async) _createUpdate(name, resource, options) → {MTX}

Create and finalize an update MTX without a lock.

Parameters:
Name Type Description
name String
resource Resource
options Object
Source:
Returns:
Type
MTX

(async, private) _decrypt(passphrase) → {Promise}

Decrypt the wallet permanently, without a lock.

Parameters:
Name Type Description
passphrase String | Buffer
Source:
Returns:
Type
Promise

(async, private) _encrypt(passphrase) → {Promise}

Encrypt the wallet permanently, without a lock.

Parameters:
Name Type Description
passphrase String | Buffer
Source:
Returns:
Type
Promise

(async) _getNoncePublicKeys(address, value) → {Promise.<Array.<Buffer>>}

Get public keys at index based on address and value for nonce generation

Parameters:
Name Type Description
address Address
value Amount
Source:
Returns:

public keys

Type
Promise.<Array.<Buffer>>

(async) _getPendingAncestors(tx, set) → {Promise}

Get pending ancestors up to the policy limit.

Parameters:
Name Type Description
tx TX
set Object
Source:
Returns:
  • Returns {BufferSet} with Hash
Type
Promise

(async, private) _importAddress(acctnullable, ring, passphrasenullable) → {Promise}

Import a keyring (will not exist on derivation chain) without a lock.

Parameters:
Name Type Attributes Description
acct String | Number <nullable>
ring WalletKey
passphrase String | Buffer <nullable>
Source:
Returns:
Type
Promise

(async, private) _importKey(acctnullable, ring, passphrasenullable) → {Promise}

Import a keyring (will not exist on derivation chain) without a lock.

Parameters:
Name Type Attributes Description
acct String | Number <nullable>
ring WalletKey
passphrase String | Buffer <nullable>
Source:
Returns:
Type
Promise

(async, private) _importName(name) → {Promise}

Import a name without a lock.

Parameters:
Name Type Description
name String
Source:
Returns:
Type
Promise

(async, private) _makeRegister(name, resourcenullable, mtxnullable) → {MTX}

Make a register MTX.

Parameters:
Name Type Attributes Description
name String
resource Resource <nullable>
mtx MTX <nullable>
Source:
Returns:
Type
MTX

(async) _modifyAccount(acct, options, passphraseopt) → {Promise.<Account>}

Create an account without a lock.

Parameters:
Name Type Attributes Description
acct String | Number
options Object
passphrase String <optional>
Source:
Returns:
Type
Promise.<Account>

(async, private) _removeSharedKey(acct, key) → {Promise}

Remove a public account key from the wallet (multisig).

Parameters:
Name Type Description
acct Number | String
key HDPublicKey
Source:
Returns:
Type
Promise

(async, private) _renameAccount(acctnullable, name) → {Promise}

Rename account without a lock.

Parameters:
Name Type Attributes Description
acct String | Number <nullable>
name String
Source:
Returns:
Type
Promise

(async, private) _retoken(passphrasenullable) → {Promise}

Generate a new token without a lock.

Parameters:
Name Type Attributes Description
passphrase String | Buffer <nullable>
Source:
Returns:
Type
Promise

(async, private) _send(options) → {Promise}

Build and send a transaction without a lock.

Parameters:
Name Type Description
options Object

See options.

Properties
Name Type Description
outputs Array.<Object>

See MTX#addOutput.

Source:
Returns:
  • Returns TX.
Type
Promise

(async) _sendBatch(actions, options) → {TX}

Create and send a batch transaction with multiple actions.

Parameters:
Name Type Description
actions Array
options Object
Source:
Returns:
Type
TX

(async) _sendBid(name, value, lockup, options)

Create and send a bid MTX.

Parameters:
Name Type Description
name String
value Number
lockup Number
options Object
Source:

(async) _sendCancel(name, options)

Create and send a cancel MTX without a lock.

Parameters:
Name Type Description
name String
options Object
Source:

(async) _sendClaim(name, options)

Create and send a claim proof.

Parameters:
Name Type Description
name String
options Object
Source:

(async) _sendFakeClaim(name, options)

Create and send a claim proof.

Parameters:
Name Type Description
name String
options Object
Source:

(async) _sendFinalize(name, options)

Create and send a finalize MTX without a lock.

Parameters:
Name Type Description
name String
options Object
Source:

(async) _sendOpen(name, options) → {Promise.<TX>}

Create and send an open MTX without a lock.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
Promise.<TX>

(async) _sendRedeem(name, options)

Create and send a redeem MTX without a lock.

Parameters:
Name Type Description
name String
options Object
Source:

(async) _sendRedeemAll(options)

Create and send a redeem all MTX without a lock.

Parameters:
Name Type Description
options Object
Source:

(async) _sendRenewal(name, options)

Create and send a renewal MTX without a lock.

Parameters:
Name Type Description
name String
options Object
Source:

(async) _sendReveal(name, options)

Create and send a reveal MTX.

Parameters:
Name Type Description
name String
options Object
Source:

(async) _sendRevealAll(options)

Create and send a reveal all MTX.

Parameters:
Name Type Description
options Object
Source:

(async) _sendRevoke(name, options)

Create and send a revoke MTX without a lock.

Parameters:
Name Type Description
name String
options Object
Source:

(async) _sendTransfer(name, address, options)

Create and send a transfer MTX without a lock.

Parameters:
Name Type Description
name String
address Address
options Object
Source:

(async) _sendUpdate(name, resource, options)

Create and send an update MTX without a lock.

Parameters:
Name Type Description
name String
resource Resource
options Object
Source:

(async, private) _zap(acctnullable, age) → {Promise}

Zap stale TXs from wallet without a lock.

Parameters:
Name Type Attributes Description
acct Number | String <nullable>
age Number
Source:
Returns:
Type
Promise

(async) abandon(hash) → {Promise}

Abandon transaction.

Parameters:
Name Type Description
hash Hash
Source:
Returns:
Type
Promise

(async) accountKey(acctopt) → {HDPublicKey}

Get account key.

Parameters:
Name Type Attributes Default Description
acct Number <optional>
0
Source:
Returns:
Type
HDPublicKey

(async) add(tx, blockopt, extraopt) → {Promise.<?AddResult>}

Add a transaction to the wallets TX history.

Parameters:
Name Type Attributes Description
tx TX
block BlockMeta <optional>
extra BlockExtraInfo <optional>
Source:
Returns:
Type
Promise.<?AddResult>

(async) addSharedKey(acct, key) → {Promise}

Add a public account key to the wallet (multisig). Saves the key in the wallet database.

Parameters:
Name Type Description
acct Number | String
key HDPublicKey
Source:
Returns:
Type
Promise

(async) changeAddress(acctopt) → {Promise.<Address>}

Get current change address.

Parameters:
Name Type Attributes Default Description
acct Number <optional>
0
Source:
Returns:
Type
Promise.<Address>

(async) changeDepth(acctopt) → {Number}

Get current change depth.

Parameters:
Name Type Attributes Default Description
acct Number <optional>
0
Source:
Returns:
Type
Number

(async) changeKey(acctopt) → {WalletKey}

Get current change key.

Parameters:
Name Type Attributes Default Description
acct Number <optional>
0
Source:
Returns:
Type
WalletKey

(async) createAccount(options) → {Promise}

Create an account. Requires passphrase if master key is encrypted.

Parameters:
Name Type Description
options Object

See Account options.

Source:
Returns:
  • Returns Account.
Type
Promise

(async) createAuctionTXs(name, value, lockup, options) → {Object|MTX|MTX}

Create and finalize a bid & a reveal (in advance) MTX with a lock.

Parameters:
Name Type Description
name String
value Number
lockup Number
options Object
Source:
Returns:
  • output

    Type
    Object
  • output.bid

    Type
    MTX
  • output.reveal

    Type
    MTX

(async) createBatch(actions, options) → {MTX}

Make a batch transaction with multiple actions.

Parameters:
Name Type Description
actions Array
options Object
Source:
Returns:
Type
MTX

(async) createBid(name, value, lockup, options) → {MTX}

Create and finalize a bid MTX with a lock.

Parameters:
Name Type Description
name String
value Number
lockup Number
options Object
Source:
Returns:
Type
MTX

(async) createCancel(name, options) → {MTX}

Create and finalize a cancel MTX with a lock.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
MTX

createChange(acctnullable) → {Promise}

Create a new change address (increments changeDepth).

Parameters:
Name Type Attributes Default Description
acct Number | String <nullable>
0
Source:
Returns:
  • Returns WalletKey.
Type
Promise

(async) createClaim(name, options)

Create and send a claim MTX.

Parameters:
Name Type Description
name String
options Object
Source:

(async) createFinalize(name, options) → {MTX}

Create and finalize a finalize MTX with a lock.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
MTX

(async) createKey(acctnullable, branch) → {Promise}

Create a new address (increments depth).

Parameters:
Name Type Attributes Description
acct Number | String <nullable>
branch Number
Source:
Returns:
  • Returns WalletKey.
Type
Promise

(async) createOpen(name, options) → {Promise.<MTX>}

Create and finalize an open MTX with a lock.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
Promise.<MTX>

createReceive(acctnullable) → {Promise}

Create a new receiving address (increments receiveDepth).

Parameters:
Name Type Attributes Default Description
acct Number | String <nullable>
0
Source:
Returns:
  • Returns WalletKey.
Type
Promise

(async) createRedeem(name, options) → {MTX}

Create and finalize a redeem MTX with a lock.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
MTX

(async) createRedeemAll(options) → {MTX}

Create and finalize a redeem all MTX with a lock.

Parameters:
Name Type Description
options Object
Source:
Returns:
Type
MTX

(async) createRenewal(name, options) → {MTX}

Create and finalize a renewal MTX with a lock.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
MTX

(async) createReveal(name, options) → {MTX}

Create and finalize a reveal MTX with a lock.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
MTX

(async) createRevealAll(options) → {MTX}

Create and finalize a reveal all MTX with a lock.

Parameters:
Name Type Description
options Object
Source:
Returns:
Type
MTX

(async) createRevoke(name, options) → {MTX}

Create and finalize a revoke MTX with a lock.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
MTX

(async) createTransfer(name, address, options) → {MTX}

Create and finalize a transfer MTX with a lock.

Parameters:
Name Type Description
name String
address Address
options Object
Source:
Returns:
Type
MTX

(async) createTX(options) → {Promise}

Build a transaction, fill and finalize with a lock.

Parameters:
Name Type Description
options Object

See options.

Properties
Name Type Description
outputs Array.<Object>

See MTX#addOutput.

Source:
Returns:
  • Returns MTX.
Type
Promise

(async) createUpdate(name, resource, options) → {MTX}

Create and finalize an update MTX with a lock.

Parameters:
Name Type Description
name String
resource Resource
options Object
Source:
Returns:
Type
MTX

(private) decode(data)

Inject properties from serialized data.

Parameters:
Name Type Description
data Buffer
Source:

(async) decrypt(passphrase) → {Promise}

Decrypt the wallet permanently.

Parameters:
Name Type Description
passphrase String | Buffer
Source:
Returns:
Type
Promise

(async) deriveInputs(mtx, indexnullable) → {Promise}

Derive necessary addresses for signing a transaction.

Parameters:
Name Type Attributes Description
mtx MTX
index Number <nullable>

Input index.

Source:
Returns:
  • Returns WalletKey[].
Type
Promise

(async) destroy() → {Promise}

Close the wallet, unregister with the database.

Source:
Returns:
Type
Promise

encode() → {Buffer}

Serialize the wallet.

Source:
Returns:
Type
Buffer

(async) encrypt(passphrase) → {Promise}

Encrypt the wallet permanently.

Parameters:
Name Type Description
passphrase String | Buffer
Source:
Returns:
Type
Promise

(async) ensureAccount(options) → {Promise}

Ensure an account. Requires passphrase if master key is encrypted.

Parameters:
Name Type Description
options Object

See Account options.

Source:
Returns:
  • Returns Account.
Type
Promise

(async) ensureIndex(acct) → {Promise}

Lookup the corresponding account name's index.

Parameters:
Name Type Description
acct String | Number

Account name/index.

Source:
Throws:

on non-existent account

Returns:
  • Returns Number.
Type
Promise

(async) estimateSize(addr) → {Promise.<Number>}

Estimate witness size given output address. Unlike Bitcoin, our signatures are always 65 bytes. However, we still assume that the witness varInt size is only one byte. In short, this estimate may be off by 2 (at most) but only if a witness has > 253 items. Also note we are only processing the witness data here, which will be scaled down by WITNESS_SCALE_FACTOR to compute vsize. Input data like prevout and sequence count as base data and must be added in outside this function.

Parameters:
Name Type Description
addr Address
Source:
Returns:
Type
Promise.<Number>

(async, private) fill()

Fill a transaction with inputs without a lock.

Source:
See:
  • MTX#selectCoins
  • MTX#fill

(async) finalize(mtx, options) → {Promise.<MTX>}

Finalize and template an MTX.

Parameters:
Name Type Description
mtx MTX
options Object
Source:
Returns:
Type
Promise.<MTX>

format() → {Object}

Convert the wallet to a more inspection-friendly object.

Source:
Returns:
Type
Object

(private) fromOptions(options)

Inject properties from options object.

Parameters:
Name Type Description
options Object
Source:

(async) fund(mtx, optionsnullable)

Fill a transaction with inputs, estimate transaction size, calculate fee, and add a change output.

Parameters:
Name Type Attributes Description
mtx MTX

Must be a mutable transaction.

options Object <nullable>
Properties
Name Type Attributes Description
account String | Number <nullable>

If no account is specified, coins from the entire wallet will be filled.

selection String <nullable>

Coin selection priority. Can be age, random, or all. (default=age).

round Boolean

Whether to round to the nearest kilobyte for fee calculation. See TX#getMinFee vs. TX#getRoundFee.

rate Rate

Rate used for fee calculation.

confirmed Boolean

Select only confirmed coins.

free Boolean

Do not apply a fee if the transaction priority is high enough to be considered free.

hardFee Amount <nullable>

Use a hard fee rather than calculating one.

subtractFee Number | Boolean

Whether to subtract the fee from existing outputs rather than adding more inputs.

Source:
See:
  • MTX#selectCoins
  • MTX#fill

(async) generateBlind(nameHash, address, value) → {Promise.<Buffer>}

Generate nonce & blind, save nonce.

Parameters:
Name Type Description
nameHash Buffer
address Address
value Amount
Source:
Returns:
Type
Promise.<Buffer>

(async) generateBlinds(nameHash, address, value) → {Promise.<Array.<Buffer>>}

Generate all nonces & blinds, save nonces.

Parameters:
Name Type Description
nameHash Buffer
address Address
value Amount
Source:
Returns:
Type
Promise.<Array.<Buffer>>

(async) generateNonce(nameHash, address, value) → {Promise.<Buffer>}

Generate nonce deterministically based on address (smallest pubkey), name hash, and bid value.

Parameters:
Name Type Description
nameHash Buffer
address Address
value Amount
Source:
Returns:
Type
Promise.<Buffer>

(async) generateNonces(nameHash, address, value) → {Promise.<Array.<Buffer>>}

Generate nonces deterministically for all keys (in multisig).

Parameters:
Name Type Description
nameHash Buffer
address Address
value Amount
Source:
Returns:
Type
Promise.<Array.<Buffer>>

(async) getAccount(acct) → {Promise.<Account>}

Retrieve an account from the database.

Parameters:
Name Type Description
acct Number | String
Source:
Returns:
Type
Promise.<Account>

(async) getAccountByAddress(address) → {Promise.<?Account>}

Get account by address.

Parameters:
Name Type Description
address Address
Source:
Returns:
Type
Promise.<?Account>

(async) getAccountHashes(acct) → {Promise}

Get all account address hashes.

Parameters:
Name Type Description
acct String | Number
Source:
Returns:
  • Returns Array.
Type
Promise

getAccountIndex(acct) → {Promise}

Lookup the corresponding account name's index.

Parameters:
Name Type Description
acct String | Number

Account name/index.

Source:
Returns:
  • Returns Number.
Type
Promise

(async) getAccountName(index) → {Promise}

Lookup the corresponding account index's name.

Parameters:
Name Type Description
index Number

Account index.

Source:
Returns:
  • Returns String.
Type
Promise

(async) getAccountPaths(acct) → {Promise}

Get all account paths.

Parameters:
Name Type Description
acct String | Number
Source:
Returns:
  • Returns Path.
Type
Promise

getAccounts() → {Promise}

List account names and indexes from the db.

Source:
Returns:
  • Returns Array.
Type
Promise

getAddressHashes(acctnullable) → {Promise}

Get all wallet address hashes.

Parameters:
Name Type Attributes Description
acct String | Number <nullable>
Source:
Returns:
  • Returns Array.
Type
Promise

(async) getBalance(acctnullable) → {Promise}

Get wallet balance.

Parameters:
Name Type Attributes Description
acct String | Number <nullable>
Source:
Returns:
  • Returns Balance.
Type
Promise

(async) getBid(nameHash, outpoint) → {Promise.<?BlindBid>}

Get bid

Parameters:
Name Type Description
nameHash Buffer
outpoint Outpoint
Source:
Returns:
Type
Promise.<?BlindBid>

(async) getBidByReveal(nameHash, outpoint) → {Promise.<?BlindBid>}

Get bid by reveal.

Parameters:
Name Type Description
nameHash Buffer
outpoint Outpoint

reveal outpoint

Source:
Returns:
Type
Promise.<?BlindBid>

(async) getBids(nameHash) → {Promise.<Array.<BlindBid>>}

Get all bids for name.

Parameters:
Name Type Description
nameHash Buffer
Source:
Returns:
Type
Promise.<Array.<BlindBid>>

(async) getBidsByName(name) → {Array.<BlindBid>}

Get all bids for name.

Parameters:
Name Type Description
name String | Buffer
Source:
Returns:
Type
Array.<BlindBid>

(async) getBlind(blind) → {BlindValue}

Get a blind value if present.

Parameters:
Name Type Description
blind Buffer

Blind hash.

Source:
Returns:
Type
BlindValue

getBlock(height) → {Promise}

Get a block from the wallet.

Parameters:
Name Type Description
height Number
Source:
Returns:
  • Returns BlockRecord.
Type
Promise

getBlocks() → {Promise}

List blocks for the wallet.

Source:
Returns:
  • Returns BlockRecord.
Type
Promise

getCoin(hash, index) → {Promise}

Get a coin from the wallet.

Parameters:
Name Type Description
hash Hash
index Number
Source:
Returns:
  • Returns Coin.
Type
Promise

(async) getCoins(accountnullable) → {Promise}

Get all available coins.

Parameters:
Name Type Attributes Description
account String | Number <nullable>
Source:
Returns:
  • Returns Coin[].
Type
Promise

getCoinView(tx) → {Promise}

Get a coin viewpoint.

Parameters:
Name Type Description
tx TX
Source:
Returns:
  • Returns CoinView.
Type
Promise

getCredit(hash, index) → {Promise.<Credit>}

Get credit from the wallet.

Parameters:
Name Type Description
hash Hash
index Number
Source:
Returns:
Type
Promise.<Credit>

(async) getCredits(accountnullable) → {Promise}

Get all available credits.

Parameters:
Name Type Attributes Description
account String | Number <nullable>
Source:
Returns:
  • Returns Credit[].
Type
Promise

getDetails(hash) → {Promise}

Get transaction details.

Parameters:
Name Type Description
hash Hash
Source:
Returns:
  • Returns Details.
Type
Promise

(private) getID() → {Base58String}

Generate the wallet ID if none was passed in. It is represented as BLAKE2b(m/44->public|magic, 20) converted to an "address" with a prefix of 0x03be04 (WLT in base58).

Source:
Returns:
Type
Base58String

(async) getInputPaths(mtx) → {Promise}

Map input addresses to paths.

Parameters:
Name Type Description
mtx MTX
Source:
Returns:
  • Returns Path[].
Type
Promise

getJSON(unsafenullable) → {Object}

Convert the wallet to an object suitable for serialization.

Parameters:
Name Type Attributes Description
unsafe Boolean <nullable>

Whether to include the master key in the JSON.

Source:
Returns:
Type
Object

(async) getKey(hash) → {Promise}

Retrieve a single keyring by address.

Parameters:
Name Type Description
hash Address | Hash
Source:
Returns:
Type
Promise

getLocked() → {Array.<Outpoint>}

Return an array of all locked outpoints.

Source:
Returns:
Type
Array.<Outpoint>

(async) getNames() → {Promise.<Array.<NameState>>}

Get all names.

Source:
Returns:
Type
Promise.<Array.<NameState>>

(async) getNameState(nameHash) → {NameState}

Get a name if present.

Parameters:
Name Type Description
nameHash Buffer
Source:
Returns:
Type
NameState

(async) getNameStateByName(name) → {NameState}

Get a name if present.

Parameters:
Name Type Description
name String | Buffer
Source:
Returns:
Type
NameState

(async) getOutputPaths(tx) → {Promise}

Map output addresses to paths.

Parameters:
Name Type Description
tx TX
Source:
Returns:
  • Returns Path[].
Type
Promise

(async) getPath(address) → {Promise}

Get path by address hash.

Parameters:
Name Type Description
address Address | Hash
Source:
Returns:
  • Returns Path.
Type
Promise

(async) getPaths(acctnullable) → {Promise}

Get all wallet paths.

Parameters:
Name Type Attributes Description
acct String | Number <nullable>
Source:
Returns:
  • Returns Path.
Type
Promise

(async) getPending(acctnullable) → {Promise}

Get all pending/unconfirmed transactions.

Parameters:
Name Type Attributes Description
acct String | Number <nullable>
Source:
Returns:
  • Returns TX[].
Type
Promise

(async) getPendingAncestors(tx) → {Promise}

Get pending ancestors up to the policy limit

Parameters:
Name Type Description
tx TX
Source:
Returns:
  • Returns {BufferSet} with Hash
Type
Promise

(async) getPrivateKey(hash, passphrasenullable) → {Promise}

Retrieve a single keyring by address (with the private key reference).

Parameters:
Name Type Attributes Description
hash Address | Hash
passphrase Buffer | String <nullable>
Source:
Returns:
Type
Promise

(async) getReveal(nameHash, outpoint) → (nullable) {BidReveal}

Get reveal.

Parameters:
Name Type Description
nameHash Buffer
outpoint Outpoint
Source:
Returns:
Type
BidReveal

(async) getRevealByBid(nameHash, outpoint) → {Promise.<?BlindReveal>}

Get reveal for bid.

Parameters:
Name Type Description
nameHash Buffer
outpoint Outpoint

bid outpoint

Source:
Returns:
Type
Promise.<?BlindReveal>

(async) getReveals(nameHash) → {Array.<BidReveal>}

Get all reveals by name.

Parameters:
Name Type Description
nameHash Buffer
Source:
Returns:
Type
Array.<BidReveal>

(async) getRevealsByName(name) → {Array.<BidReveal>}

Get all reveals by name.

Parameters:
Name Type Description
name String
Source:
Returns:
Type
Array.<BidReveal>

getSize() → {Number}

Calculate serialization size.

Source:
Returns:
Type
Number

(async) getSmartCoins(accountnullable) → {Promise}

Get "smart" coins.

Parameters:
Name Type Attributes Description
account String | Number <nullable>
Source:
Returns:
  • Returns Coin[].
Type
Promise

getSpentView(tx) → {Promise}

Get a historical coin viewpoint.

Parameters:
Name Type Description
tx TX
Source:
Returns:
  • Returns CoinView.
Type
Promise

(private) getToken(master, nonce) → {Buffer}

Generate the wallet api key if none was passed in. It is represented as BLAKE2b(m/44'->private|nonce).

Parameters:
Name Type Description
master HDPrivateKey
nonce Number
Source:
Returns:
Type
Buffer

getTX(hash) → {Promise}

Get a transaction from the wallet.

Parameters:
Name Type Description
hash Hash
Source:
Returns:
  • Returns TX.
Type
Promise

(async) getUnspentCoin(hash, index) → {Promise}

Get an unspent coin from the wallet.

Parameters:
Name Type Description
hash Hash
index Number
Source:
Returns:
  • Returns Coin.
Type
Promise

(async) getWalletCoinView(tx, viewnullable) → {Promise}

Get a wallet coin viewpoint with HD paths.

Parameters:
Name Type Attributes Description
tx TX
view CoinView <nullable>

Coins to be used in wallet coin viewpoint.

Source:
Returns:
  • Returns WalletCoinView.
Type
Promise

(async) hasAccount(acct) → {Promise}

Test whether an account exists.

Parameters:
Name Type Description
acct Number | String
Source:
Returns:
  • Returns Boolean.
Type
Promise

(async) hasAddress(address) → {Promise}

Test whether the wallet possesses an address.

Parameters:
Name Type Description
address Address | Hash
Source:
Returns:
  • Returns Boolean.
Type
Promise

(async) hasPath(address) → {Promise}

Test whether the wallet contains a path.

Parameters:
Name Type Description
address Address | Hash
Source:
Returns:
  • Returns {Boolean}.
Type
Promise

hasPending(hash) → {Promise}

Test whether the database has a pending transaction.

Parameters:
Name Type Description
hash Hash
Source:
Returns:
  • Returns Boolean.
Type
Promise

(async) importAddress(acctnullable, ring, passphrasenullable) → {Promise}

Import a keyring (will not exist on derivation chain). Rescanning must be invoked manually.

Parameters:
Name Type Attributes Description
acct String | Number <nullable>
ring WalletKey
passphrase String | Buffer <nullable>
Source:
Returns:
Type
Promise

(async) importKey(acctnullable, ring, passphrasenullable) → {Promise}

Import a keyring (will not exist on derivation chain). Rescanning must be invoked manually.

Parameters:
Name Type Attributes Description
acct String | Number <nullable>
ring WalletKey
passphrase String | Buffer <nullable>
Source:
Returns:
Type
Promise

(async) importName(name) → {Promise}

Import a name. Rescanning must be invoked manually.

Parameters:
Name Type Description
name String
Source:
Returns:
Type
Promise

(async) increaseFee(hash, rate, passphrasenullable) → {Promise}

Intentionally double-spend outputs by increasing fee for an existing transaction.

Parameters:
Name Type Attributes Description
hash Hash
rate Rate
passphrase String | Buffer <nullable>
Source:
Returns:
  • Returns TX.
Type
Promise

increment() → {Promise}

Increment the wid depth.

Source:
Returns:
Type
Promise

(async) init() → {Promise}

Attempt to intialize the wallet (generating the first addresses along with the lookahead addresses). Called automatically from the walletdb.

Source:
Returns:
Type
Promise

inspect() → {Object}

Convert the wallet to a more inspection-friendly object.

Source:
Returns:
Type
Object

isLocked(coin)

Test locked status of a single coin.

Parameters:
Name Type Description
coin Coin | Outpoint
Source:

isOversizedBatch(mtx, witnessSize) → {Boolean}

Check batch MTX for excessive size

Parameters:
Name Type Description
mtx MTX
witnessSize Number
Source:
Returns:
Type
Boolean

(async) listHistory(acctopt, options) → {Promise.<Array.<TXRecord>>}

Parameters:
Name Type Attributes Description
acct String | Number <optional>
options Object
Properties
Name Type Description
limit Number
reverse Boolean
Source:
Returns:
Type
Promise.<Array.<TXRecord>>

(async) listHistoryAfter(acctopt, options) → {Promise.<Array.<TXRecord>>}

Parameters:
Name Type Attributes Description
acct String | Number <optional>
options Object
Properties
Name Type Description
hash String
limit Number
reverse Boolean
Source:
Returns:
Type
Promise.<Array.<TXRecord>>

(async) listHistoryByTime(acctopt, options) → {Promise.<Array.<TXRecord>>}

Parameters:
Name Type Attributes Description
acct String | Number <optional>
options Object
Properties
Name Type Description
time Number

Time in seconds.

limit Number
reverse Boolean
Source:
Returns:
Type
Promise.<Array.<TXRecord>>

(async) listHistoryFrom(acctopt, options) → {Promise.<Array.<TXRecord>>}

Parameters:
Name Type Attributes Description
acct String | Number <optional>
options Object
Properties
Name Type Description
hash String
limit Number
reverse Boolean
Source:
Returns:
Type
Promise.<Array.<TXRecord>>

(async) listUnconfirmed(acctopt, options) → {Promise.<Array.<TXRecord>>}

Parameters:
Name Type Attributes Description
acct String | Number <optional>
options Object
Properties
Name Type Description
limit Number
reverse Boolean
Source:
Returns:
Type
Promise.<Array.<TXRecord>>

(async) listUnconfirmedAfter(acctopt, options) → {Promise.<Array.<TXRecord>>}

Parameters:
Name Type Attributes Description
acct String | Number <optional>
options Object
Properties
Name Type Description
hash Buffer
limit Number
reverse Boolean
Source:
Returns:
Type
Promise.<Array.<TXRecord>>

(async) listUnconfirmedByTime(acctopt, options) → {Promise.<Array.<TXRecord>>}

Parameters:
Name Type Attributes Description
acct String | Number <optional>
options Object
Properties
Name Type Description
time Number

Time in seconds.

limit Number
reverse Boolean
Source:
Returns:
Type
Promise.<Array.<TXRecord>>

(async) listUnconfirmedFrom(acctopt, options) → {Promise.<Array.<TXRecord>>}

Parameters:
Name Type Attributes Description
acct String | Number <optional>
options Object
Properties
Name Type Description
hash Buffer
limit Number
reverse Boolean
Source:
Returns:
Type
Promise.<Array.<TXRecord>>

(async) lock()

Lock the wallet, destroy decrypted key.

Source:

lockCoin(coin)

Lock a single coin.

Parameters:
Name Type Description
coin Coin | Outpoint
Source:

(async) makeBatch(actions, options) → {Promise.<MTX>}

Make a batch transaction with multiple actions.

Parameters:
Name Type Description
actions Array
options Object
Source:
Returns:
Type
Promise.<MTX>

(async) makeBid(name, value, lockup, acct, mtxnullable, addrnullable) → {Promise.<MTX>}

Make a bid MTX.

Parameters:
Name Type Attributes Description
name String
value Number
lockup Number
acct Number | String
mtx MTX <nullable>
addr Address <nullable>
Source:
Returns:
Type
Promise.<MTX>

(async, private) makeCancel(name, acctnullable, mtxnullable) → {Promise.<MTX>}

Make a transfer-cancelling MTX.

Parameters:
Name Type Attributes Description
name String
acct Number | String <nullable>
mtx MTX <nullable>
Source:
Returns:
Type
Promise.<MTX>

(async) makeClaim(name, options) → {Claim}

Make a claim proof.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
Claim

(async) makeFakeClaim(name, options) → {Claim}

Make a claim proof.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
Claim

(async, private) makeFinalize(name, acctnullable, mtxnullable) → {Promise.<MTX>}

Make a transfer-finalizing MTX.

Parameters:
Name Type Attributes Description
name String
acct Number | String <nullable>
mtx MTX <nullable>
Source:
Returns:
Type
Promise.<MTX>

(async, private) makeFinalizeAll(mtxnullable, witnessSizenullable) → {Promise.<MTX>}

Make a finazling MTX for all transferring names

Parameters:
Name Type Attributes Description
mtx MTX <nullable>
witnessSize Number <nullable>
Source:
Returns:
Type
Promise.<MTX>

(async) makeOpen(name, acct, mtxnullable) → {Promise.<MTX>}

Make a open MTX.

Parameters:
Name Type Attributes Description
name String
acct Number | String
mtx MTX <nullable>
Source:
Returns:
Type
Promise.<MTX>

(async) makeRedeem(name, acctnullable, mtxnullable) → {Promise.<MTX>}

Make a redeem MTX.

Parameters:
Name Type Attributes Description
name String
acct Number | String <nullable>
mtx MTX <nullable>
Source:
Returns:
Type
Promise.<MTX>

(async) makeRedeemAll(name, mtxnullable, witnessSizenullable) → {Promise.<MTX>}

Make a redeem MTX.

Parameters:
Name Type Attributes Description
name String
mtx MTX <nullable>
witnessSize Number <nullable>
Source:
Returns:
Type
Promise.<MTX>

(async, private) makeRenewal(name, acctnullable, mtxnullable) → {Promise.<MTX>}

Make a renewal MTX.

Parameters:
Name Type Attributes Description
name String
acct Number | String <nullable>
mtx MTX <nullable>
Source:
Returns:
Type
Promise.<MTX>

(async) makeRenewalAll(mtxnullable, witnessSizenullable) → {Promise.<MTX>}

Make a renewal MTX for all expiring names.

Parameters:
Name Type Attributes Description
mtx MTX <nullable>
witnessSize Number <nullable>
Source:
Returns:
Type
Promise.<MTX>

(async) makeReveal(name, acctnullable, mtxnullable) → {Promise.<MTX>}

Make a reveal MTX.

Parameters:
Name Type Attributes Description
name String
acct Number | String <nullable>
mtx MTX <nullable>
Source:
Returns:
Type
Promise.<MTX>

(async) makeRevealAll(mtxnullable, witnessSizenullable) → {Promise.<MTX>}

Make a reveal MTX.

Parameters:
Name Type Attributes Description
mtx MTX <nullable>
witnessSize Number <nullable>
Source:
Returns:
Type
Promise.<MTX>

(async) makeRevoke(name, acctnullable, mtxnullable) → {Promise.<MTX>}

Make a revoke MTX.

Parameters:
Name Type Attributes Description
name String
acct Number | String <nullable>
mtx MTX <nullable>
Source:
Returns:
Type
Promise.<MTX>

(async) makeTransfer(name, address, acctnullable, mtxnullable) → {Promise.<MTX>}

Make a transfer MTX.

Parameters:
Name Type Attributes Description
name String
address Address
acct Number | String <nullable>
mtx MTX <nullable>
Source:
Returns:
Type
Promise.<MTX>

makeTX(outputs, mtxopt) → {MTX}

Make a transaction with normal outputs.

Parameters:
Name Type Attributes Default Description
outputs Array.<Object>

See MTX#addOutput

mtx MTX <optional>
null

MTX to modify instead of new one.

Source:
Returns:
  • MTX with populated outputs.
Type
MTX

(async) makeUpdate(name, resource, acctnullable, mtxnullable) → {Promise.<MTX>}

Make an update MTX.

Parameters:
Name Type Attributes Description
name String
resource Resource
acct Number | String <nullable>
mtx MTX <nullable>
Source:
Returns:
Type
Promise.<MTX>

(async) modifyAccount(acct, options, passphraseopt) → {Promise.<Account>}

Modify an account. Requires passphrase if master key is encrypted.

Parameters:
Name Type Attributes Description
acct String | Number
options Object
passphrase String <optional>
Source:
Returns:
Type
Promise.<Account>

(async) open() → {Promise}

Open wallet (done after retrieval).

Source:
Returns:
Type
Promise

(async, private) readPath(address) → {Promise}

Get path by address hash (without account name).

Parameters:
Name Type Description
address Address | Hash
Source:
Returns:
  • Returns Path.
Type
Promise

(async) recalculateBalances() → {Promise}

Recalculate balances

Source:
Returns:
Type
Promise

(async) receiveAddress(acctopt) → {Promise.<Address>}

Get current receive address.

Parameters:
Name Type Attributes Default Description
acct String | Number <optional>
0
Source:
Returns:
Type
Promise.<Address>

(async) receiveDepth(acctopt) → {Number}

Get current receive depth.

Parameters:
Name Type Attributes Default Description
acct Number <optional>
0
Source:
Returns:
Type
Number

(async) receiveKey(acctopt) → {WalletKey}

Get current receive key.

Parameters:
Name Type Attributes Default Description
acct Number <optional>
0
Source:
Returns:
Type
WalletKey

(async) remove(hash) → {Promise}

Remove a wallet transaction.

Parameters:
Name Type Description
hash Hash
Source:
Returns:
Type
Promise

(async) removeSharedKey(acct, key) → {Promise}

Remove a public account key from the wallet (multisig).

Parameters:
Name Type Description
acct Number | String
key HDPublicKey
Source:
Returns:
Type
Promise

(async) rename(id) → {Promise}

Rename the wallet.

Parameters:
Name Type Description
id String
Source:
Returns:
Type
Promise

(async) renameAccount(acctnullable, name) → {Promise}

Rename account.

Parameters:
Name Type Attributes Description
acct String | Number <nullable>
name String
Source:
Returns:
Type
Promise

(async) resend() → {Promise}

Resend pending wallet transactions.

Source:
Returns:
Type
Promise

(async) retoken(passphrasenullable) → {Promise}

Generate a new token.

Parameters:
Name Type Attributes Description
passphrase String | Buffer <nullable>
Source:
Returns:
Type
Promise

(async) revert(height) → {Promise.<Number>}

Revert a block.

Parameters:
Name Type Description
height Number
Source:
Returns:
  • number of txs removed.
Type
Promise.<Number>

save() → {Promise}

Save the wallet to the database. Necessary when address depth and keys change.

Source:
Returns:
Type
Promise

(async) send(options) → {Promise}

Build a transaction, fill it with outputs and inputs, sort the members according to BIP69, set locktime, sign and broadcast. Doing this all in one go prevents coins from being double spent.

Parameters:
Name Type Description
options Object

See options.

Properties
Name Type Description
outputs Array.<Object>

See MTX#addOutput.

Source:
Returns:
  • Returns TX.
Type
Promise

(async) sendBatch(actions, options) → {TX}

Create and send a batch transaction with multiple actions.

Parameters:
Name Type Description
actions Array
options Object
Source:
Returns:
Type
TX

(async) sendBid(name, value, lockup, options)

Create and send a bid MTX.

Parameters:
Name Type Description
name String
value Number
lockup Number
options Object
Source:

(async) sendCancel(name, options)

Create and send a cancel MTX with a lock.

Parameters:
Name Type Description
name String
options Object
Source:

(async) sendClaim(name, options)

Create and send a claim proof.

Parameters:
Name Type Description
name String
options Object
Source:

(async) sendFakeClaim(name, options)

Create and send a claim proof.

Parameters:
Name Type Description
name String
options Object
Source:

(async) sendFinalize(name, options)

Create and send a finalize MTX with a lock.

Parameters:
Name Type Description
name String
options Object
Source:

(async) sendMTX(mtx, passphrase) → {Promise.<TX>}

Sign and send a (templated) mutable transaction.

Parameters:
Name Type Description
mtx MTX
passphrase String
Source:
Returns:
Type
Promise.<TX>

(async) sendOpen(name, options) → {Promise.<TX>}

Create and send an open MTX with a lock.

Parameters:
Name Type Description
name String
options Object
Source:
Returns:
Type
Promise.<TX>

(async) sendRedeem(name, options)

Create and send a redeem MTX with a lock.

Parameters:
Name Type Description
name String
options Object
Source:

(async) sendRedeemAll(options)

Create and send a redeem all MTX with a lock.

Parameters:
Name Type Description
options Object
Source:

(async) sendRenewal(name, options)

Create and send a renewal MTX with a lock.

Parameters:
Name Type Description
name String
options Object
Source:

(async) sendReveal(name, options)

Create and send a bid MTX.

Parameters:
Name Type Description
name String
options Object
Source:

(async) sendRevealAll(options)

Create and send a bid MTX.

Parameters:
Name Type Description
options Object
Source:

(async) sendRevoke(name, options)

Create and send a revoke MTX with a lock.

Parameters:
Name Type Description
name String
options Object
Source:

(async) sendTransfer(name, address, options)

Create and send a transfer MTX with a lock.

Parameters:
Name Type Description
name String
address Address
options Object
Source:

(async) sendUpdate(name, resource, options)

Create and send an update MTX with a lock.

Parameters:
Name Type Description
name String
resource Resource
options Object
Source:

(async) setPassphrase(passphrase, old) → {Promise}

Change or set master key's passphrase.

Parameters:
Name Type Description
passphrase String | Buffer
old String | Buffer
Source:
Returns:
Type
Promise

(async) sign(tx, options) → {Promise}

Build input scripts and sign inputs for a transaction. Only attempts to build/sign inputs that are redeemable by this wallet.

Parameters:
Name Type Description
tx MTX
options Object | String | Buffer

Options or passphrase.

Source:
Returns:
  • Returns Number (total number of inputs scripts built and signed).
Type
Promise

(async) syncOutputDepth(tx) → {Promise.<Array.<WalletKey>>}

Sync address depths based on a transaction's outputs. This is used for deriving new addresses when a confirmed transaction is seen.

Parameters:
Name Type Description
tx TX
Source:
Returns:
  • derived rings.
Type
Promise.<Array.<WalletKey>>

(async) template(mtx) → {Promise}

Build input scripts templates for a transaction (does not sign, only creates signature slots). Only builds scripts for inputs that are redeemable by this wallet.

Parameters:
Name Type Description
mtx MTX
Source:
Returns:
  • Returns Number (total number of scripts built).
Type
Promise

toDetails(wtx) → {Promise}

Convert transaction to transaction details.

Parameters:
Name Type Description
wtx TXRecord
Source:
Returns:
  • Returns Details.
Type
Promise

toJSON(unsafenullable) → {Object}

Convert the wallet to an object suitable for serialization.

Parameters:
Name Type Attributes Description
unsafe Boolean <nullable>

Whether to include the master key in the JSON.

Source:
Returns:
Type
Object

unlock(passphrase, timeoutopt, nullable)

Unlock the key for timeout seconds.

Parameters:
Name Type Attributes Default Description
passphrase Buffer | String
timeout Number <optional>
<nullable>
60
Source:

unlockCoin(coin)

Unlock a single coin.

Parameters:
Name Type Description
coin Coin | Outpoint
Source:

unlockCoins()

Unlock all locked coins.

Source:

(async) zap(acctnullable, age) → {Promise}

Zap stale TXs from wallet.

Parameters:
Name Type Attributes Description
acct Number | String <nullable>
age Number

Age threshold (unix time, default=72 hours).

Source:
Returns:
Type
Promise