You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1076 lines
40 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: wallet/account.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: wallet/account.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/*!
* account.js - account object for bcoin
* Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
var util = require('../utils/util');
var co = require('../utils/co');
var assert = require('assert');
var BufferReader = require('../utils/reader');
var StaticWriter = require('../utils/staticwriter');
var encoding = require('../utils/encoding');
var Path = require('./path');
var common = require('./common');
var Script = require('../script/script');
var WalletKey = require('./walletkey');
var HD = require('../hd/hd');
/**
* Represents a BIP44 Account belonging to a {@link Wallet}.
* Note that this object does not enforce locks. Any method
* that does a write is internal API only and will lead
* to race conditions if used elsewhere.
* @alias module:wallet.Account
* @constructor
* @param {Object} options
* @param {WalletDB} options.db
* @param {HDPublicKey} options.accountKey
* @param {Boolean?} options.witness - Whether to use witness programs.
* @param {Number} options.accountIndex - The BIP44 account index.
* @param {Number?} options.receiveDepth - The index of the _next_ receiving
* address.
* @param {Number?} options.changeDepth - The index of the _next_ change
* address.
* @param {String?} options.type - Type of wallet (pubkeyhash, multisig)
* (default=pubkeyhash).
* @param {Number?} options.m - `m` value for multisig.
* @param {Number?} options.n - `n` value for multisig.
* @param {String?} options.wid - Wallet ID
* @param {String?} options.name - Account name
*/
function Account(db, options) {
if (!(this instanceof Account))
return new Account(db, options);
assert(db, 'Database is required.');
this.db = db;
this.network = db.network;
this.wallet = null;
this.receive = null;
this.change = null;
this.nested = null;
this.wid = 0;
this.id = null;
this.name = null;
this.initialized = false;
this.witness = this.db.options.witness === true;
this.watchOnly = false;
this.type = Account.types.PUBKEYHASH;
this.m = 1;
this.n = 1;
this.accountIndex = 0;
this.receiveDepth = 0;
this.changeDepth = 0;
this.nestedDepth = 0;
this.lookahead = 10;
this.accountKey = null;
this.keys = [];
if (options)
this.fromOptions(options);
}
/**
* Account types.
* @enum {Number}
* @default
*/
Account.types = {
PUBKEYHASH: 0,
MULTISIG: 1
};
/**
* Account types by value.
* @const {RevMap}
*/
Account.typesByVal = {
0: 'pubkeyhash',
1: 'multisig'
};
/**
* Inject properties from options object.
* @private
* @param {Object} options
*/
Account.prototype.fromOptions = function fromOptions(options) {
var i;
assert(options, 'Options are required.');
assert(util.isNumber(options.wid));
assert(common.isName(options.id), 'Bad Wallet ID.');
assert(HD.isHD(options.accountKey), 'Account key is required.');
assert(util.isNumber(options.accountIndex), 'Account index is required.');
this.wid = options.wid;
this.id = options.id;
if (options.name != null) {
assert(common.isName(options.name), 'Bad account name.');
this.name = options.name;
}
if (options.initialized != null) {
assert(typeof options.initialized === 'boolean');
this.initialized = options.initialized;
}
if (options.witness != null) {
assert(typeof options.witness === 'boolean');
this.witness = options.witness;
}
if (options.watchOnly != null) {
assert(typeof options.watchOnly === 'boolean');
this.watchOnly = options.watchOnly;
}
if (options.type != null) {
if (typeof options.type === 'string') {
this.type = Account.types[options.type.toUpperCase()];
assert(this.type != null);
} else {
assert(typeof options.type === 'number');
this.type = options.type;
assert(Account.typesByVal[this.type]);
}
}
if (options.m != null) {
assert(util.isNumber(options.m));
this.m = options.m;
}
if (options.n != null) {
assert(util.isNumber(options.n));
this.n = options.n;
}
if (options.accountIndex != null) {
assert(util.isNumber(options.accountIndex));
this.accountIndex = options.accountIndex;
}
if (options.receiveDepth != null) {
assert(util.isNumber(options.receiveDepth));
this.receiveDepth = options.receiveDepth;
}
if (options.changeDepth != null) {
assert(util.isNumber(options.changeDepth));
this.changeDepth = options.changeDepth;
}
if (options.nestedDepth != null) {
assert(util.isNumber(options.nestedDepth));
this.nestedDepth = options.nestedDepth;
}
if (options.lookahead != null) {
assert(util.isNumber(options.lookahead));
assert(options.lookahead >= 0);
assert(options.lookahead &lt;= Account.MAX_LOOKAHEAD);
this.lookahead = options.lookahead;
}
this.accountKey = options.accountKey;
if (this.n > 1)
this.type = Account.types.MULTISIG;
if (!this.name)
this.name = this.accountIndex + '';
if (this.m &lt; 1 || this.m > this.n)
throw new Error('m ranges between 1 and n');
if (options.keys) {
assert(Array.isArray(options.keys));
for (i = 0; i &lt; options.keys.length; i++)
this.pushKey(options.keys[i]);
}
return this;
};
/**
* Instantiate account from options.
* @param {WalletDB} db
* @param {Object} options
* @returns {Account}
*/
Account.fromOptions = function fromOptions(db, options) {
return new Account(db).fromOptions(options);
};
/*
* Default address lookahead.
* @const {Number}
*/
Account.MAX_LOOKAHEAD = 40;
/**
* Attempt to intialize the account (generating
* the first addresses along with the lookahead
* addresses). Called automatically from the
* walletdb.
* @returns {Promise}
*/
Account.prototype.init = co(function* init() {
// Waiting for more keys.
if (this.keys.length !== this.n - 1) {
assert(!this.initialized);
this.save();
return;
}
assert(this.receiveDepth === 0);
assert(this.changeDepth === 0);
assert(this.nestedDepth === 0);
this.initialized = true;
yield this.initDepth();
});
/**
* Open the account (done after retrieval).
* @returns {Promise}
*/
Account.prototype.open = function open() {
if (!this.initialized)
return Promise.resolve();
if (this.receive)
return Promise.resolve();
this.receive = this.deriveReceive(this.receiveDepth - 1);
this.change = this.deriveChange(this.changeDepth - 1);
if (this.witness)
this.nested = this.deriveNested(this.nestedDepth - 1);
return Promise.resolve();
};
/**
* Add a public account key to the account (multisig).
* Does not update the database.
* @param {HDPublicKey} key - Account (bip44)
* key (can be in base58 form).
* @throws Error on non-hdkey/non-accountkey.
*/
Account.prototype.pushKey = function pushKey(key) {
var index;
if (HD.isBase58(key))
key = HD.fromBase58(key);
assert(key.verifyNetwork(this.network),
'Network mismatch for account key.');
if (!HD.isPublic(key))
throw new Error('Must add HD keys to wallet.');
if (!key.isAccount44())
throw new Error('Must add HD account keys to BIP44 wallet.');
if (this.type !== Account.types.MULTISIG)
throw new Error('Cannot add keys to non-multisig wallet.');
if (key.equal(this.accountKey))
throw new Error('Cannot add own key.');
index = util.binaryInsert(this.keys, key, cmp, true);
if (index === -1)
return false;
if (this.keys.length > this.n - 1) {
util.binaryRemove(this.keys, key, cmp);
throw new Error('Cannot add more keys.');
}
return true;
};
/**
* Remove a public account key to the account (multisig).
* Does not update the database.
* @param {HDPublicKey} key - Account (bip44)
* key (can be in base58 form).
* @throws Error on non-hdkey/non-accountkey.
*/
Account.prototype.spliceKey = function spliceKey(key) {
if (HD.isBase58(key))
key = HD.fromBase58(key);
assert(key.verifyNetwork(this.network),
'Network mismatch for account key.');
if (!HD.isHDPublicKey(key))
throw new Error('Must add HD keys to wallet.');
if (!key.isAccount44())
throw new Error('Must add HD account keys to BIP44 wallet.');
if (this.type !== Account.types.MULTISIG)
throw new Error('Cannot remove keys from non-multisig wallet.');
if (this.keys.length === this.n - 1)
throw new Error('Cannot remove key.');
return util.binaryRemove(this.keys, key, cmp);
};
/**
* Add a public account key to the account (multisig).
* Saves the key in the wallet database.
* @param {HDPublicKey} key
* @returns {Promise}
*/
Account.prototype.addSharedKey = co(function* addSharedKey(key) {
var result = this.pushKey(key);
var exists = yield this._hasDuplicate();
if (exists) {
this.spliceKey(key);
throw new Error('Cannot add a key from another account.');
}
// Try to initialize again.
yield this.init();
return result;
});
/**
* Ensure accounts are not sharing keys.
* @private
* @returns {Promise}
*/
Account.prototype._hasDuplicate = function _hasDuplicate() {
var ring, hash;
if (this.keys.length !== this.n - 1)
return false;
ring = this.deriveReceive(0);
hash = ring.getScriptHash('hex');
return this.wallet.hasAddress(hash);
};
/**
* Remove a public account key from the account (multisig).
* Remove the key from the wallet database.
* @param {HDPublicKey} key
* @returns {Promise}
*/
Account.prototype.removeSharedKey = function removeSharedKey(key) {
var result = this.spliceKey(key);
if (!result)
return false;
this.save();
return true;
};
/**
* Create a new receiving address (increments receiveDepth).
* @returns {WalletKey}
*/
Account.prototype.createReceive = function createReceive() {
return this.createKey(0);
};
/**
* Create a new change address (increments receiveDepth).
* @returns {WalletKey}
*/
Account.prototype.createChange = function createChange() {
return this.createKey(1);
};
/**
* Create a new change address (increments receiveDepth).
* @returns {WalletKey}
*/
Account.prototype.createNested = function createNested() {
return this.createKey(2);
};
/**
* Create a new address (increments depth).
* @param {Boolean} change
* @returns {Promise} - Returns {@link WalletKey}.
*/
Account.prototype.createKey = co(function* createKey(branch) {
var key, lookahead;
switch (branch) {
case 0:
key = this.deriveReceive(this.receiveDepth);
lookahead = this.deriveReceive(this.receiveDepth + this.lookahead);
yield this.saveKey(lookahead);
this.receiveDepth++;
this.receive = key;
break;
case 1:
key = this.deriveChange(this.changeDepth);
lookahead = this.deriveReceive(this.changeDepth + this.lookahead);
yield this.saveKey(lookahead);
this.changeDepth++;
this.change = key;
break;
case 2:
key = this.deriveNested(this.nestedDepth);
lookahead = this.deriveNested(this.nestedDepth + this.lookahead);
yield this.saveKey(lookahead);
this.nestedDepth++;
this.nested = key;
break;
default:
throw new Error('Bad branch: ' + branch);
}
this.save();
return key;
});
/**
* Derive a receiving address at `index`. Do not increment depth.
* @param {Number} index
* @returns {WalletKey}
*/
Account.prototype.deriveReceive = function deriveReceive(index, master) {
return this.deriveKey(0, index, master);
};
/**
* Derive a change address at `index`. Do not increment depth.
* @param {Number} index
* @returns {WalletKey}
*/
Account.prototype.deriveChange = function deriveChange(index, master) {
return this.deriveKey(1, index, master);
};
/**
* Derive a nested address at `index`. Do not increment depth.
* @param {Number} index
* @returns {WalletKey}
*/
Account.prototype.deriveNested = function deriveNested(index, master) {
if (!this.witness)
throw new Error('Cannot derive nested on non-witness account.');
return this.deriveKey(2, index, master);
};
/**
* Derive an address from `path` object.
* @param {Path} path
* @param {MasterKey} master
* @returns {WalletKey}
*/
Account.prototype.derivePath = function derivePath(path, master) {
var data = path.data;
var ring;
switch (path.keyType) {
case Path.types.HD:
return this.deriveKey(path.branch, path.index, master);
case Path.types.KEY:
assert(this.type === Account.types.PUBKEYHASH);
if (path.encrypted) {
data = master.decipher(data, path.hash);
if (!data)
return;
}
ring = WalletKey.fromImport(this, data);
return ring;
case Path.types.ADDRESS:
return;
default:
assert(false, 'Bad key type.');
}
};
/**
* Derive an address at `index`. Do not increment depth.
* @param {Number} branch - Whether the address on the change branch.
* @param {Number} index
* @returns {WalletKey}
*/
Account.prototype.deriveKey = function deriveKey(branch, index, master) {
var keys = [];
var i, key, shared, ring;
assert(typeof branch === 'number');
if (master &amp;&amp; master.key &amp;&amp; !this.watchOnly) {
key = master.key.deriveAccount44(this.accountIndex);
key = key.derive(branch).derive(index);
} else {
key = this.accountKey.derive(branch).derive(index);
}
ring = WalletKey.fromHD(this, key, branch, index);
switch (this.type) {
case Account.types.PUBKEYHASH:
break;
case Account.types.MULTISIG:
keys.push(key.publicKey);
for (i = 0; i &lt; this.keys.length; i++) {
shared = this.keys[i];
shared = shared.derive(branch).derive(index);
keys.push(shared.publicKey);
}
ring.script = Script.fromMultisig(this.m, this.n, keys);
break;
}
return ring;
};
/**
* Save the account to the database. Necessary
* when address depth and keys change.
* @returns {Promise}
*/
Account.prototype.save = function save() {
return this.db.saveAccount(this);
};
/**
* Save addresses to path map.
* @param {WalletKey[]} rings
* @returns {Promise}
*/
Account.prototype.saveKey = function saveKey(ring) {
return this.db.saveKey(this.wallet, ring);
};
/**
* Save paths to path map.
* @param {Path[]} rings
* @returns {Promise}
*/
Account.prototype.savePath = function savePath(path) {
return this.db.savePath(this.wallet, path);
};
/**
* Initialize address depths (including lookahead).
* @returns {Promise}
*/
Account.prototype.initDepth = co(function* initDepth() {
var i, key;
// Receive Address
this.receive = this.deriveReceive(0);
this.receiveDepth = 1;
yield this.saveKey(this.receive);
// Lookahead
for (i = 0; i &lt; this.lookahead; i++) {
key = this.deriveReceive(i + 1);
yield this.saveKey(key);
}
// Change Address
this.change = this.deriveChange(0);
this.changeDepth = 1;
yield this.saveKey(this.change);
// Lookahead
for (i = 0; i &lt; this.lookahead; i++) {
key = this.deriveChange(i + 1);
yield this.saveKey(key);
}
// Nested Address
if (this.witness) {
this.nested = this.deriveNested(0);
this.nestedDepth = 1;
yield this.saveKey(this.nested);
// Lookahead
for (i = 0; i &lt; this.lookahead; i++) {
key = this.deriveNested(i + 1);
yield this.saveKey(key);
}
}
this.save();
});
/**
* Allocate new lookahead addresses if necessary.
* @param {Number} receiveDepth
* @param {Number} changeDepth
* @param {Number} nestedDepth
* @returns {Promise} - Returns {@link WalletKey}.
*/
Account.prototype.syncDepth = co(function* syncDepth(receive, change, nested) {
var derived = false;
var result = null;
var i, depth, key;
if (receive > this.receiveDepth) {
depth = this.receiveDepth + this.lookahead;
assert(receive &lt;= depth + 1);
for (i = depth; i &lt; receive + this.lookahead; i++) {
key = this.deriveReceive(i);
yield this.saveKey(key);
}
this.receive = this.deriveReceive(receive - 1);
this.receiveDepth = receive;
derived = true;
result = this.receive;
}
if (change > this.changeDepth) {
depth = this.changeDepth + this.lookahead;
assert(change &lt;= depth + 1);
for (i = depth; i &lt; change + this.lookahead; i++) {
key = this.deriveChange(i);
yield this.saveKey(key);
}
this.change = this.deriveChange(change - 1);
this.changeDepth = change;
derived = true;
}
if (this.witness &amp;&amp; nested > this.nestedDepth) {
depth = this.nestedDepth + this.lookahead;
assert(nested &lt;= depth + 1);
for (i = depth; i &lt; nested + this.lookahead; i++) {
key = this.deriveNested(i);
yield this.saveKey(key);
}
this.nested = this.deriveNested(nested - 1);
this.nestedDepth = nested;
derived = true;
result = this.nested;
}
if (derived)
this.save();
return result;
});
/**
* Allocate new lookahead addresses.
* @param {Number} lookahead
* @returns {Promise}
*/
Account.prototype.setLookahead = co(function* setLookahead(lookahead) {
var i, diff, key, depth, target;
if (lookahead === this.lookahead) {
this.db.logger.warning(
'Lookahead is not changing for: %s/%s.',
this.id, this.name);
return;
}
if (lookahead &lt; this.lookahead) {
diff = this.lookahead - lookahead;
this.receiveDepth += diff;
this.receive = this.deriveReceive(this.receiveDepth - 1);
this.changeDepth += diff;
this.change = this.deriveChange(this.changeDepth - 1);
if (this.witness) {
this.nestedDepth += diff;
this.nested = this.deriveNested(this.nestedDepth - 1);
}
this.lookahead = lookahead;
this.save();
return;
}
depth = this.receiveDepth + this.lookahead;
target = this.receiveDepth + lookahead;
for (i = depth; i &lt; target; i++) {
key = this.deriveReceive(i);
yield this.saveKey(key);
}
depth = this.changeDepth + this.lookahead;
target = this.changeDepth + lookahead;
for (i = depth; i &lt; target; i++) {
key = this.deriveChange(i);
yield this.saveKey(key);
}
if (this.witness) {
depth = this.nestedDepth + this.lookahead;
target = this.nestedDepth + lookahead;
for (i = depth; i &lt; target; i++) {
key = this.deriveNested(i);
yield this.saveKey(key);
}
}
this.lookahead = lookahead;
this.save();
});
/**
* Get current receive address.
* @param {String?} enc - `"base58"` or `null`.
* @returns {Address|Base58Address}
*/
Account.prototype.getAddress = function getAddress(enc) {
return this.getReceive(enc);
};
/**
* Get current receive address.
* @param {String?} enc - `"base58"` or `null`.
* @returns {Address|Base58Address}
*/
Account.prototype.getReceive = function getReceive(enc) {
if (!this.receive)
return;
return this.receive.getAddress(enc);
};
/**
* Get current change address.
* @param {String?} enc - `"base58"` or `null`.
* @returns {Address|Base58Address}
*/
Account.prototype.getChange = function getChange(enc) {
if (!this.change)
return;
return this.change.getAddress(enc);
};
/**
* Get current nested address.
* @param {String?} enc - `"base58"` or `null`.
* @returns {Address|Base58Address}
*/
Account.prototype.getNested = function getNested(enc) {
if (!this.nested)
return;
return this.nested.getAddress(enc);
};
/**
* Convert the account to a more inspection-friendly object.
* @returns {Object}
*/
Account.prototype.inspect = function inspect() {
return {
wid: this.wid,
name: this.name,
network: this.network,
initialized: this.initialized,
witness: this.witness,
watchOnly: this.watchOnly,
type: Account.typesByVal[this.type].toLowerCase(),
m: this.m,
n: this.n,
accountIndex: this.accountIndex,
receiveDepth: this.receiveDepth,
changeDepth: this.changeDepth,
nestedDepth: this.nestedDepth,
lookahead: this.lookahead,
address: this.initialized
? this.receive.getAddress()
: null,
nestedAddress: this.initialized &amp;&amp; this.nested
? this.nested.getAddress()
: null,
accountKey: this.accountKey.toBase58(),
keys: this.keys.map(function(key) {
return key.toBase58();
})
};
};
/**
* Convert the account to an object suitable for
* serialization.
* @returns {Object}
*/
Account.prototype.toJSON = function toJSON(minimal) {
return {
wid: minimal ? undefined : this.wid,
id: minimal ? undefined : this.id,
name: this.name,
initialized: this.initialized,
witness: this.witness,
watchOnly: this.watchOnly,
type: Account.typesByVal[this.type].toLowerCase(),
m: this.m,
n: this.n,
accountIndex: this.accountIndex,
receiveDepth: this.receiveDepth,
changeDepth: this.changeDepth,
nestedDepth: this.nestedDepth,
lookahead: this.lookahead,
receiveAddress: this.receive
? this.receive.getAddress('base58')
: null,
nestedAddress: this.nested
? this.nested.getAddress('base58')
: null,
changeAddress: this.change
? this.change.getAddress('base58')
: null,
accountKey: this.accountKey.toBase58(),
keys: this.keys.map(function(key) {
return key.toBase58();
})
};
};
/**
* Calculate serialization size.
* @returns {Number}
*/
Account.prototype.getSize = function getSize() {
var size = 0;
size += encoding.sizeVarString(this.name, 'ascii');
size += 105;
size += this.keys.length * 82;
return size;
};
/**
* Serialize the account.
* @returns {Buffer}
*/
Account.prototype.toRaw = function toRaw() {
var size = this.getSize();
var bw = new StaticWriter(size);
var i, key;
bw.writeVarString(this.name, 'ascii');
bw.writeU8(this.initialized ? 1 : 0);
bw.writeU8(this.witness ? 1 : 0);
bw.writeU8(this.type);
bw.writeU8(this.m);
bw.writeU8(this.n);
bw.writeU32(this.accountIndex);
bw.writeU32(this.receiveDepth);
bw.writeU32(this.changeDepth);
bw.writeU32(this.nestedDepth);
bw.writeU8(this.lookahead);
bw.writeBytes(this.accountKey.toRaw());
bw.writeU8(this.keys.length);
for (i = 0; i &lt; this.keys.length; i++) {
key = this.keys[i];
bw.writeBytes(key.toRaw());
}
return bw.render();
};
/**
* Inject properties from serialized data.
* @private
* @param {Buffer} data
* @returns {Object}
*/
Account.prototype.fromRaw = function fromRaw(data) {
var br = new BufferReader(data);
var i, count, key;
this.name = br.readVarString('ascii');
this.initialized = br.readU8() === 1;
this.witness = br.readU8() === 1;
this.type = br.readU8();
this.m = br.readU8();
this.n = br.readU8();
this.accountIndex = br.readU32();
this.receiveDepth = br.readU32();
this.changeDepth = br.readU32();
this.nestedDepth = br.readU32();
this.lookahead = br.readU8();
this.accountKey = HD.fromRaw(br.readBytes(82));
assert(Account.typesByVal[this.type]);
count = br.readU8();
for (i = 0; i &lt; count; i++) {
key = HD.fromRaw(br.readBytes(82));
this.pushKey(key);
}
return this;
};
/**
* Instantiate a account from serialized data.
* @param {WalletDB} data
* @param {Buffer} data
* @returns {Account}
*/
Account.fromRaw = function fromRaw(db, data) {
return new Account(db).fromRaw(data);
};
/**
* Test an object to see if it is a Account.
* @param {Object} obj
* @returns {Boolean}
*/
Account.isAccount = function isAccount(obj) {
return obj
&amp;&amp; typeof obj.receiveDepth === 'number'
&amp;&amp; obj.deriveKey === 'function';
};
/*
* Helpers
*/
function cmp(key1, key2) {
return key1.compare(key2);
}
/*
* Expose
*/
module.exports = Account;
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-bcoin.html">bcoin</a></li><li><a href="module-bip70.html">bip70</a></li><li><a href="module-bip70_pk.html">bip70/pk</a></li><li><a href="module-bip70_x509.html">bip70/x509</a></li><li><a href="module-blockchain.html">blockchain</a></li><li><a href="module-blockchain_common.html">blockchain/common</a></li><li><a href="module-btc.html">btc</a></li><li><a href="module-coins.html">coins</a></li><li><a href="module-crypto.html">crypto</a></li><li><a href="module-crypto_chachapoly.html">crypto/chachapoly</a></li><li><a href="module-crypto_ec.html">crypto/ec</a></li><li><a href="module-crypto_pk.html">crypto/pk</a></li><li><a href="module-crypto_schnorr.html">crypto/schnorr</a></li><li><a href="module-crypto_siphash.html">crypto/siphash</a></li><li><a href="module-db.html">db</a></li><li><a href="module-hd.html">hd</a></li><li><a href="module-http.html">http</a></li><li><a href="module-mempool.html">mempool</a></li><li><a href="module-mining.html">mining</a></li><li><a href="module-net.html">net</a></li><li><a href="module-net_bip152.html">net/bip152</a></li><li><a href="module-net_common.html">net/common</a></li><li><a href="module-net_dns.html">net/dns</a></li><li><a href="module-net_packets.html">net/packets</a></li><li><a href="module-net_socks.html">net/socks</a></li><li><a href="module-net_tcp.html">net/tcp</a></li><li><a href="module-node.html">node</a></li><li><a href="module-node_config.html">node/config</a></li><li><a href="module-primitives.html">primitives</a></li><li><a href="module-protocol.html">protocol</a></li><li><a href="module-protocol_consensus.html">protocol/consensus</a></li><li><a href="module-protocol_errors.html">protocol/errors</a></li><li><a href="module-protocol_networks.html">protocol/networks</a></li><li><a href="module-protocol_policy.html">protocol/policy</a></li><li><a href="module-script.html">script</a></li><li><a href="module-script_common.html">script/common</a></li><li><a href="module-utils.html">utils</a></li><li><a href="module-utils_asn1.html">utils/asn1</a></li><li><a href="module-utils_base32.html">utils/base32</a></li><li><a href="module-utils_base58.html">utils/base58</a></li><li><a href="module-utils_co.html">utils/co</a></li><li><a href="module-utils_encoding.html">utils/encoding</a></li><li><a href="module-utils_ip.html">utils/ip</a></li><li><a href="module-utils_pem.html">utils/pem</a></li><li><a href="module-utils_protobuf.html">utils/protobuf</a></li><li><a href="module-utils_util.html">utils/util</a></li><li><a href="module-wallet.html">wallet</a></li><li><a href="module-wallet_common.html">wallet/common</a></li><li><a href="module-wallet_records.html">wallet/records</a></li><li><a href="module-workers.html">workers</a></li><li><a href="module-workers_jobs.html">workers/jobs</a></li><li><a href="module-workers_packets.html">workers/packets</a></li></ul><h3>Classes</h3><ul><li><a href="Environment.html">Environment</a></li><li><a href="module-bip70.Payment.html">Payment</a></li><li><a href="module-bip70.PaymentACK.html">PaymentACK</a></li><li><a href="module-bip70.PaymentDetails.html">PaymentDetails</a></li><li><a href="module-bip70.PaymentRequest.html">PaymentRequest</a></li><li><a href="module-blockchain.Chain.html">Chain</a></li><li><a href="module-blockchain.ChainDB.html">ChainDB</a></li><li><a href="module-blockchain.ChainEntry.html">ChainEntry</a></li><li><a href="module-blockchain.ChainFlags.html">ChainFlags</a></li><li><a href="module-blockchain.ChainOptions.html">ChainOptions</a></li><li><a href="module-blockchain.ChainState.html">ChainState</a></li><li><a href="module-blockchain.DeploymentState.html">DeploymentState</a></li><li><a href="module-blockchain.StateCache.html">StateCache</a></li><li><a href="module-btc.Amount.html">Amount</a></li><li><a href="module-btc.URI.html">URI</a></li><li><a href="module-coins.CoinEntry.html">CoinEntry</a></li><li><a href="module-coins.Coins.html">Coins</a></li><li><a href="module-coins.CoinView.html">CoinView</a></li><li><a href="module-coins.UndoCoin.html">UndoCoin</a></li><li><a href="module-coins.UndoCoins.html">UndoCoins</a></li><li><a href="module-crypto_aes.AESCipher.html">AESCipher</a></li><li><a href="module-crypto_aes.AESDecipher.html">AESDecipher</a></li><li><a href="module-crypto_aes.AESKey.html">AESKey</a></li><li><a href="module-crypto_chachapoly.AEAD.html">AEAD</a></li><li><a href="module-crypto_chachapoly.ChaCha20.html">ChaCha20</a></li><li><a href="module-crypto_chachapoly.Poly1305.html">Poly1305</a></li><li><a href="module-crypto_sha256.SHA256.html">SHA256</a></li><li><a href="module-crypto_sha256.SHA256Hmac.html">SHA256Hmac</a></li><li><a href="module-db.LowlevelUp.html">LowlevelUp</a></li><li><a href="module-db.RBT.html">RBT</a></li><li><a href="module-hd.Mnemonic.html">Mnemonic</a></li><li><a href="module-hd.PrivateKey.html">PrivateKey</a></li><li><a href="module-hd.PublicKey.html">PublicKey</a></li><li><a href="module-http.Base.html">Base</a></li><li><a href="module-http.Client.html">Client</a></li><li><a href="module-http.HTTPBaseOptions.html">HTTPBaseOptions</a></li><li><a href="module-http.HTTPOptions.html">HTTPOptions</a></li><li><a href="module-http.Request.html">Request</a></li><li><a href="module-http.RPC.html">RPC</a></li><li><a href="module-http.RPCClient.html">RPCClient</a></li><li><a href="module-http.Server.html">Server</a></li><li><a href="module-http.Wallet.html">Wallet</a></li><li><a href="module-mempool.ConfirmStats.html">ConfirmStats</a></li><li><a href="module-mempool.Mempool.html">Mempool</a></li><li><a href="module-mempool.MempoolEntry.html">MempoolEntry</a></li><li><a href="module-mempool.MempoolOptions.html">MempoolOptions</a></li><li><a href="module-mempool.PolicyEstimator.html">PolicyEstimator</a></li><li><a href="module-mining.BlockEntry.html">BlockEntry</a></li><li><a href="module-mining.Miner.html">Miner</a></li><li><a href="module-mining.MinerBlock.html">MinerBlock</a></li><li><a href="module-mining.MinerOptions.html">MinerOptions</a></li><li><a href="module-net.AuthDB.html">AuthDB</a></li><li><a href="module-net.BIP150.html">BIP150</a></li><li><a href="module-net.BIP151.html">BIP151</a></li><li><a href="module-net.BIP151Stream.html">BIP151Stream</a></li><li><a href="module-net.BroadcastItem.html">BroadcastItem</a></li><li><a href="module-net.Framer.html">Framer</a></li><li><a href="module-net.HostEntry.html">HostEntry</a></li><li><a href="module-net.HostList.html">HostList</a></li><li><a href="module-net.Parser.html">Parser</a></li><li><a href="module-net.Peer.html">Peer</a></li><li><a href="module-net.PeerList.html">PeerList</a></li><li><a href="module-net.PeerOptions.html">PeerOptions</a></li><li><a href="module-net.Pool.html">Pool</a></li><li><a href="module-net.PoolOptions.html">PoolOptions</a></li><li><a href="module-net_bip152-CompactBlock.html">CompactBlock</a></li><li><a href="module-net_bip152-PrefilledTX.html">PrefilledTX</a></li><li><a href="module-net_bip152-TXRequest.html">TXRequest</a></li><li><a href="module-net_bip152-TXResponse.html">TXResponse</a></li><li><a href="module-net_packets-AddrPacket.html">AddrPacket</a></li><li><a href="module-net_packets-AuthChallengePacket.html">AuthChallengePacket</a></li><li><a href="module-net_packets-AuthProposePacket.html">AuthProposePacket</a></li><li><a href="module-net_packets-AuthReplyPacket.html">AuthReplyPacket</a></li><li><a href="module-net_packets-BlockPacket.html">BlockPacket</a></li><li><a href="module-net_packets-BlockTxnPacket.html">BlockTxnPacket</a></li><li><a href="module-net_packets-CmpctBlockPacket.html">CmpctBlockPacket</a></li><li><a href="module-net_packets-EncackPacket.html">EncackPacket</a></li><li><a href="module-net_packets-EncinitPacket.html">EncinitPacket</a></li><li><a href="module-net_packets-FeeFilterPacket.html">FeeFilterPacket</a></li><li><a href="module-net_packets-FilterAddPacket.html">FilterAddPacket</a></li><li><a href="module-net_packets-FilterClearPacket.html">FilterClearPacket</a></li><li><a href="module-net_packets-FilterLoadPacket.html">FilterLoadPacket</a></li><li><a href="module-net_packets-GetAddrPacket.html">GetAddrPacket</a></li><li><a href="module-net_packets-GetBlocksPacket.html">GetBlocksPacket</a></li><li><a href="module-net_packets-GetBlockTxnPacket.html">GetBlockTxnPacket</a></li><li><a href="module-net_packets-GetDataPacket.html">GetDataPacket</a></li><li><a href="module-net_packets-GetHeadersPacket.html">GetHeadersPacket</a></li><li><a href="module-net_packets-HeadersPacket.html">HeadersPacket</a></li><li><a href="module-net_packets-InvPacket.html">InvPacket</a></li><li><a href="module-net_packets-MempoolPacket.html">MempoolPacket</a></li><li><a href="module-net_packets-MerkleBlockPacket.html">MerkleBlockPacket</a></li><li><a href="module-net_packets-NotFoundPacket.html">NotFoundPacket</a></li><li><a href="module-net_packets-Packet.html">Packet</a></li><li><a href="module-net_packets-PingPacket.html">PingPacket</a></li><li><a href="module-net_packets-PongPacket.html">PongPacket</a></li><li><a href="module-net_packets-RejectPacket.html">RejectPacket</a></li><li><a href="module-net_packets-SendCmpctPacket.html">SendCmpctPacket</a></li><li><a href="module-net_packets-SendHeadersPacket.html">SendHeadersPacket</a></li><li><a href="module-net_packets-TXPacket.html">TXPacket</a></li><li><a href="module-net_packets-UnknownPacket.html">UnknownPacket</a></li><li><a href="module-net_packets-VerackPacket.html">VerackPacket</a></li><li><a href="module-net_packets-VersionPacket.html">VersionPacket</a></li><li><a href="module-net_socks-Proxy.html">Proxy</a></li><li><a href="module-net_socks-SOCKS.html">SOCKS</a></li><li><a href="module-node.FullNode.html">FullNode</a></li><li><a href="module-node.Logger.html">Logger</a></li><li><a href="module-node.Node.html">Node</a></li><li><a href="module-node.NodeClient.html">NodeClient</a></li><li><a href="module-node.SPVNode.html">SPVNode</a></li><li><a href="module-primitives.AbstractBlock.html">AbstractBlock</a></li><li><a href="module-primitives.Address.html">Address</a></li><li><a href="module-primitives.Block.html">Block</a></li><li><a href="module-primitives.Coin.html">Coin</a></li><li><a href="module-primitives.CoinSelector.html">CoinSelector</a></li><li><a href="module-primitives.Headers.html">Headers</a></li><li><a href="module-primitives.Input.html">Input</a></li><li><a href="module-primitives.InvItem.html">InvItem</a></li><li><a href="module-primitives.KeyRing.html">KeyRing</a></li><li><a href="module-primitives.MemBlock.html">MemBlock</a></li><li><a href="module-primitives.MerkleBlock.html">MerkleBlock</a></li><li><a href="module-primitives.MTX.html">MTX</a></li><li><a href="module-primitives.NetAddress.html">NetAddress</a></li><li><a href="module-primitives.Outpoint.html">Outpoint</a></li><li><a href="module-primitives.Output.html">Output</a></li><li><a href="module-primitives.TX.html">TX</a></li><li><a href="module-primitives.TXMeta.html">TXMeta</a></li><li><a href="module-protocol.Network.html">Network</a></li><li><a href="module-protocol.TimeData.html">TimeData</a></li><li><a href="module-protocol_errors-VerifyError.html">VerifyError</a></li><li><a href="module-protocol_errors-VerifyResult.html">VerifyResult</a></li><li><a href="module-script.Opcode.html">Opcode</a></li><li><a href="module-script.Program.html">Program</a></li><li><a href="module-script.Script.html">Script</a></li><li><a href="module-script.ScriptError.html">ScriptError</a></li><li><a href="module-script.SigCache.html">SigCache</a></li><li><a href="module-script.Stack.html">Stack</a></li><li><a href="module-script.Witness.html">Witness</a></li><li><a href="module-utils.AsyncEmitter.html">AsyncEmitter</a></li><li><a href="module-utils.AsyncObject.html">AsyncObject</a></li><li><a href="module-utils.Bloom.html">Bloom</a></li><li><a href="module-utils.BufferReader.html">BufferReader</a></li><li><a href="module-utils.BufferWriter.html">BufferWriter</a></li><li><a href="module-utils.List.html">List</a></li><li><a href="module-utils.ListItem.html">ListItem</a></li><li><a href="module-utils.Lock.html">Lock</a></li><li><a href="module-utils.LRU.html">LRU</a></li><li><a href="module-utils.LRUBatch.html">LRUBatch</a></li><li><a href="module-utils.LRUItem.html">LRUItem</a></li><li><a href="module-utils.LRUOp.html">LRUOp</a></li><li><a href="module-utils.Map.html">Map</a></li><li><a href="module-utils.MappedLock.html">MappedLock</a></li><li><a href="module-utils.RollingFilter.html">RollingFilter</a></li><li><a href="module-utils.StaticWriter.html">StaticWriter</a></li><li><a href="module-utils_ip.Address.html">Address</a></li><li><a href="module-utils_protobuf-ProtoReader.html">ProtoReader</a></li><li><a href="module-utils_protobuf-ProtoWriter.html">ProtoWriter</a></li><li><a href="module-wallet.Account.html">Account</a></li><li><a href="module-wallet.Balance.html">Balance</a></li><li><a href="module-wallet.BlockRecord.html">BlockRecord</a></li><li><a href="module-wallet.ChainState.html">ChainState</a></li><li><a href="module-wallet.Credit.html">Credit</a></li><li><a href="module-wallet.Details.html">Details</a></li><li><a href="module-wallet.DetailsMember.html">DetailsMember</a></li><li><a href="module-wallet.MasterKey.html">MasterKey</a></li><li><a href="module-wallet.Path.html">Path</a></li><li><a href="module-wallet.TXDB.html">TXDB</a></li><li><a href="module-wallet.Wallet.html">Wallet</a></li><li><a href="module-wallet.WalletClient.html">WalletClient</a></li><li><a href="module-wallet.WalletDB.html">WalletDB</a></li><li><a href="module-wallet.WalletKey.html">WalletKey</a></li><li><a href="module-wallet.WalletOptions.html">WalletOptions</a></li><li><a href="module-wallet_records-BlockMapRecord.html">BlockMapRecord</a></li><li><a href="module-wallet_records-BlockMeta.html">BlockMeta</a></li><li><a href="module-wallet_records-ChainState.html">ChainState</a></li><li><a href="module-wallet_records-OutpointMapRecord.html">OutpointMapRecord</a></li><li><a href="module-wallet_records-PathMapRecord.html">PathMapRecord</a></li><li><a href="module-wallet_records-TXMapRecord.html">TXMapRecord</a></li><li><a href="module-wallet_records-TXRecord.html">TXRecord</a></li><li><a href="module-workers.Framer.html">Framer</a></li><li><a href="module-workers.Master.html">Master</a></li><li><a href="module-workers.Parser.html">Parser</a></li><li><a href="module-workers.ParserClient.html">ParserClient</a></li><li><a href="module-workers.Worker.html">Worker</a></li><li><a href="module-workers.WorkerPool.html">WorkerPool</a></li><li><a href="module-workers_packets-ECSignPacket.html">ECSignPacket</a></li><li><a href="module-workers_packets-ECSignResultPacket.html">ECSignResultPacket</a></li><li><a href="module-workers_packets-ECVerifyPacket.html">ECVerifyPacket</a></li><li><a href="module-workers_packets-ECVerifyResultPacket.html">ECVerifyResultPacket</a></li><li><a href="module-workers_packets-ErrorPacket.html">ErrorPacket</a></li><li><a href="module-workers_packets-ErrorResultPacket.html">ErrorResultPacket</a></li><li><a href="module-workers_packets-EventPacket.html">EventPacket</a></li><li><a href="module-workers_packets-LogPacket.html">LogPacket</a></li><li><a href="module-workers_packets-MinePacket.html">MinePacket</a></li><li><a href="module-workers_packets-MineResultPacket.html">MineResultPacket</a></li><li><a href="module-workers_packets-Packet.html">Packet</a></li><li><a href="module-workers_packets-ScryptPacket.html">ScryptPacket</a></li><li><a href="module-workers_packets-ScryptResultPacket.html">ScryptResultPacket</a></li><li><a href="module-workers_packets-SignInputPacket.html">SignInputPacket</a></li><li><a href="module-workers_packets-SignInputResultPacket.html">SignInputResultPacket</a></li><li><a href="module-workers_packets-SignPacket.html">SignPacket</a></li><li><a href="module-workers_packets-SignResultPacket.html">SignResultPacket</a></li><li><a href="module-workers_packets-VerifyInputPacket.html">VerifyInputPacket</a></li><li><a href="module-workers_packets-VerifyInputResultPacket.html">VerifyInputResultPacket</a></li><li><a href="module-workers_packets-VerifyPacket.html">VerifyPacket</a></li><li><a href="module-workers_packets-VerifyResultPacket.html">VerifyResultPacket</a></li></ul><h3>Namespaces</h3><ul><li><a href="module-crypto_pk.ecdsa.html">ecdsa</a></li><li><a href="module-crypto_pk.rsa.html">rsa</a></li></ul><h3>Global</h3><ul><li><a href="global.html"></a></li><li><a href="global.html#DoubleMap">DoubleMap</a></li><li><a href="global.html#StatEntry">StatEntry</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Fri Feb 10 2017 09:40:23 GMT-0800 (PST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>