diff --git a/LICENSE b/LICENSE
index 1c98fb0fd..560d783a8 100644
--- a/LICENSE
+++ b/LICENSE
@@ -2,7 +2,7 @@ This software is licensed under the MIT License.
Copyright (c) 2014-2015, Fedor Indutny (https://github.com/indutny)
-Copyright (c) 2014-2016, Christopher Jeffrey (https://github.com/chjj)
+Copyright (c) 2014-2017, Christopher Jeffrey (https://github.com/chjj)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index b7c823ec9..10b1483f3 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,7 @@ $ npm install
$ bcoin --fast
```
-Note that the latest BCoin has not been published to NPM yet, as it is still
+Note that the latest Bcoin has not been published to NPM yet, as it is still
under fairly heavy development (which may involve changing serialization
formats for the database).
@@ -373,7 +373,7 @@ Normal transactions in bcoin are immutable. The primary TX object contains a
bunch of consensus and policy checking methods. A lot of it is for internal use
and pretty boring for users of this library.
-BCoin also offers a mutable transaction object (MTX). Mutable transactions
+Bcoin also offers a mutable transaction object (MTX). Mutable transactions
inherit from the TX object, but can also be signed and modified.
``` js
@@ -446,7 +446,7 @@ assert(tx.getFee(mtx.view) === 40000);
The above method works, but is pretty contrived. In reality, you probably
wouldn't select inputs and calculate the fee by hand. You would want a
-change output added. BCoin has a nice method of dealing with this.
+change output added. Bcoin has a nice method of dealing with this.
Let's try it more realistically:
@@ -575,7 +575,7 @@ output.execute(stack);
## Wallet usage
-BCoin maintains a wallet database which contains every wallet. Wallets are _not
+Bcoin maintains a wallet database which contains every wallet. Wallets are _not
usable_ without also using a wallet database. For testing, the wallet database
can be in-memory, but it must be there.
@@ -584,7 +584,7 @@ but support was removed to reduce code complexity, and also because bip45
doesn't seem to add any benefit in practice.
The wallet database can contain many different wallets, with many different
-accounts, with many different addresses for each account. BCoin should
+accounts, with many different addresses for each account. Bcoin should
theoretically be able to scale to hundreds of thousands of
wallets/accounts/addresses.
@@ -602,7 +602,7 @@ TODO
## Design
-BCoin is thoroughly event driven. It has a fullnode object, but BCoin was
+Bcoin is thoroughly event driven. It has a fullnode object, but Bcoin was
specifically designed so the mempool, blockchain, p2p pool, and wallet database
could all be used separately. All the fullnode object does is tie these things
together. It's essentially a huge proxying of events. The general communication
@@ -638,7 +638,7 @@ well-written.
#### Concurrency
-BCoin runs in node.js, so the javascript code is limited to one thread. We
+Bcoin runs in node.js, so the javascript code is limited to one thread. We
solve this limitation by spinning up persistent worker processes for
transaction verification (webworkers when in the browser). This ensures the
blockchain and mempool do not block the master process very much. It also means
@@ -652,7 +652,7 @@ data to another process.
But of course, there is a benefit to having a multi-process architecture: the
worker processes can die on their own without disturbing the master process.
-BCoin uses [secp256k1-node][secp256k1-node] for ecdsa verification, which is a
+Bcoin uses [secp256k1-node][secp256k1-node] for ecdsa verification, which is a
node.js binding to Pieter Wuille's blazingly fast [libsecp256k1][libsecp256k1]
library.
@@ -669,7 +669,7 @@ visiting a webpage.
## Disclaimer
-BCoin does not guarantee you against theft or lost funds due to bugs, mishaps,
+Bcoin does not guarantee you against theft or lost funds due to bugs, mishaps,
or your own incompetence. You and you alone are responsible for securing your
money.
@@ -683,7 +683,7 @@ all code is your original work. ``
Copyright (c) 2014-2015, Fedor Indutny (MIT License).
-Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
See LICENSE for more info.
diff --git a/bin/bcoin b/bin/bcoin
index 96703143c..315f0ee7a 100755
--- a/bin/bcoin
+++ b/bin/bcoin
@@ -6,7 +6,7 @@ cmd='node'
if ! type perl > /dev/null 2>& 1; then
if uname | grep -i 'darwin' > /dev/null; then
- echo 'BCoin requires perl to start.' >& 2
+ echo 'Bcoin requires perl to start.' >& 2
exit 1
fi
rl=1
@@ -51,7 +51,7 @@ done
if test $daemon -eq 1; then
if ! type setsid > /dev/null 2>& 1; then
- echo 'BCoin requires setsid to start as a daemon.' >& 2
+ echo 'Bcoin requires setsid to start as a daemon.' >& 2
exit 1
fi
(
diff --git a/browser/index.html b/browser/index.html
index ea0029241..22280fc05 100644
--- a/browser/index.html
+++ b/browser/index.html
@@ -72,7 +72,7 @@
-BCoin, the browser full node
+Bcoin, the browser full node
Welcome. Your machine is currently validating the blockchain.
The blocks and wallet are stored on your local disk with indexed DB. You are
connecting to the actual bitcoin P2P network via a websocket->tcp proxy.
diff --git a/lib/bcoin.js b/lib/bcoin.js
index 973e47d9c..d64184c78 100644
--- a/lib/bcoin.js
+++ b/lib/bcoin.js
@@ -1,15 +1,23 @@
+/*!
+ * bcoin.js - a javascript bitcoin library.
+ * Copyright (c) 2014-2015, Fedor Indutny (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
+ * https://github.com/indutny/bcoin
+ */
+
+'use strict';
+
/**
- * Javascript bitcoin library. Exposes the global environment.
+ * Exposes the global environment.
+ * An instance of {@link Environment}.
* @module bcoin
* @see {Environment}
* @license
* Copyright (c) 2014-2015, Fedor Indutny (MIT License).
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/indutny/bcoin
*/
-'use strict';
-
var env = require('./env');
var util = require('./utils/util');
var global = util.global;
@@ -22,4 +30,8 @@ var global = util.global;
if (util.isBrowser)
global.bcoin = env;
+/*
+ * Expose
+ */
+
module.exports = env;
diff --git a/lib/bip70/index.js b/lib/bip70/index.js
index f7502ac7f..02da3a645 100644
--- a/lib/bip70/index.js
+++ b/lib/bip70/index.js
@@ -1,11 +1,15 @@
/*!
* bip70.js - bip70 for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module bip70
+ */
+
exports.PaymentRequest = require('./paymentrequest');
exports.PaymentDetails = require('./paymentdetails');
exports.Payment = require('./payment');
diff --git a/lib/bip70/payment.js b/lib/bip70/payment.js
index af7a28b99..ded75ac3f 100644
--- a/lib/bip70/payment.js
+++ b/lib/bip70/payment.js
@@ -1,6 +1,6 @@
/*!
* payment.js - bip70 payment for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -17,6 +17,7 @@ var ProtoWriter = protobuf.ProtoWriter;
/**
* Represents a BIP70 payment.
+ * @alias module:bip70.Payment
* @constructor
* @param {Object?} options
* @property {Buffer} merchantData
diff --git a/lib/bip70/paymentack.js b/lib/bip70/paymentack.js
index 76ff95d91..462705d14 100644
--- a/lib/bip70/paymentack.js
+++ b/lib/bip70/paymentack.js
@@ -1,6 +1,6 @@
/*!
* paymentack.js - bip70 paymentack for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -14,6 +14,8 @@ var ProtoWriter = protobuf.ProtoWriter;
/**
* Represents a BIP70 payment ack.
+ * @alias module:bip70.PaymentACK
+ * @constructor
* @param {Object?} options
* @property {Payment} payment
* @property {String|null} memo
diff --git a/lib/bip70/paymentdetails.js b/lib/bip70/paymentdetails.js
index b19701272..5b46e5567 100644
--- a/lib/bip70/paymentdetails.js
+++ b/lib/bip70/paymentdetails.js
@@ -1,6 +1,6 @@
/*!
* paymentdetails.js - bip70 paymentdetails for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -15,6 +15,8 @@ var ProtoWriter = protobuf.ProtoWriter;
/**
* Represents BIP70 payment details.
+ * @alias module:bip70.PaymentDetails
+ * @constructor
* @param {Object?} options
* @property {String|null} network
* @property {Output[]} outputs
diff --git a/lib/bip70/paymentrequest.js b/lib/bip70/paymentrequest.js
index cb018d6d5..cdf127b90 100644
--- a/lib/bip70/paymentrequest.js
+++ b/lib/bip70/paymentrequest.js
@@ -1,6 +1,6 @@
/*!
* paymentrequest.js - bip70 paymentrequest for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -18,6 +18,8 @@ var ProtoWriter = protobuf.ProtoWriter;
/**
* Represents a BIP70 payment request.
+ * @alias module:bip70.PaymentRequest
+ * @constructor
* @param {Object?} options
* @property {Number} version
* @property {String|null} pkiType
@@ -332,6 +334,7 @@ PaymentRequest.prototype.getCA = function getCA() {
/**
* Algorithm
* @constructor
+ * @ignore
*/
function Algorithm(key, hash) {
@@ -342,6 +345,7 @@ function Algorithm(key, hash) {
/**
* CA
* @constructor
+ * @ignore
*/
function CA(root) {
diff --git a/lib/bip70/pk.js b/lib/bip70/pk.js
index 7fcc0650e..e49588daf 100644
--- a/lib/bip70/pk.js
+++ b/lib/bip70/pk.js
@@ -1,13 +1,27 @@
/*!
* pk.js - public key algorithms for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module bip70/pk
+ */
+
var pk = require('../crypto/pk');
+/**
+ * Verify signature with public key.
+ * @private
+ * @param {String} hash - Hash algorithm.
+ * @param {Buffer} msg
+ * @param {Buffer} sig
+ * @param {Object} key
+ * @returns {Boolean}
+ */
+
exports._verify = function verify(hash, msg, sig, key) {
switch (key.alg) {
case 'rsa':
@@ -19,6 +33,15 @@ exports._verify = function verify(hash, msg, sig, key) {
}
};
+/**
+ * Verify signature with public key.
+ * @param {String} hash - Hash algorithm.
+ * @param {Buffer} msg
+ * @param {Buffer} sig
+ * @param {Object} key
+ * @returns {Boolean}
+ */
+
exports.verify = function verify(hash, msg, sig, key) {
try {
return exports._verify(hash, msg, sig, key);
@@ -27,6 +50,14 @@ exports.verify = function verify(hash, msg, sig, key) {
}
};
+/**
+ * Sign message with private key.
+ * @param {String} hash - Hash algorithm.
+ * @param {Buffer} msg
+ * @param {Object} key
+ * @returns {Buffer}
+ */
+
exports.sign = function sign(hash, msg, key) {
switch (key.alg) {
case 'rsa':
diff --git a/lib/bip70/x509.js b/lib/bip70/x509.js
index 17a2641da..2b7f602b9 100644
--- a/lib/bip70/x509.js
+++ b/lib/bip70/x509.js
@@ -1,6 +1,6 @@
/*!
* x509.js - x509 handling for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -12,6 +12,11 @@ var PEM = require('../utils/pem');
var util = require('../utils/util');
var crypto = require('../crypto/crypto');
var pk = require('./pk');
+
+/**
+ * @exports bip70/x509
+ */
+
var x509 = exports;
/**
diff --git a/lib/blockchain/chain.js b/lib/blockchain/chain.js
index 4b2b33d16..9b70db7d4 100644
--- a/lib/blockchain/chain.js
+++ b/lib/blockchain/chain.js
@@ -1,7 +1,7 @@
/*!
* chain.js - blockchain management for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -27,7 +27,7 @@ var VerifyResult = errors.VerifyResult;
/**
* Represents a blockchain.
- * @exports Chain
+ * @alias module:blockchain.Chain
* @constructor
* @param {Object} options
* @param {String?} options.name - Database name.
@@ -168,6 +168,7 @@ Chain.prototype._init = function _init() {
/**
* Open the chain, wait for the database to load.
+ * @method
* @alias Chain#open
* @returns {Promise}
*/
@@ -219,6 +220,7 @@ Chain.prototype._close = function close() {
/**
* Perform all necessary contextual verification on a block.
+ * @method
* @private
* @param {Block} block
* @param {ChainEntry} prev
@@ -254,6 +256,7 @@ Chain.prototype.isGenesis = function isGenesis(block) {
* Contextual verification for a block, including
* version deployments (IsSuperMajority), versionbits,
* coinbase height, finality checks.
+ * @method
* @private
* @param {Block} block
* @param {ChainEntry} prev
@@ -407,6 +410,7 @@ Chain.prototype.verify = co(function* verify(block, prev) {
/**
* Check all deployments on a chain, ranging from p2sh to segwit.
+ * @method
* @param {Block} block
* @param {ChainEntry} prev
* @returns {Promise} - Returns [{@link VerifyError}, {@link DeploymentState}].
@@ -507,6 +511,7 @@ Chain.prototype.setDeploymentState = function setDeploymentState(state) {
* Determine whether to check block for duplicate txids in blockchain
* history (BIP30). If we're on a chain that has bip34 activated, we
* can skip this.
+ * @method
* @private
* @see https://github.com/bitcoin/bips/blob/master/bip-0030.mediawiki
* @param {Block} block
@@ -556,6 +561,7 @@ Chain.prototype.verifyDuplicates = co(function* verifyDuplicates(block, prev, st
* will attempt to do this on the worker pool). If
* `checkpoints` is enabled, it will skip verification
* for historical data.
+ * @method
* @private
* @see TX#checkInputs
* @param {Block} block
@@ -678,6 +684,7 @@ Chain.prototype.checkHeight = function checkHeight(hash) {
/**
* Find the block at which a fork ocurred.
* @private
+ * @method
* @param {ChainEntry} fork - The current chain.
* @param {ChainEntry} longer - The competing chain.
* @returns {Promise}
@@ -707,6 +714,7 @@ Chain.prototype.findFork = co(function* findFork(fork, longer) {
* Reorganize the blockchain (connect and disconnect inputs).
* Called when a competing chain with a higher chainwork
* is received.
+ * @method
* @private
* @param {ChainEntry} competitor - The competing chain's tip.
* @param {Block} block - The being being added.
@@ -758,6 +766,7 @@ Chain.prototype.reorganize = co(function* reorganize(competitor, block) {
/**
* Reorganize the blockchain for SPV. This
* will reset the chain to the fork block.
+ * @method
* @private
* @param {ChainEntry} competitor - The competing chain's tip.
* @param {Block} block - The being being added.
@@ -800,6 +809,7 @@ Chain.prototype.reorganizeSPV = co(function* reorganizeSPV(competitor, block) {
/**
* Disconnect an entry from the chain (updates the tip).
+ * @method
* @param {ChainEntry} entry
* @returns {Promise}
*/
@@ -831,6 +841,7 @@ Chain.prototype.disconnect = co(function* disconnect(entry) {
* This will do contextual-verification on the block
* (necessary because we cannot validate the inputs
* in alternate chains when they come in).
+ * @method
* @param {ChainEntry} entry
* @returns {Promise}
*/
@@ -875,6 +886,7 @@ Chain.prototype.reconnect = co(function* reconnect(entry) {
* that comes in. It may add and connect the block (main chain),
* save the block without connection (alternate chain), or
* reorganize the chain (a higher fork).
+ * @method
* @private
* @param {ChainEntry} entry
* @param {Block} block
@@ -935,6 +947,7 @@ Chain.prototype.setBestChain = co(function* setBestChain(entry, block, prev) {
/**
* Save block on an alternate chain.
+ * @method
* @private
* @param {ChainEntry} entry
* @param {Block} block
@@ -973,6 +986,7 @@ Chain.prototype.saveAlternate = co(function* saveAlternate(entry, block, prev) {
* Reset the chain to the desired block. This
* is useful for replaying the blockchain download
* for SPV.
+ * @method
* @param {Hash|Number} block
* @returns {Promise}
*/
@@ -988,6 +1002,7 @@ Chain.prototype.reset = co(function* reset(block) {
/**
* Reset the chain to the desired block without a lock.
+ * @method
* @private
* @param {Hash|Number} block
* @returns {Promise}
@@ -1022,6 +1037,7 @@ Chain.prototype._reset = co(function* reset(block, silent) {
/**
* Reset the chain to a height or hash. Useful for replaying
* the blockchain download for SPV.
+ * @method
* @param {Hash|Number} block - hash/height
* @returns {Promise}
*/
@@ -1037,6 +1053,7 @@ Chain.prototype.replay = co(function* replay(block) {
/**
* Reset the chain without a lock.
+ * @method
* @private
* @param {Hash|Number} block - hash/height
* @returns {Promise}
@@ -1059,6 +1076,7 @@ Chain.prototype._replay = co(function* replay(block) {
/**
* Scan the blockchain for transactions containing specified address hashes.
+ * @method
* @param {Hash} start - Block hash to start at.
* @param {Bloom} filter - Bloom filter containing tx and address hashes.
* @param {Function} iter - Iterator.
@@ -1078,6 +1096,7 @@ Chain.prototype.scan = co(function* scan(start, filter, iter) {
* Reset the chain to the desired timestamp (within 2
* hours). This is useful for replaying the blockchain
* download for SPV.
+ * @method
* @param {Number} ts - Timestamp.
* @returns {Promise}
*/
@@ -1094,6 +1113,7 @@ Chain.prototype.resetTime = co(function* resetTime(ts) {
/**
* Reset the chain to the desired timestamp without a lock.
* @private
+ * @method
* @param {Number} ts - Timestamp.
* @returns {Promise}
*/
@@ -1109,6 +1129,7 @@ Chain.prototype._resetTime = co(function* resetTime(ts) {
/**
* Add a block to the chain, perform all necessary verification.
+ * @method
* @param {Block} block
* @returns {Promise}
*/
@@ -1125,6 +1146,7 @@ Chain.prototype.add = co(function* add(block) {
/**
* Add a block to the chain without a lock.
+ * @method
* @private
* @param {Block} block
* @returns {Promise}
@@ -1557,6 +1579,7 @@ Chain.prototype.removeInvalid = function removeInvalid(hash) {
/**
* Test the chain to see if it contains
* a block, or has recently seen a block.
+ * @method
* @param {Hash} hash
* @returns {Promise} - Returns Boolean.
*/
@@ -1626,6 +1649,7 @@ Chain.prototype.hasPending = function hasPending(hash) {
/**
* Get coin viewpoint.
+ * @method
* @param {TX} tx
* @returns {Promise} - Returns {@link CoinView}.
*/
@@ -1700,6 +1724,7 @@ Chain.prototype.getProgress = function getProgress() {
/**
* Calculate chain locator (an array of hashes).
+ * @method
* @param {Hash} start - Height or hash to treat as the tip.
* The current tip will be used if not present. Note that this can be a
* non-existent hash, which is useful for headers-first locators.
@@ -1717,6 +1742,7 @@ Chain.prototype.getLocator = co(function* getLocator(start) {
/**
* Calculate chain locator without a lock.
+ * @method
* @private
* @param {Hash} start
* @returns {Promise}
@@ -1826,6 +1852,7 @@ Chain.prototype.getProofTime = function getProofTime(to, from) {
/**
* Calculate the next target based on the chain tip.
+ * @method
* @returns {Promise} - returns Number
* (target is in compact/mantissa form).
*/
@@ -1836,6 +1863,7 @@ Chain.prototype.getCurrentTarget = co(function* getCurrentTarget() {
/**
* Calculate the target based on the passed-in chain entry.
+ * @method
* @param {ChainEntry} prev - Previous entry.
* @param {Block} - Current block.
* @returns {Promise} - returns Number
@@ -1936,6 +1964,7 @@ Chain.prototype.retarget = function retarget(prev, first) {
/**
* Find a locator. Analagous to bitcoind's `FindForkInGlobalIndex()`.
+ * @method
* @param {Hash[]} locator - Hashes.
* @returns {Promise} - Returns {@link Hash} (the
* hash of the latest known block).
@@ -1957,6 +1986,7 @@ Chain.prototype.findLocator = co(function* findLocator(locator) {
* Check whether a versionbits deployment is active (BIP9: versionbits).
* @example
* yield chain.isActive(tip, deployments.segwit);
+ * @method
* @see https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki
* @param {ChainEntry} prev - Previous chain entry.
* @param {String} id - Deployment id.
@@ -1970,6 +2000,7 @@ Chain.prototype.isActive = co(function* isActive(prev, deployment) {
/**
* Get chain entry state for a deployment (BIP9: versionbits).
+ * @method
* @example
* yield chain.getState(tip, deployments.segwit);
* @see https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki
@@ -2087,6 +2118,7 @@ Chain.prototype.getState = co(function* getState(prev, deployment) {
/**
* Compute the version for a new block (BIP9: versionbits).
+ * @method
* @see https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki
* @param {ChainEntry} prev - Previous chain entry (usually the tip).
* @returns {Promise} - Returns Number.
@@ -2114,6 +2146,7 @@ Chain.prototype.computeBlockVersion = co(function* computeBlockVersion(prev) {
/**
* Get the current deployment state of the chain. Called on load.
+ * @method
* @private
* @returns {Promise} - Returns {@link DeploymentState}.
*/
@@ -2135,6 +2168,7 @@ Chain.prototype.getDeploymentState = co(function* getDeploymentState() {
/**
* Check transaction finality, taking into account MEDIAN_TIME_PAST
* if it is present in the lock flags.
+ * @method
* @param {ChainEntry} prev - Previous chain entry.
* @param {TX} tx
* @param {LockFlags} flags
@@ -2159,6 +2193,7 @@ Chain.prototype.verifyFinal = co(function* verifyFinal(prev, tx, flags) {
/**
* Get the necessary minimum time and height sequence locks for a transaction.
+ * @method
* @param {ChainEntry} prev
* @param {TX} tx
* @param {CoinView} view
@@ -2212,6 +2247,7 @@ Chain.prototype.getLocks = co(function* getLocks(prev, tx, view, flags) {
/**
* Verify sequence locks.
+ * @method
* @param {ChainEntry} prev
* @param {TX} tx
* @param {CoinView} view
@@ -2241,6 +2277,7 @@ Chain.prototype.verifyLocks = co(function* verifyLocks(prev, tx, view, flags) {
/**
* ChainOptions
+ * @alias module:blockchain.ChainOptions
* @constructor
* @param {Object} options
*/
@@ -2375,6 +2412,7 @@ ChainOptions.fromOptions = function fromOptions(options) {
/**
* Represents the deployment state of the chain.
+ * @alias module:blockchain.DeploymentState
* @constructor
* @property {VerifyFlags} flags
* @property {LockFlags} lockFlags
@@ -2457,6 +2495,7 @@ DeploymentState.prototype.hasWitness = function hasWitness() {
/**
* LockTimes
* @constructor
+ * @ignore
*/
function LockTimes(height, time) {
@@ -2467,6 +2506,7 @@ function LockTimes(height, time) {
/**
* ContextResult
* @constructor
+ * @ignore
*/
function ContextResult(view, state) {
diff --git a/lib/blockchain/chaindb.js b/lib/blockchain/chaindb.js
index 39ae4fdec..f4128d7bf 100644
--- a/lib/blockchain/chaindb.js
+++ b/lib/blockchain/chaindb.js
@@ -1,7 +1,7 @@
/*!
* chaindb.js - blockchain data management for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -33,7 +33,7 @@ var DUMMY = new Buffer([0]);
/**
* The database backend for the {@link Chain} object.
- * @exports ChainDB
+ * @alias module:blockchain.ChainDB
* @constructor
* @param {Chain} chain
* @param {Boolean?} options.prune - Whether to prune the chain.
@@ -80,6 +80,7 @@ ChainDB.layout = layout;
/**
* Open the chain db, wait for the database to load.
+ * @method
* @alias ChainDB#open
* @returns {Promise}
*/
@@ -210,6 +211,7 @@ ChainDB.prototype.drop = function drop() {
/**
* Commit current batch.
+ * @method
* @returns {Promise}
*/
@@ -277,6 +279,7 @@ ChainDB.prototype.getCache = function getCache(block) {
/**
* Get the height of a block by hash.
+ * @method
* @param {Hash} hash
* @returns {Promise} - Returns Number.
*/
@@ -308,6 +311,7 @@ ChainDB.prototype.getHeight = co(function* getHeight(hash) {
/**
* Get the hash of a block by height. Note that this
* will only return hashes in the main chain.
+ * @method
* @param {Number} height
* @returns {Promise} - Returns {@link Hash}.
*/
@@ -338,6 +342,7 @@ ChainDB.prototype.getHash = co(function* getHash(height) {
/**
* Retrieve a chain entry by height.
+ * @method
* @param {Number} height
* @returns {Promise} - Returns {@link ChainEntry}.
*/
@@ -379,6 +384,7 @@ ChainDB.prototype.getEntryByHeight = co(function* getEntryByHeight(height) {
/**
* Retrieve a chain entry by hash.
+ * @method
* @param {Hash} hash
* @returns {Promise} - Returns {@link ChainEntry}.
*/
@@ -425,6 +431,7 @@ ChainDB.prototype.getEntry = function getEntry(block) {
/**
* Test whether the chain contains a block.
+ * @method
* @param {Hash} hash
* @returns {Promise} - Returns Boolean.
*/
@@ -445,6 +452,7 @@ ChainDB.prototype.getTip = function getTip() {
/**
* Retrieve the tip entry from the tip record.
+ * @method
* @returns {Promise} - Returns {@link ChainState}.
*/
@@ -459,6 +467,7 @@ ChainDB.prototype.getState = co(function* getState() {
/**
* Write genesis block to database.
+ * @method
* @returns {Promise}
*/
@@ -474,6 +483,7 @@ ChainDB.prototype.saveGenesis = co(function* saveGenesis() {
/**
* Retrieve the database flags.
+ * @method
* @returns {Promise} - Returns {@link ChainFlags}.
*/
@@ -488,6 +498,7 @@ ChainDB.prototype.getFlags = co(function* getFlags() {
/**
* Verify current options against db options.
+ * @method
* @returns {Promise}
*/
@@ -504,6 +515,7 @@ ChainDB.prototype.verifyFlags = co(function* verifyFlags() {
/**
* Get state caches.
+ * @method
* @returns {Promise} - Returns {@link StateCache}.
*/
@@ -563,6 +575,7 @@ ChainDB.prototype.writeDeployments = function writeDeployments(batch) {
/**
* Check for outdated deployments.
+ * @method
* @private
* @returns {Promise}
*/
@@ -599,6 +612,7 @@ ChainDB.prototype.checkDeployments = co(function* checkDeployments() {
/**
* Potentially invalidate state cache.
+ * @method
* @returns {Promise}
*/
@@ -627,6 +641,7 @@ ChainDB.prototype.verifyDeployments = co(function* verifyDeployments() {
/**
* Invalidate state cache.
+ * @method
* @private
* @returns {Promise}
*/
@@ -647,6 +662,7 @@ ChainDB.prototype.invalidateCache = co(function* invalidateCache(bit, batch) {
/**
* Get the _next_ block hash (does not work by height).
+ * @method
* @param {Hash} hash
* @returns {Promise} - Returns {@link Hash}.
*/
@@ -662,6 +678,7 @@ ChainDB.prototype.getNextHash = co(function* getNextHash(hash) {
/**
* Check to see if a block is on the main chain.
+ * @method
* @param {ChainEntry|Hash} hash
* @returns {Promise} - Returns Boolean.
*/
@@ -724,6 +741,7 @@ ChainDB.prototype.getTips = function getTips() {
/**
* Get a coin (unspents only).
+ * @method
* @param {Hash} hash
* @param {Number} index
* @returns {Promise} - Returns {@link Coin}.
@@ -754,6 +772,7 @@ ChainDB.prototype.getCoin = co(function* getCoin(hash, index) {
/**
* Get coins (unspents only).
+ * @method
* @param {Hash} hash
* @returns {Promise} - Returns {@link Coins}.
*/
@@ -790,6 +809,7 @@ ChainDB.prototype.hasCoins = function hasCoins(hash) {
/**
* Get coin viewpoint.
+ * @method
* @param {TX} tx
* @returns {Promise} - Returns {@link CoinView}.
*/
@@ -818,6 +838,7 @@ ChainDB.prototype.getCoinView = co(function* getCoinView(tx) {
/**
* Get coin viewpoint (historical).
+ * @method
* @param {TX} tx
* @returns {Promise} - Returns {@link CoinView}.
*/
@@ -846,6 +867,7 @@ ChainDB.prototype.getSpentView = co(function* getSpentView(tx) {
/**
* Get coins necessary to be resurrected during a reorg.
+ * @method
* @param {Hash} hash
* @returns {Promise} - Returns {@link Coin}[].
*/
@@ -859,6 +881,7 @@ ChainDB.prototype.getUndoCoins = co(function* getUndoCoins(hash) {
/**
* Retrieve a block from the database (not filled with coins).
+ * @method
* @param {Hash} hash
* @returns {Promise} - Returns {@link Block}.
*/
@@ -874,6 +897,7 @@ ChainDB.prototype.getBlock = co(function* getBlock(hash) {
/**
* Retrieve a block from the database (not filled with coins).
+ * @method
* @param {Hash} hash
* @returns {Promise} - Returns {@link Block}.
*/
@@ -894,6 +918,7 @@ ChainDB.prototype.getRawBlock = co(function* getRawBlock(block) {
/**
* Get a historical block coin viewpoint.
+ * @method
* @param {Block} hash
* @returns {Promise} - Returns {@link CoinView}.
*/
@@ -936,6 +961,7 @@ ChainDB.prototype.getBlockView = co(function* getBlockView(block) {
/**
* Get a transaction with metadata.
+ * @method
* @param {Hash} hash
* @returns {Promise} - Returns {@link TXMeta}.
*/
@@ -956,6 +982,7 @@ ChainDB.prototype.getMeta = co(function* getMeta(hash) {
/**
* Retrieve a transaction.
+ * @method
* @param {Hash} hash
* @returns {Promise} - Returns {@link TX}.
*/
@@ -981,6 +1008,7 @@ ChainDB.prototype.hasTX = function hasTX(hash) {
/**
* Get all coins pertinent to an address.
+ * @method
* @param {Address[]} addresses
* @returns {Promise} - Returns {@link Coin}[].
*/
@@ -1022,6 +1050,7 @@ ChainDB.prototype.getCoinsByAddress = co(function* getCoinsByAddress(addresses)
/**
* Get all transaction hashes to an address.
+ * @method
* @param {Address[]} addresses
* @returns {Promise} - Returns {@link Hash}[].
*/
@@ -1055,6 +1084,7 @@ ChainDB.prototype.getHashesByAddress = co(function* getHashesByAddress(addresses
/**
* Get all transactions pertinent to an address.
+ * @method
* @param {Address[]} addresses
* @returns {Promise} - Returns {@link TX}[].
*/
@@ -1074,6 +1104,7 @@ ChainDB.prototype.getTXByAddress = co(function* getTXByAddress(addresses) {
/**
* Get all transactions pertinent to an address.
+ * @method
* @param {Address[]} addresses
* @returns {Promise} - Returns {@link TXMeta}[].
*/
@@ -1102,6 +1133,7 @@ ChainDB.prototype.getMetaByAddress = co(function* getTXByAddress(addresses) {
/**
* Scan the blockchain for transactions containing specified address hashes.
+ * @method
* @param {Hash} start - Block hash to start at.
* @param {Bloom} filter - Bloom filter containing tx and address hashes.
* @param {Function} iter - Iterator.
@@ -1196,6 +1228,7 @@ ChainDB.prototype.scan = co(function* scan(start, filter, iter) {
* connect it as the tip. Note that this method
* does _not_ perform any verification which is
* instead performed in {@link Chain#add}.
+ * @method
* @param {ChainEntry} entry
* @param {Block} block
* @param {CoinView?} view - Will not connect if null.
@@ -1215,6 +1248,7 @@ ChainDB.prototype.save = co(function* save(entry, block, view) {
/**
* Save an entry without a batch.
+ * @method
* @private
* @param {ChainEntry} entry
* @param {Block} block
@@ -1261,6 +1295,7 @@ ChainDB.prototype._save = co(function* save(entry, block, view) {
/**
* Reconnect the block to the chain.
+ * @method
* @param {ChainEntry} entry
* @param {Block} block
* @param {CoinView} view
@@ -1280,6 +1315,7 @@ ChainDB.prototype.reconnect = co(function* reconnect(entry, block, view) {
/**
* Reconnect block without a batch.
+ * @method
* @private
* @param {ChainEntry} entry
* @param {Block} block
@@ -1312,6 +1348,7 @@ ChainDB.prototype._reconnect = co(function* reconnect(entry, block, view) {
/**
* Disconnect block from the chain.
+ * @method
* @param {ChainEntry} entry
* @param {Block} block
* @returns {Promise}
@@ -1337,6 +1374,7 @@ ChainDB.prototype.disconnect = co(function* disconnect(entry, block) {
/**
* Disconnect block without a batch.
* @private
+ * @method
* @param {ChainEntry} entry
* @param {Block} block
* @returns {Promise} - Returns {@link CoinView}.
@@ -1387,6 +1425,7 @@ ChainDB.prototype.saveUpdates = function saveUpdates() {
/**
* Reset the chain to a height or hash. Useful for replaying
* the blockchain download for SPV.
+ * @method
* @param {Hash|Number} block - hash/height
* @returns {Promise}
*/
@@ -1464,6 +1503,7 @@ ChainDB.prototype.reset = co(function* reset(block) {
/**
* Remove all alternate chains.
+ * @method
* @returns {Promise}
*/
@@ -1488,6 +1528,7 @@ ChainDB.prototype.removeChains = co(function* removeChains() {
/**
* Remove an alternate chain.
+ * @method
* @private
* @param {Hash} hash - Alternate chain tip.
* @returns {Promise}
@@ -1525,6 +1566,7 @@ ChainDB.prototype._removeChain = co(function* removeChain(hash) {
/**
* Save a block (not an entry) to the
* database and potentially connect the inputs.
+ * @method
* @param {ChainEntry} entry
* @param {Block} block
* @param {CoinView?} view
@@ -1550,6 +1592,7 @@ ChainDB.prototype.saveBlock = co(function* saveBlock(entry, block, view) {
/**
* Remove a block (not an entry) to the database.
* Disconnect inputs.
+ * @method
* @param {ChainEntry} entry
* @returns {Promise} - Returns {@link Block}.
*/
@@ -1596,6 +1639,7 @@ ChainDB.prototype.saveView = function saveView(view) {
/**
* Connect block inputs.
+ * @method
* @param {ChainEntry} entry
* @param {Block} block
* @param {CoinView} view
@@ -1652,6 +1696,7 @@ ChainDB.prototype.connectBlock = co(function* connectBlock(entry, block, view) {
/**
* Disconnect block inputs.
+ * @method
* @param {ChainEntry} entry
* @param {Block} block
* @returns {Promise} - Returns {@link CoinView}.
@@ -1714,6 +1759,7 @@ ChainDB.prototype.disconnectBlock = co(function* disconnectBlock(entry, block) {
/**
* Prune a block from the chain and
* add current block to the prune queue.
+ * @method
* @private
* @param {ChainEntry} entry
* @returns {Promise}
@@ -1857,7 +1903,8 @@ ChainDB.prototype.unindexTX = function unindexTX(tx, view) {
};
/**
- * Chain Options
+ * Chain Flags
+ * @alias module:blockchain.ChainFlags
* @constructor
*/
@@ -1989,6 +2036,7 @@ ChainFlags.fromRaw = function fromRaw(data) {
/**
* Chain State
+ * @alias module:blockchain.ChainState
* @constructor
*/
@@ -2064,6 +2112,7 @@ ChainState.fromRaw = function fromRaw(data) {
/**
* StateCache
+ * @alias module:blockchain.StateCache
* @constructor
*/
@@ -2138,6 +2187,7 @@ StateCache.prototype.insert = function insert(bit, hash, state) {
/**
* CacheUpdate
* @constructor
+ * @ignore
*/
function CacheUpdate(bit, hash, state) {
diff --git a/lib/blockchain/chainentry.js b/lib/blockchain/chainentry.js
index 1721df137..83d31afb7 100644
--- a/lib/blockchain/chainentry.js
+++ b/lib/blockchain/chainentry.js
@@ -1,7 +1,7 @@
/*!
* chainentry.js - chainentry object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -25,13 +25,13 @@ var co = require('../utils/co');
* chainwork _with_ the entry in order to
* avoid reading the entire chain index on
* boot and recalculating the chainworks.
- * @exports ChainEntry
+ * @alias module:blockchain.ChainEntry
* @constructor
* @param {Chain} chain
* @param {Object} options
* @param {ChainEntry} prev
* @property {Hash} hash
- * @property {Number} version - Transaction version. Note that BCoin reads
+ * @property {Number} version - Transaction version. Note that Bcoin reads
* versions as unsigned even though they are signed at the protocol level.
* This value will never be negative.
* @property {Hash} prevBlock
@@ -182,6 +182,7 @@ ChainEntry.prototype.getRetargetAncestors = function getRetargetAncestors() {
/**
* Collect ancestors.
+ * @method
* @param {Number} max - Number of ancestors.
* @returns {Promise} - Returns ChainEntry[].
*/
@@ -224,6 +225,7 @@ ChainEntry.prototype.getAncestors = co(function* getAncestors(max) {
/**
* Test whether the entry is in the main chain.
+ * @method
* @returns {Promise} - Return Boolean.
*/
@@ -251,6 +253,7 @@ ChainEntry.prototype.isMainChain = co(function* isMainChain() {
/**
* Get ancestor by `height`.
+ * @method
* @param {Number} height
* @returns {Promise} - Returns ChainEntry[].
*/
@@ -286,6 +289,7 @@ ChainEntry.prototype.getPrevious = function getPrevious() {
/**
* Get next entry.
+ * @method
* @returns {Promise} - Returns ChainEntry.
*/
@@ -298,6 +302,7 @@ ChainEntry.prototype.getNext = co(function* getNext() {
/**
* Get next entry.
+ * @method
* @returns {Promise} - Returns ChainEntry.
*/
@@ -337,6 +342,7 @@ ChainEntry.prototype.getMedianTime = function getMedianTime(ancestors) {
/**
* Get median time past asynchronously (see {@link ChainEntry#getMedianTime}).
+ * @method
* @returns {Promise} - Returns Number.
*/
diff --git a/lib/blockchain/common.js b/lib/blockchain/common.js
index 13b8b6564..1c245a951 100644
--- a/lib/blockchain/common.js
+++ b/lib/blockchain/common.js
@@ -1,12 +1,16 @@
/*!
* common.js - bitcoin constants for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module blockchain/common
+ */
+
/**
* Locktime flags.
* @enum {Number}
diff --git a/lib/blockchain/index.js b/lib/blockchain/index.js
index e8ab9ed79..c1211fd7a 100644
--- a/lib/blockchain/index.js
+++ b/lib/blockchain/index.js
@@ -1,5 +1,9 @@
'use strict';
+/**
+ * @module blockchain
+ */
+
exports.common = require('./common');
exports.Chain = require('./chain');
exports.ChainDB = require('./chaindb');
diff --git a/lib/blockchain/layout-browser.js b/lib/blockchain/layout-browser.js
index 165871916..b755428c9 100644
--- a/lib/blockchain/layout-browser.js
+++ b/lib/blockchain/layout-browser.js
@@ -1,6 +1,6 @@
/*!
* layout-browser.js - chaindb layout for browser.
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/blockchain/layout.js b/lib/blockchain/layout.js
index ceb568f72..0249882f9 100644
--- a/lib/blockchain/layout.js
+++ b/lib/blockchain/layout.js
@@ -1,6 +1,6 @@
/*!
* layout.js - blockchain data layout for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/btc/amount.js b/lib/btc/amount.js
index 1788c9d57..57ac7fa0d 100644
--- a/lib/btc/amount.js
+++ b/lib/btc/amount.js
@@ -1,6 +1,6 @@
/*!
* amount.js - amount object for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -11,6 +11,7 @@ var util = require('../utils/util');
/**
* Represents a bitcoin amount (satoshis internally).
+ * @alias module:btc.Amount
* @constructor
* @param {(String|Number)?} value
* @param {String?} unit
diff --git a/lib/btc/index.js b/lib/btc/index.js
index d019f898a..d222c8586 100644
--- a/lib/btc/index.js
+++ b/lib/btc/index.js
@@ -1,4 +1,8 @@
'use strict';
+/**
+ * @module btc
+ */
+
exports.Amount = require('./amount');
exports.URI = require('./uri');
diff --git a/lib/btc/uri.js b/lib/btc/uri.js
index e293822b8..263905a49 100644
--- a/lib/btc/uri.js
+++ b/lib/btc/uri.js
@@ -1,6 +1,6 @@
/**
* uri.js - bitcoin uri parsing for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -13,6 +13,7 @@ var assert = require('assert');
/**
* Represents a bitcoin URI.
+ * @alias module:btc.URI
* @constructor
* @param {Object|String} options
* @property {Address} address
diff --git a/lib/coins/coins.js b/lib/coins/coins.js
index 5615e81c0..0c3472035 100644
--- a/lib/coins/coins.js
+++ b/lib/coins/coins.js
@@ -1,6 +1,6 @@
/*!
* coins.js - coins object for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -19,6 +19,7 @@ var decompress = compressor.decompress;
/**
* Represents the outputs for a single transaction.
+ * @alias module:coins.Coins
* @constructor
* @param {Object?} options - Options object.
* @property {Hash} hash - Transaction hash.
@@ -611,8 +612,8 @@ Coins.fromTX = function fromTX(tx, height) {
* pointer to that coin in the Coins buffer, as
* well as a size. Parsing and decompression
* is done only if that coin is being redeemed.
+ * @alias module:coins.CoinEntry
* @constructor
- * @private
* @property {Number} offset
* @property {Number} size
* @property {Buffer} raw
diff --git a/lib/coins/coinview.js b/lib/coins/coinview.js
index 6bfe7a3e0..2f08475a1 100644
--- a/lib/coins/coinview.js
+++ b/lib/coins/coinview.js
@@ -1,6 +1,6 @@
/*!
* coinview.js - coin viewpoint object for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -15,10 +15,10 @@ var BufferWriter = require('../utils/writer');
var CoinEntry = Coins.CoinEntry;
/**
- * A collection of {@link Coins} objects.
+ * Represents a coin viewpoint:
+ * a snapshot of {@link Coins} objects.
+ * @alias module:coins.CoinView
* @constructor
- * @param {Object} map - A hash-to-coins map.
- * @param {UndoCoins} undo - Spent coins.
* @property {Object} map
* @property {UndoCoins} undo
*/
@@ -298,6 +298,7 @@ CoinView.prototype.isCoinbase = function isCoinbase(input) {
/**
* Retrieve coins from database.
+ * @method
* @param {ChainDB} db
* @param {TX} tx
* @returns {Promise} - Returns {@link Coins}.
@@ -320,6 +321,7 @@ CoinView.prototype.readCoins = co(function* readCoins(db, hash) {
/**
* Read all input coins into unspent map.
+ * @method
* @param {ChainDB} db
* @param {TX} tx
* @returns {Promise} - Returns {Boolean}.
@@ -340,6 +342,7 @@ CoinView.prototype.ensureInputs = co(function* ensureInputs(db, tx) {
/**
* Spend coins for transaction.
+ * @method
* @param {ChainDB} db
* @param {TX} tx
* @returns {Promise} - Returns {Boolean}.
diff --git a/lib/coins/compress.js b/lib/coins/compress.js
index 5197c6022..978e52f6b 100644
--- a/lib/coins/compress.js
+++ b/lib/coins/compress.js
@@ -1,11 +1,16 @@
/*!
* compress.js - coin compressor for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module coins/compress
+ * @ignore
+ */
+
var assert = require('assert');
var ec = require('../crypto/ec');
var encoding = require('../utils/encoding');
diff --git a/lib/coins/index.js b/lib/coins/index.js
index 5ef8c9e67..ef1d147a9 100644
--- a/lib/coins/index.js
+++ b/lib/coins/index.js
@@ -1,5 +1,9 @@
'use strict';
+/**
+ * @module coins
+ */
+
exports.Coins = require('./coins');
exports.CoinView = require('./coinview');
exports.compress = require('./compress');
diff --git a/lib/coins/undocoins.js b/lib/coins/undocoins.js
index 022ed55fb..19ef2e19a 100644
--- a/lib/coins/undocoins.js
+++ b/lib/coins/undocoins.js
@@ -1,6 +1,6 @@
/*!
* undocoins.js - undocoins object for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -22,6 +22,7 @@ var decompress = compressor.decompress;
* during a reorg. The undo coins store all
* spent coins in a single record per block
* (in a compressed format).
+ * @alias module:coins.UndoCoins
* @constructor
* @property {UndoCoin[]} items
*/
@@ -176,6 +177,7 @@ UndoCoins.prototype.apply = function apply(view, outpoint) {
/**
* UndoCoin
+ * @alias module:coins.UndoCoin
* @constructor
* @property {CoinEntry|null} entry
* @property {Output|null} output
diff --git a/lib/crypto/aes.js b/lib/crypto/aes.js
index 2e61e881a..dd94abb72 100644
--- a/lib/crypto/aes.js
+++ b/lib/crypto/aes.js
@@ -1,6 +1,6 @@
/*!
* aes.js - aes128/192/256 for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*
* Ported from:
@@ -14,12 +14,18 @@
var assert = require('assert');
var U32Array = typeof Uint32Array === 'function' ? Uint32Array : Array;
+
+/**
+ * @exports crypto/aes
+ * @ignore
+ */
+
var AES = exports;
/**
* An AES key object for encrypting
* and decrypting blocks.
- * @exports AESKey
+ * @alias module:crypto/aes.AESKey
* @constructor
* @param {Buffer} key
* @param {Number} bits
@@ -467,7 +473,7 @@ AESKey.prototype.decryptBlock = function decryptBlock(input) {
/**
* AES cipher.
- * @exports AESCipher
+ * @alias module:crypto/aes.AESCipher
* @constructor
* @param {Buffer} key
* @param {Buffer} iv
@@ -554,7 +560,7 @@ AESCipher.prototype.final = function final() {
/**
* AES decipher.
- * @exports AESDecipher
+ * @alias module:crypto/aes.AESDecipher
* @constructor
* @param {Buffer} key
* @param {Buffer} iv
diff --git a/lib/crypto/backend-browser.js b/lib/crypto/backend-browser.js
index af91b13e8..ac1f00e8b 100644
--- a/lib/crypto/backend-browser.js
+++ b/lib/crypto/backend-browser.js
@@ -1,6 +1,6 @@
/*!
* backend-browser.js - browser crypto backend for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/crypto/backend.js b/lib/crypto/backend.js
index 049e2bdbf..f06e6786b 100644
--- a/lib/crypto/backend.js
+++ b/lib/crypto/backend.js
@@ -1,6 +1,6 @@
/*!
* backend.js - crypto backend for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/crypto/chachapoly.js b/lib/crypto/chachapoly.js
index c4d9f6fda..23fcaf946 100644
--- a/lib/crypto/chachapoly.js
+++ b/lib/crypto/chachapoly.js
@@ -1,6 +1,6 @@
/*!
* chachapoly.js - chacha20/poly1305 for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -11,10 +11,14 @@ var native = require('../utils/native').binding;
var BIG_ENDIAN = new Int8Array(new Int16Array([1]).buffer)[0] === 0;
+/**
+ * @module crypto/chachapoly
+ */
+
/**
* ChaCha20 (used for bip151)
* @see https://tools.ietf.org/html/rfc7539#section-2
- * @exports ChaCha20
+ * @alias module:crypto/chachapoly.ChaCha20
* @constructor
*/
@@ -206,7 +210,7 @@ function rotl32(w, b) {
* Poly1305 (used for bip151)
* @see https://github.com/floodyberry/poly1305-donna
* @see https://tools.ietf.org/html/rfc7539#section-2.5
- * @exports Poly1305
+ * @alias module:crypto/chachapoly.Poly1305
* @constructor
*/
@@ -501,6 +505,7 @@ if (native)
* @exports AEAD
* @see https://github.com/openssh/openssh-portable
* @see https://tools.ietf.org/html/rfc7539#section-2.8
+ * @alias module:crypto/chachapoly.AEAD
* @constructor
*/
diff --git a/lib/crypto/crypto.js b/lib/crypto/crypto.js
index b9abf7ff7..b8b9ffbb4 100644
--- a/lib/crypto/crypto.js
+++ b/lib/crypto/crypto.js
@@ -1,7 +1,7 @@
/*!
* crypto.js - crypto for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -10,6 +10,12 @@
var backend = require('./backend');
var native = require('../utils/native').binding;
var scrypt = require('./scrypt');
+
+/**
+ * @exports crypto/crypto
+ * @ignore
+ */
+
var crypto = exports;
/**
@@ -418,8 +424,12 @@ crypto.randomRange = function randomRange(min, max) {
return Math.floor((num / 0x100000000) * (max - min) + min);
};
-/*
- * Helpers
+/**
+ * Merkle Tree
+ * @constructor
+ * @ignore
+ * @param {Buffer[]} nodes
+ * @param {Boolean} malleated
*/
function MerkleTree(nodes, malleated) {
@@ -427,6 +437,14 @@ function MerkleTree(nodes, malleated) {
this.malleated = malleated;
}
+/**
+ * Merkle Root
+ * @constructor
+ * @ignore
+ * @param {Buffer} hash
+ * @param {Boolean} malleated
+ */
+
function MerkleRoot(hash, malleated) {
this.hash = hash;
this.malleated = malleated;
diff --git a/lib/crypto/ec-elliptic.js b/lib/crypto/ec-elliptic.js
index 9d96c45a8..8b94cb4b0 100644
--- a/lib/crypto/ec-elliptic.js
+++ b/lib/crypto/ec-elliptic.js
@@ -1,7 +1,7 @@
/*!
* ec.js - ecdsa wrapper for elliptic
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -15,7 +15,8 @@ var curve = secp256k1.curve;
var BN = require('bn.js');
/**
- * @exports ec
+ * @exports crypto/ec-elliptic
+ * @ignore
*/
var ec = exports;
diff --git a/lib/crypto/ec-secp256k1.js b/lib/crypto/ec-secp256k1.js
index fc73e150d..4b853a7b7 100644
--- a/lib/crypto/ec-secp256k1.js
+++ b/lib/crypto/ec-secp256k1.js
@@ -1,7 +1,7 @@
/*!
* ec-secp256k1.js - ecdsa wrapper for secp256k1
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -12,6 +12,12 @@ var util = require('../utils/util');
var backend = require('./backend');
var secp256k1 = require('secp256k1');
+/**
+ * @exports crypto/ec
+ */
+
+var ec = exports;
+
/*
* Constants
*/
@@ -25,15 +31,10 @@ var HALF_ORDER = new Buffer(
'7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0',
'hex');
-/**
- * @exports ec
- */
-
-var ec = exports;
-
/**
* Whether we're using native bindings.
* @const {Boolean}
+ * @private
*/
ec.binding = true;
diff --git a/lib/crypto/ec.js b/lib/crypto/ec.js
index 864ccda46..f76f15f02 100644
--- a/lib/crypto/ec.js
+++ b/lib/crypto/ec.js
@@ -1,6 +1,6 @@
/*!
* ec.js - ecdsa wrapper for secp256k1 and elliptic
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/crypto/index.js b/lib/crypto/index.js
index f97542bef..306ceb9a7 100644
--- a/lib/crypto/index.js
+++ b/lib/crypto/index.js
@@ -1,49 +1,349 @@
'use strict';
+/**
+ * @module crypto
+ */
+
var crypto = require('./crypto');
+/**
+ * Crypto module.
+ * @ignore
+ */
+
exports.crypto = crypto;
+
+/**
+ * Hash with chosen algorithm.
+ * @function
+ * @param {String} alg
+ * @param {Buffer} data
+ * @returns {Buffer}
+ */
+
exports.hash = crypto.hash;
-exports.hashAsync = crypto.hashAsync;
+
+/**
+ * Hash with ripemd160.
+ * @function
+ * @param {Buffer} data
+ * @returns {Buffer}
+ */
+
exports.ripemd160 = crypto.ripemd160;
+
+/**
+ * Hash with sha1.
+ * @function
+ * @param {Buffer} data
+ * @returns {Buffer}
+ */
+
exports.sha1 = crypto.sha1;
+
+/**
+ * Hash with sha256.
+ * @function
+ * @param {Buffer} data
+ * @returns {Buffer}
+ */
+
exports.sha256 = crypto.sha256;
+
+/**
+ * Hash with sha256 and ripemd160 (OP_HASH160).
+ * @function
+ * @param {Buffer} data
+ * @returns {Buffer}
+ */
+
exports.hash160 = crypto.hash160;
+
+/**
+ * Hash with sha256 twice (OP_HASH256).
+ * @function
+ * @param {Buffer} data
+ * @returns {Buffer}
+ */
+
exports.hash256 = crypto.hash256;
-exports.hash256Async = crypto.hash256Async;
+
+/**
+ * Create an HMAC.
+ * @function
+ * @param {String} alg
+ * @param {Buffer} data
+ * @param {Buffer} key
+ * @returns {Buffer} HMAC
+ */
+
exports.hmac = crypto.hmac;
-exports.hmacAsync = crypto.hmacAsync;
+
+/**
+ * Perform key derivation using PBKDF2.
+ * @function
+ * @param {Buffer} key
+ * @param {Buffer} salt
+ * @param {Number} iter
+ * @param {Number} len
+ * @param {String} alg
+ * @returns {Buffer}
+ */
+
exports.pbkdf2 = crypto.pbkdf2;
+
+/**
+ * Execute pbkdf2 asynchronously.
+ * @function
+ * @param {Buffer} key
+ * @param {Buffer} salt
+ * @param {Number} iter
+ * @param {Number} len
+ * @param {String} alg
+ * @returns {Promise}
+ */
+
exports.pbkdf2Async = crypto.pbkdf2Async;
+
+/**
+ * Perform key derivation using scrypt.
+ * @function
+ * @param {Buffer} passwd
+ * @param {Buffer} salt
+ * @param {Number} N
+ * @param {Number} r
+ * @param {Number} p
+ * @param {Number} len
+ * @returns {Buffer}
+ */
+
exports.scrypt = crypto.scrypt;
+
+/**
+ * Execute scrypt asynchronously.
+ * @function
+ * @param {Buffer} passwd
+ * @param {Buffer} salt
+ * @param {Number} N
+ * @param {Number} r
+ * @param {Number} p
+ * @param {Number} len
+ * @returns {Promise}
+ */
+
exports.scryptAsync = crypto.scryptAsync;
+
+/**
+ * Perform hkdf extraction.
+ * @function
+ * @param {Buffer} ikm
+ * @param {Buffer} key
+ * @param {String} alg
+ * @returns {Buffer}
+ */
+
exports.hkdfExtract = crypto.hkdfExtract;
+
+/**
+ * Perform hkdf expansion.
+ * @function
+ * @param {Buffer} prk
+ * @param {Buffer} info
+ * @param {Number} len
+ * @param {String} alg
+ * @returns {Buffer}
+ */
+
exports.hkdfExpand = crypto.hkdfExpand;
+
+/**
+ * Build a merkle tree from leaves.
+ * Note that this will mutate the `leaves` array!
+ * @function
+ * @param {Buffer[]} leaves
+ * @returns {MerkleTree}
+ */
+
exports.createMerkleTree = crypto.createMerkleTree;
+
+/**
+ * Calculate merkle root from leaves.
+ * @function
+ * @param {Buffer[]} leaves
+ * @returns {MerkleRoot}
+ */
+
exports.createMerkleRoot = crypto.createMerkleRoot;
+
+/**
+ * Collect a merkle branch at vector index.
+ * @function
+ * @param {Number} index
+ * @param {Buffer[]} leaves
+ * @returns {Buffer[]} branch
+ */
+
exports.createMerkleBranch = crypto.createMerkleBranch;
+
+/**
+ * Check a merkle branch at vector index.
+ * @function
+ * @param {Buffer} hash
+ * @param {Buffer[]} branch
+ * @param {Number} index
+ * @returns {Buffer} Hash.
+ */
+
exports.verifyMerkleBranch = crypto.verifyMerkleBranch;
+
+/**
+ * Encrypt with aes-256-cbc.
+ * @function
+ * @param {Buffer} data
+ * @param {Buffer} key - 256 bit key.
+ * @param {Buffer} iv - 128 bit initialization vector.
+ * @returns {Buffer}
+ */
+
exports.encipher = crypto.encipher;
+
+/**
+ * Decrypt with aes-256-cbc.
+ * @function
+ * @param {Buffer} data
+ * @param {Buffer} key - 256 bit key.
+ * @param {Buffer} iv - 128 bit initialization vector.
+ * @returns {Buffer}
+ */
+
exports.decipher = crypto.decipher;
+
+/**
+ * memcmp in constant time (can only return true or false).
+ * This protects us against timing attacks when
+ * comparing an input against a secret string.
+ * @function
+ * @see https://cryptocoding.net/index.php/Coding_rules
+ * @see `$ man 3 memcmp` (NetBSD's consttime_memequal)
+ * @param {Buffer} a
+ * @param {Buffer} b
+ * @returns {Boolean}
+ */
+
exports.ccmp = crypto.ccmp;
+
+/**
+ * A maybe-secure memzero.
+ * @function
+ * @param {Buffer} data
+ */
+
exports.cleanse = crypto.cleanse;
+
+/**
+ * Generate some random bytes.
+ * @function
+ * @param {Number} size
+ * @returns {Buffer}
+ */
+
exports.randomBytes = crypto.randomBytes;
+
+/**
+ * Generate a random uint32.
+ * Probably more cryptographically sound than
+ * `Math.random()`.
+ * @function
+ * @returns {Number}
+ */
+
exports.randomInt = crypto.randomInt;
+
+/**
+ * Generate a random number within a range.
+ * Probably more cryptographically sound than
+ * `Math.random()`.
+ * @function
+ * @param {Number} min - Inclusive.
+ * @param {Number} max - Exclusive.
+ * @returns {Number}
+ */
+
exports.randomRange = crypto.randomRange;
+/**
+ * chachapoly module
+ * @see module:crypto/chachapoly
+ */
+
exports.chachapoly = require('./chachapoly');
+
+/**
+ * ChaCha20
+ * @see module:crypto/chachapoly.ChaCha20
+ */
+
exports.ChaCha20 = exports.chachapoly.ChaCha20;
+
+/**
+ * Poly1305
+ * @see module:crypto/chachapoly.Poly1305
+ */
+
exports.Poly1305 = exports.chachapoly.Poly1305;
+
+/**
+ * AEAD
+ * @see module:crypto/chachapoly.AEAD
+ */
+
exports.AEAD = exports.chachapoly.AEAD;
+/**
+ * pk module
+ * @see module:crypto/pk
+ */
+
exports.pk = require('./pk');
-exports.dsa = exports.pk.rsa;
-exports.rsa = exports.pk.dsa;
+
+/**
+ * RSA
+ * @see module:crypto/pk.rsa
+ */
+
+exports.rsa = exports.pk.rsa;
+
+/**
+ * ECDSA
+ * @see module:crypto/pk.ecdsa
+ */
+
exports.ecdsa = exports.pk.ecdsa;
+/**
+ * ec module
+ * @see module:crypto/ec
+ */
+
exports.ec = require('./ec');
+/**
+ * schnorr module
+ * @see module:crypto/schnorr
+ */
+
exports.schnorr = require('./schnorr');
+/**
+ * siphash module
+ * @see module:crypto/siphash
+ */
+
exports.siphash = require('./siphash');
+
+/**
+ * siphash256
+ * @see module:crypto/siphash.siphash256
+ */
+
exports.siphash256 = exports.siphash.siphash256;
diff --git a/lib/crypto/pk-browser.js b/lib/crypto/pk-browser.js
index 5a2f5c604..965828a70 100644
--- a/lib/crypto/pk-browser.js
+++ b/lib/crypto/pk-browser.js
@@ -1,11 +1,16 @@
/*!
* pk-browser.js - public key algorithms for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module crypto/pk-browser
+ * @ignore
+ */
+
var assert = require('assert');
var BN = require('bn.js');
var elliptic = require('elliptic');
@@ -13,12 +18,20 @@ var ASN1 = require('../utils/asn1');
var backend = require('./backend');
var rsa, ecdsa;
-/*
+/**
* RSA
+ * @namespace module:crypto/pk-browser.rsa
+ * @ignore
*/
rsa = {};
+/**
+ * PKCS signature prefixes.
+ * @type {Object}
+ * @memberof module:crypto/pk-browser.rsa
+ */
+
rsa.prefixes = {
md5: new Buffer('3020300c06082a864886f70d020505000410', 'hex'),
sha1: new Buffer('3021300906052b0e03021a05000414', 'hex'),
@@ -29,6 +42,16 @@ rsa.prefixes = {
ripemd160: new Buffer('30203008060628cf060300310414', 'hex')
};
+/**
+ * Verify RSA signature.
+ * @memberof module:crypto/pk-browser.rsa
+ * @param {String} alg - Hash algorithm.
+ * @param {Buffer} msg - Signed message.
+ * @param {Buffer} sig - Signature.
+ * @param {Buffer} key - ASN1 serialized RSA key.
+ * @returns {Boolean}
+ */
+
rsa.verify = function verify(alg, msg, sig, key) {
var prefix = rsa.prefixes[alg];
var hash, len, pub;
@@ -63,6 +86,15 @@ rsa.verify = function verify(alg, msg, sig, key) {
return ok === 1;
};
+/**
+ * Sign message with RSA key.
+ * @memberof module:crypto/pk-browser.rsa
+ * @param {String} alg - Hash algorithm.
+ * @param {Buffer} msg - Signed message.
+ * @param {Buffer} key - ASN1 serialized RSA key.
+ * @returns {Buffer} Signature (DER)
+ */
+
rsa.sign = function sign(alg, msg, key) {
var prefix = rsa.prefixes[alg];
var hash, len, priv;
@@ -95,6 +127,15 @@ rsa.sign = function sign(alg, msg, key) {
return rsa.decrypt(N, D, em);
};
+/**
+ * Decrypt with modulus and exponent.
+ * @memberof module:crypto/pk-browser.rsa
+ * @param {BN} N
+ * @param {BN} D
+ * @param {Buffer} m
+ * @returns {Buffer}
+ */
+
rsa.decrypt = function decrypt(N, D, m) {
var c = new BN(m);
@@ -108,6 +149,15 @@ rsa.decrypt = function decrypt(N, D, m) {
.toArrayLike(Buffer, 'be');
};
+/**
+ * Encrypt with modulus and exponent.
+ * @memberof module:crypto/pk-browser.rsa
+ * @param {BN} N
+ * @param {BN} e
+ * @param {Buffer} m
+ * @returns {Buffer}
+ */
+
rsa.encrypt = function encrypt(N, e, m) {
return new BN(m)
.toRed(BN.red(N))
@@ -116,13 +166,26 @@ rsa.encrypt = function encrypt(N, e, m) {
.toArrayLike(Buffer, 'be');
};
-/*
+/**
* ECDSA
+ * @namespace module:crypto/pk.ecdsa
+ * @ignore
*/
ecdsa = {};
-ecdsa.verify = function verify(curve, alg, msg, key, sig) {
+/**
+ * Verify ECDSA signature.
+ * @memberof module:crypto/pk-browser.ecdsa
+ * @param {String} curve - Curve name.
+ * @param {String} alg - Hash algorithm.
+ * @param {Buffer} msg - Signed message.
+ * @param {Buffer} sig - Signature.
+ * @param {Buffer} key - ASN1 serialized ECDSA key.
+ * @returns {Boolean}
+ */
+
+ecdsa.verify = function verify(curve, alg, msg, sig, key) {
var ec, hash;
assert(curve, 'No curve selected.');
@@ -133,6 +196,16 @@ ecdsa.verify = function verify(curve, alg, msg, key, sig) {
return ec.verify(hash, sig, key);
};
+/**
+ * Sign message with ECDSA key.
+ * @memberof module:crypto/pk-browser.ecdsa
+ * @param {String} curve - Curve name.
+ * @param {String} alg - Hash algorithm.
+ * @param {Buffer} msg - Signed message.
+ * @param {Buffer} key - ASN1 serialized ECDSA key.
+ * @returns {Buffer} Signature (DER)
+ */
+
ecdsa.sign = function sign(curve, alg, msg, key) {
var ec, hash;
diff --git a/lib/crypto/pk.js b/lib/crypto/pk.js
index 83d31d22e..5b5f5b4df 100644
--- a/lib/crypto/pk.js
+++ b/lib/crypto/pk.js
@@ -1,11 +1,15 @@
/*!
* pk.js - public key algorithms for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module crypto/pk
+ */
+
var assert = require('assert');
var nodeCrypto = require('crypto');
var elliptic = require('elliptic');
@@ -13,29 +17,61 @@ var PEM = require('../utils/pem');
var backend = require('./backend');
var rsa, ecdsa;
-/*
+/**
* RSA
+ * @namespace module:crypto/pk.rsa
*/
rsa = {};
+/**
+ * Verify RSA signature.
+ * @memberof module:crypto/pk.rsa
+ * @param {String} alg - Hash algorithm.
+ * @param {Buffer} msg - Signed message.
+ * @param {Buffer} sig - Signature.
+ * @param {Buffer} key - ASN1 serialized RSA key.
+ * @returns {Boolean}
+ */
+
rsa.verify = function _verify(alg, msg, sig, key) {
var pem = toPEM('rsa', key, null, 'public key');
return verify('rsa', alg, msg, sig, pem);
};
+/**
+ * Sign message with RSA key.
+ * @memberof module:crypto/pk.rsa
+ * @param {String} alg - Hash algorithm.
+ * @param {Buffer} msg - Signed message.
+ * @param {Buffer} key - ASN1 serialized RSA key.
+ * @returns {Buffer} Signature (DER)
+ */
+
rsa.sign = function _sign(alg, msg, key) {
var pem = toPEM('rsa', key, null, 'private key');
return sign('rsa', alg, msg, pem);
};
-/*
+/**
* ECDSA
+ * @namespace module:crypto/pk.ecdsa
*/
ecdsa = {};
-ecdsa.verify = function verify(curve, msg, alg, key, sig) {
+/**
+ * Verify ECDSA signature.
+ * @memberof module:crypto/pk.ecdsa
+ * @param {String} curve - Curve name.
+ * @param {String} alg - Hash algorithm.
+ * @param {Buffer} msg - Signed message.
+ * @param {Buffer} sig - Signature.
+ * @param {Buffer} key - ASN1 serialized ECDSA key.
+ * @returns {Boolean}
+ */
+
+ecdsa.verify = function verify(curve, alg, msg, sig, key) {
var ec, hash;
assert(curve, 'No curve selected.');
@@ -46,7 +82,17 @@ ecdsa.verify = function verify(curve, msg, alg, key, sig) {
return ec.verify(hash, sig, key);
};
-ecdsa.sign = function sign(curve, msg, alg, key) {
+/**
+ * Sign message with ECDSA key.
+ * @memberof module:crypto/pk.ecdsa
+ * @param {String} curve - Curve name.
+ * @param {String} alg - Hash algorithm.
+ * @param {Buffer} msg - Signed message.
+ * @param {Buffer} key - ASN1 serialized ECDSA key.
+ * @returns {Buffer} Signature (DER)
+ */
+
+ecdsa.sign = function sign(curve, alg, msg, key) {
var ec, hash;
assert(curve, 'No curve selected.');
diff --git a/lib/crypto/schnorr.js b/lib/crypto/schnorr.js
index 80b80208f..a745b48d1 100644
--- a/lib/crypto/schnorr.js
+++ b/lib/crypto/schnorr.js
@@ -1,6 +1,6 @@
/*!
* schnorr.js - schnorr signatures for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -17,7 +17,7 @@ var curves = elliptic.curves;
var hash = curves.secp256k1.hash;
/**
- * @exports schnorr
+ * @exports crypto/schnorr
*/
var schnorr = exports;
@@ -47,6 +47,7 @@ schnorr.hash = function _hash(msg, r, hash) {
/**
* Sign message.
+ * @private
* @param {Buffer} msg
* @param {BN} priv
* @param {BN} k
diff --git a/lib/crypto/scrypt.js b/lib/crypto/scrypt.js
index b09229cad..ca84d0bbe 100644
--- a/lib/crypto/scrypt.js
+++ b/lib/crypto/scrypt.js
@@ -1,6 +1,6 @@
/*!
* scrypt.js - scrypt for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*
* Ported from:
@@ -33,6 +33,11 @@
'use strict';
+/**
+ * @module crypto/scrypt
+ * @ignore
+ */
+
var co = require('../utils/co');
var backend = require('./backend');
var native = require('../utils/native').binding;
@@ -41,8 +46,9 @@ var scryptAsync, smixAsync;
/**
* Javascript scrypt implementation. Scrypt is
- * used in bip38. BCoin doesn't support bip38
+ * used in bip38. Bcoin doesn't support bip38
* yet, but here it is, just in case.
+ * @alias module:crypto/scrypt.scrypt
* @param {Buffer} passwd
* @param {Buffer} salt
* @param {Number} N
@@ -198,6 +204,8 @@ function blkxor(dest, src, s1, s2, len) {
/**
* Asynchronous scrypt implementation.
+ * @alias module:crypto/scrypt.scryptAsync
+ * @function
* @param {Buffer} passwd
* @param {Buffer} salt
* @param {Number} N
diff --git a/lib/crypto/sha256.js b/lib/crypto/sha256.js
index f931e661d..eaa3e6fa7 100644
--- a/lib/crypto/sha256.js
+++ b/lib/crypto/sha256.js
@@ -1,12 +1,17 @@
/*!
* sha256.js - SHA256 implementation for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
* Parts of this software based on hash.js.
*/
'use strict';
+/**
+ * @module crypto/sha256
+ * @ignore
+ */
+
/*
* Constants
*/
@@ -41,6 +46,7 @@ K = [
/**
* SHA256
+ * @alias module:crypto/sha256.SHA256
* @constructor
* @property {Number[]} s
* @property {Number[]} w
@@ -225,6 +231,7 @@ SHA256.prototype.transform = function transform(chunk, pos) {
/**
* SHA256Hmac
+ * @alias module:crypto/sha256.SHA256Hmac
* @constructor
* @property {SHA256} inner
* @property {SHA256} outer
@@ -339,12 +346,26 @@ function readU32(buf, offset) {
ctx = new SHA256();
mctx = new SHA256Hmac();
+/**
+ * Hash buffer with sha256.
+ * @alias module:crypto/sha256.sha256
+ * @param {Buffer} data
+ * @returns {Buffer}
+ */
+
function sha256(data) {
ctx.init();
ctx.update(data);
return ctx.finish();
}
+/**
+ * Hash buffer with double sha256.
+ * @alias module:crypto/sha256.hash256
+ * @param {Buffer} data
+ * @returns {Buffer}
+ */
+
function hash256(data) {
var out = new Buffer(32);
ctx.init();
@@ -356,6 +377,14 @@ function hash256(data) {
return out;
}
+/**
+ * Create a sha256 HMAC from buffer and key.
+ * @alias module:crypto/sha256.hmac
+ * @param {Buffer} data
+ * @param {Buffer} key
+ * @returns {Buffer}
+ */
+
function hmac(data, key) {
mctx.init(key);
mctx.update(data);
diff --git a/lib/crypto/siphash.js b/lib/crypto/siphash.js
index 4264e416d..67924dce7 100644
--- a/lib/crypto/siphash.js
+++ b/lib/crypto/siphash.js
@@ -1,6 +1,6 @@
/*!
* siphash.js - siphash for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*
* Ported from:
@@ -9,10 +9,15 @@
'use strict';
+/**
+ * @module crypto/siphash
+ */
+
var native = require('../utils/native').binding;
/**
* Javascript siphash implementation. Used for compact block relay.
+ * @alias module:crypto/siphash.siphash24
* @param {Buffer} data
* @param {Buffer} key - 128 bit key.
* @returns {Buffer} uint64le
@@ -110,10 +115,26 @@ function sipround(v0, v1, v2, v3) {
v2.rotl(32);
}
+/**
+ * Javascript siphash implementation. Used for compact block relay.
+ * @alias module:crypto/siphash.siphash
+ * @param {Buffer} data
+ * @param {Buffer} key - 128 bit key.
+ * @returns {Buffer} uint64le
+ */
+
function siphash(data, key) {
return siphash24(data, key, 56);
}
+/**
+ * Javascript siphash implementation. Used for compact block relay.
+ * @alias module:crypto/siphash.siphash256
+ * @param {Buffer} data
+ * @param {Buffer} key - 128 bit key.
+ * @returns {Buffer} uint64le
+ */
+
function siphash256(data, key) {
return siphash24(data, key, 59);
}
diff --git a/lib/db/backends-browser.js b/lib/db/backends-browser.js
index 55047be8d..ed3237510 100644
--- a/lib/db/backends-browser.js
+++ b/lib/db/backends-browser.js
@@ -1,6 +1,6 @@
/**
* backends-browser.js - database backends for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/db/backends.js b/lib/db/backends.js
index 4d9ec611c..b3aab2133 100644
--- a/lib/db/backends.js
+++ b/lib/db/backends.js
@@ -1,6 +1,6 @@
/**
* backends.js - database backends for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/db/index.js b/lib/db/index.js
index c956573ae..3922ada0f 100644
--- a/lib/db/index.js
+++ b/lib/db/index.js
@@ -1,5 +1,9 @@
'use strict';
+/**
+ * @module db
+ */
+
exports.LDB = require('./ldb');
exports.LowlevelUp = require('./lowlevelup');
exports.RBT = require('./rbt');
diff --git a/lib/db/ldb.js b/lib/db/ldb.js
index 17b616591..00ee55f9a 100644
--- a/lib/db/ldb.js
+++ b/lib/db/ldb.js
@@ -1,7 +1,7 @@
/**
* ldb.js - database backend for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -13,6 +13,8 @@ var util = require('../utils/util');
var backends = require('./backends');
/**
+ * Create a database.
+ * @alias module:db.LDB
* @param {Object} options
* @param {Boolean} options.compression
* @param {Number} options.cacheSize
diff --git a/lib/db/lowlevelup.js b/lib/db/lowlevelup.js
index edc2b560e..bac972105 100644
--- a/lib/db/lowlevelup.js
+++ b/lib/db/lowlevelup.js
@@ -1,9 +1,7 @@
-/**
- * LevelUP module for bcoin
- * @module lowlevelup
- * @license
+/*!
+ * lowlevelup.js - LevelUP module for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -25,7 +23,7 @@ var VERSION_ERROR;
* This avoids pulling in extra deps and
* lowers memory usage.
*
- * @expose LowlevelUp
+ * @alias module:db.LowlevelUp
* @constructor
* @param {String} file - Location.
* @param {Object} options - Leveldown options.
@@ -286,6 +284,7 @@ LowlevelUp.prototype.approximateSize = function approximateSize(start, end) {
/**
* Test whether a key exists.
+ * @method
* @param {String} key
* @returns {Promise} - Returns Boolean.
*/
@@ -297,6 +296,7 @@ LowlevelUp.prototype.has = co(function* has(key) {
/**
* Collect all keys from iterator options.
+ * @method
* @param {Object} options - Iterator options.
* @returns {Promise} - Returns Array.
*/
@@ -337,6 +337,7 @@ LowlevelUp.prototype.range = co(function* range(options) {
/**
* Collect all keys from iterator options.
+ * @method
* @param {Object} options - Iterator options.
* @returns {Promise} - Returns Array.
*/
@@ -379,6 +380,7 @@ LowlevelUp.prototype.keys = co(function* keys(options) {
/**
* Collect all keys from iterator options.
+ * @method
* @param {Object} options - Iterator options.
* @returns {Promise} - Returns Array.
*/
@@ -421,6 +423,7 @@ LowlevelUp.prototype.values = co(function* values(options) {
/**
* Dump database (for debugging).
+ * @method
* @returns {Promise} - Returns Object.
*/
@@ -445,6 +448,7 @@ LowlevelUp.prototype.dump = co(function* dump() {
/**
* Write and assert a version number for the database.
+ * @method
* @param {Number} version
* @returns {Promise}
*/
@@ -467,6 +471,7 @@ LowlevelUp.prototype.checkVersion = co(function* checkVersion(key, version) {
/**
* Clone the database.
+ * @method
* @param {String} path
* @returns {Promise}
*/
@@ -524,6 +529,7 @@ LowlevelUp.prototype.clone = co(function* clone(path) {
/**
* Batch
* @constructor
+ * @ignore
* @param {LowlevelUp} db
*/
@@ -576,6 +582,7 @@ Batch.prototype.clear = function clear() {
/**
* Iterator
* @constructor
+ * @ignore
* @param {LowlevelUp} db
* @param {Object} options
*/
diff --git a/lib/db/rbt.js b/lib/db/rbt.js
index 7df37de3a..8b630a1a4 100644
--- a/lib/db/rbt.js
+++ b/lib/db/rbt.js
@@ -1,6 +1,6 @@
/*!
* rbt.js - iterative red black tree for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -18,7 +18,7 @@ var SENTINEL;
* Many of its options, parameters,
* and methods mimic the leveldown
* interface.
- * @exports RBT
+ * @alias module:db.RBT
* @constructor
* @param {String?} location - Phony location.
* @param {Object?} options
@@ -769,6 +769,7 @@ RBT.repair = function repair(location, callback) {
/**
* RBT Node
* @constructor
+ * @ignore
* @private
* @param {Buffer} key
* @param {Buffer} value
@@ -840,6 +841,7 @@ RBTNode.prototype.isNull = function isNull() {
/**
* RBT Sentinel Node
* @constructor
+ * @ignore
* @property {null} key
* @property {null} value
* @property {Number} [color=BLACK]
@@ -879,6 +881,7 @@ RBTSentinel.prototype.isNull = function isNull() {
/**
* RBT key/value pair
* @constructor
+ * @ignore
* @param {Buffer} key
* @param {Buffer} value
* @property {Buffer} key
@@ -905,6 +908,7 @@ RBTData.prototype.inspect = function inspect() {
/**
* Batch
* @constructor
+ * @ignore
* @private
* @param {RBT} tree
* @param {Object?} options
@@ -994,6 +998,7 @@ Batch.prototype.clear = function clear() {
/**
* Batch Operation
* @constructor
+ * @ignore
* @private
* @param {String} type
* @param {Buffer} key
@@ -1009,6 +1014,7 @@ function BatchOp(type, key, value) {
/**
* Iterator
* @constructor
+ * @ignore
* @private
* @param {RBT} tree
* @param {Object?} options
diff --git a/lib/env.js b/lib/env.js
index 283daf375..054eb18bc 100644
--- a/lib/env.js
+++ b/lib/env.js
@@ -1,7 +1,7 @@
/*!
* env.js - environment for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License).
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -10,11 +10,120 @@
var lazy = require('./utils/lazy');
/**
- * A BCoin "environment" which exposes all
+ * A bcoin "environment" which exposes all
* constructors for primitives, the blockchain,
* mempool, wallet, etc. It also exposes a
* global worker pool.
+ * @exports Environment
* @constructor
+ * @property {Function} env - See {@link Environment}.
+ * @property {Function} require - See {@link module:utils/lazy}.
+ *
+ * @property {Function} bn - See {@url https://github.com/indutny/bn.js}.
+ * @property {Object} elliptic - See {@url https://github.com/indutny/elliptic}.
+ *
+ * @property {Object} bip70 - See {@link module:bip70}.
+ *
+ * @property {Object} blockchain - See {@link module:blockchain}.
+ * @property {Function} chain - See {@link module:blockchain.Chain}.
+ * @property {Function} chaindb - See {@link module:blockchain.ChainDB}.
+ * @property {Function} chainentry - See {@link module:blockchain.ChainEntry}.
+ *
+ * @property {Object} btc
+ * @property {Function} amount
+ * @property {Function} uri
+ *
+ * @property {Object} coins
+ * @property {Function} coinview
+ *
+ * @property {Object} crypto
+ * @property {Object} ec
+ * @property {Object} pk
+ * @property {Object} schnorr
+ *
+ * @property {Object} db
+ * @property {Object} ldb
+ *
+ * @property {Object} hd
+ *
+ * @property {Object} http
+ * @property {Object} rpc
+ *
+ * @property {Object} txmempool
+ * @property {Object} fees
+ * @property {Object} mempool
+ * @property {Object} mempoolentry
+ *
+ * @property {Object} mining
+ * @property {Object} miner
+ * @property {Object} minerblock
+ *
+ * @property {Object} net
+ * @property {Object} bip150
+ * @property {Object} bip151
+ * @property {Object} bip152
+ * @property {Object} dns
+ * @property {Object} packets
+ * @property {Object} peer
+ * @property {Object} pool
+ * @property {Object} tcp
+ *
+ * @property {Object} node
+ * @property {Object} config
+ * @property {Object} fullnode
+ * @property {Object} logger
+ * @property {Object} spvnode
+ *
+ * @property {Object} primitives
+ * @property {Object} address
+ * @property {Object} block
+ * @property {Object} coin
+ * @property {Object} headers
+ * @property {Object} input
+ * @property {Object} invitem
+ * @property {Object} keyring
+ * @property {Object} merkleblock
+ * @property {Object} mtx
+ * @property {Object} netaddress
+ * @property {Object} outpoint
+ * @property {Object} output
+ * @property {Object} tx
+ *
+ * @property {Object} protocol
+ * @property {Object} consensus
+ * @property {Object} errors
+ * @property {Object} network
+ * @property {Object} networks
+ * @property {Object} policy
+ * @property {Object} timedata
+ *
+ * @property {Object} txscript
+ * @property {Object} opcodes
+ * @property {Object} program
+ * @property {Object} script
+ * @property {Object} sigcache
+ * @property {Object} stack
+ * @property {Object} witness
+ *
+ * @property {Object} utils
+ * @property {Object} base32
+ * @property {Object} base58
+ * @property {Object} bloom
+ * @property {Object} co
+ * @property {Object} encoding
+ * @property {Object} lock
+ * @property {Object} reader
+ * @property {Object} staticwriter
+ * @property {Object} util
+ * @property {Object} writer
+ *
+ * @property {Object} wallet
+ * @property {Object} path
+ * @property {Object} walletkey
+ * @property {Object} walletdb
+ *
+ * @property {Object} workers
+ * @property {Object} workerpool
*/
function Environment() {
@@ -125,6 +234,7 @@ function Environment() {
// Utils
this.require('utils', './utils');
+ this.require('base32', './utils/base32');
this.require('base58', './utils/base58');
this.require('bloom', './utils/bloom');
this.require('co', './utils/co');
diff --git a/lib/hd/hd.js b/lib/hd/hd.js
index 4f51d33be..31d7be930 100644
--- a/lib/hd/hd.js
+++ b/lib/hd/hd.js
@@ -12,7 +12,7 @@ var HDPrivateKey = require('./private');
var HDPublicKey = require('./public');
/**
- * @exports HD
+ * @exports hd
*/
var HD = exports;
diff --git a/lib/hd/mnemonic.js b/lib/hd/mnemonic.js
index e9990a9ba..b94e125fe 100644
--- a/lib/hd/mnemonic.js
+++ b/lib/hd/mnemonic.js
@@ -18,7 +18,7 @@ var nfkd = require('../utils/nfkd');
/**
* HD Mnemonic
- * @exports Mnemonic
+ * @alias module:hd.Mnemonic
* @constructor
* @param {Object} options
* @param {Number?} options.bit - Bits of entropy (Must
diff --git a/lib/hd/private.js b/lib/hd/private.js
index e82141c18..e8c6f5d17 100644
--- a/lib/hd/private.js
+++ b/lib/hd/private.js
@@ -23,7 +23,7 @@ var HDPublicKey = require('./public');
/**
* HDPrivateKey
- * @exports HDPrivateKey
+ * @alias module:hd.PrivateKey
* @constructor
* @param {Object|Base58String} options
* @param {Base58String?} options.xkey - Serialized base58 key.
diff --git a/lib/hd/public.js b/lib/hd/public.js
index 81e8bdb64..4746b4a5c 100644
--- a/lib/hd/public.js
+++ b/lib/hd/public.js
@@ -20,7 +20,7 @@ var common = require('./common');
/**
* HDPublicKey
- * @exports HDPublicKey
+ * @alias module:hd.PublicKey
* @constructor
* @param {Object|Base58String} options
* @param {Base58String?} options.xkey - Serialized base58 key.
diff --git a/lib/http/base.js b/lib/http/base.js
index 8900cae49..5c2a218b7 100644
--- a/lib/http/base.js
+++ b/lib/http/base.js
@@ -1,7 +1,7 @@
/*!
* http.js - http server for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -15,7 +15,7 @@ var co = require('../utils/co');
/**
* HTTPBase
- * @exports HTTPBase
+ * @alias module:http.Base
* @constructor
* @param {Object?} options
* @emits HTTPBase#websocket
@@ -486,6 +486,7 @@ HTTPBase.prototype.listen = function listen(port, host) {
/**
* HTTP Base Options
+ * @alias module:http.HTTPBaseOptions
* @constructor
* @param {Object} options
*/
@@ -611,6 +612,7 @@ HTTPBaseOptions.prototype.toHTTP = function toHTTP() {
/**
* Route
* @constructor
+ * @ignore
*/
function Route(ctx, path, handler) {
@@ -711,6 +713,7 @@ Route.prototype.call = co(function* call(req, res) {
/**
* Routes
* @constructor
+ * @ignore
*/
function Routes() {
diff --git a/lib/http/client.js b/lib/http/client.js
index 88fa6a592..a2cba4680 100644
--- a/lib/http/client.js
+++ b/lib/http/client.js
@@ -1,7 +1,7 @@
/*!
* client.js - http client for wallets
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -16,8 +16,8 @@ var co = require('../utils/co');
var request = require('./request');
/**
- * BCoin HTTP client.
- * @exports HTTPClient
+ * Bcoin HTTP client.
+ * @alias module:http.Client
* @constructor
* @param {String} uri
* @param {Object?} options
diff --git a/lib/http/index.js b/lib/http/index.js
index ea70e31de..f5d23c9ec 100644
--- a/lib/http/index.js
+++ b/lib/http/index.js
@@ -1,12 +1,16 @@
/*!
* http/index.js - http for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module http
+ */
+
exports.request = require('./request');
exports.Client = require('./client');
exports.RPCClient = require('./rpcclient');
diff --git a/lib/http/request.js b/lib/http/request.js
index ee4b359e9..4bd3e5322 100644
--- a/lib/http/request.js
+++ b/lib/http/request.js
@@ -1,6 +1,6 @@
/*
* request.js - http request for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -22,6 +22,7 @@ var USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1)'
/**
* Request Options
* @constructor
+ * @ignore
* @param {Object} options
*/
@@ -254,6 +255,7 @@ RequestOptions.prototype.toHTTP = function toHTTP() {
/**
* Request
* @constructor
+ * @private
* @param {Object} options
*/
@@ -490,6 +492,7 @@ Request.prototype._onEnd = function _onEnd(err) {
/**
* Make an HTTP request.
+ * @alias module:http.request
* @param {Object} options
* @param {String} options.uri
* @param {Object?} options.query
diff --git a/lib/http/rpc.js b/lib/http/rpc.js
index 8767670ca..6fe68e8c6 100644
--- a/lib/http/rpc.js
+++ b/lib/http/rpc.js
@@ -1,6 +1,6 @@
/*!
* rpc.js - bitcoind-compatible json rpc for bcoin.
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -36,8 +36,10 @@ var consensus = require('../protocol/consensus');
var pkg = require('../../package.json');
/**
- * RPC
+ * Bitcoin Core RPC
+ * @alias module:http.RPC
* @constructor
+ * @param {Node} node
*/
function RPC(node) {
@@ -2762,7 +2764,7 @@ RPC.prototype.dumpwallet = co(function* dumpwallet(args) {
file = toString(args[0]);
time = util.date();
out = [
- util.fmt('# Wallet Dump created by BCoin %s', pkg.version),
+ util.fmt('# Wallet Dump created by Bcoin %s', pkg.version),
util.fmt('# * Created on %s', time),
util.fmt('# * Best block at time of backup was %d (%s),',
this.chain.height, this.chain.tip.rhash()),
diff --git a/lib/http/rpcclient.js b/lib/http/rpcclient.js
index 43da3a4eb..c1e5835c6 100644
--- a/lib/http/rpcclient.js
+++ b/lib/http/rpcclient.js
@@ -1,6 +1,6 @@
/*!
* rpcclient.js - json rpc client for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -11,8 +11,8 @@ var request = require('./request');
var co = require('../utils/co');
/**
- * BCoin RPC client.
- * @exports RPCClient
+ * Bcoin RPC client.
+ * @alias module:http.RPCClient
* @constructor
* @param {String} uri
* @param {Object?} options
diff --git a/lib/http/server.js b/lib/http/server.js
index 1f62be376..e5830ba6d 100644
--- a/lib/http/server.js
+++ b/lib/http/server.js
@@ -1,7 +1,7 @@
/*!
* server.js - http server for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -33,7 +33,7 @@ var RPC;
/**
* HTTPServer
- * @exports HTTPServer
+ * @alias module:http.Server
* @constructor
* @param {Object} options
* @param {Fullnode} options.node
@@ -1691,6 +1691,7 @@ HTTPServer.prototype.listen = function listen(port, host) {
/**
* HTTPOptions
+ * @alias module:http.HTTPOptions
* @constructor
* @param {Object} options
*/
@@ -1820,6 +1821,7 @@ HTTPOptions.fromOptions = function fromOptions(options) {
/**
* ClientSocket
* @constructor
+ * @ignore
* @param {HTTPServer} server
* @param {SocketIO.Socket}
*/
@@ -2230,6 +2232,7 @@ function getMemory() {
/**
* TimedCB
* @constructor
+ * @ignore
*/
function TimedCB(resolve, reject) {
diff --git a/lib/http/wallet.js b/lib/http/wallet.js
index bdd43452c..09756d443 100644
--- a/lib/http/wallet.js
+++ b/lib/http/wallet.js
@@ -1,7 +1,7 @@
/*!
* wallet.js - http wallet for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -16,7 +16,7 @@ var Client = require('./client');
/**
* HTTPWallet
- * @exports HTTPWallet
+ * @alias module:http.Wallet
* @constructor
* @param {String} uri
*/
diff --git a/lib/mempool/fees.js b/lib/mempool/fees.js
index 7c9e55426..93f4ded8f 100644
--- a/lib/mempool/fees.js
+++ b/lib/mempool/fees.js
@@ -1,6 +1,6 @@
/*!
* fees.js - fee estimation for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
* Ported from:
* https://github.com/bitcoin/bitcoin/blob/master/src/policy/fees.cpp
@@ -43,7 +43,7 @@ var FREE_THRESHOLD = policy.FREE_THRESHOLD;
/**
* Confirmation stats.
- * @exports ConfirmStats
+ * @alias module:mempool.ConfirmStats
* @constructor
* @param {String} type
* @param {Logger} logger
@@ -398,7 +398,7 @@ ConfirmStats.fromRaw = function fromRaw(data, type, logger) {
/**
* Estimator for fees and priority.
- * @exports PolicyEstimator
+ * @alias module:mempool.PolicyEstimator
* @constructor
* @param {Rate} minRelay
* @param {Network|NetworkType} network
diff --git a/lib/mempool/index.js b/lib/mempool/index.js
index e7f1d57c1..48b3dbd38 100644
--- a/lib/mempool/index.js
+++ b/lib/mempool/index.js
@@ -1,5 +1,9 @@
'use strict';
+/**
+ * @module mempool
+ */
+
exports.Mempool = require('./mempool');
exports.MempoolEntry = require('./mempoolentry');
exports.Fees = require('./fees');
diff --git a/lib/mempool/mempool.js b/lib/mempool/mempool.js
index 09892c719..1a0da7be0 100644
--- a/lib/mempool/mempool.js
+++ b/lib/mempool/mempool.js
@@ -1,6 +1,6 @@
/*!
* mempool.js - mempool for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -29,7 +29,7 @@ var VerifyResult = errors.VerifyResult;
/**
* Represents a mempool.
- * @exports Mempool
+ * @alias module:mempool.Mempool
* @constructor
* @param {Object} options
* @param {String?} options.name - Database name.
@@ -93,6 +93,7 @@ util.inherits(Mempool, AsyncObject);
/**
* Open the chain, wait for the database to load.
+ * @method
* @alias Mempool#open
* @returns {Promise}
*/
@@ -117,6 +118,7 @@ Mempool.prototype._close = function close() {
* Notify the mempool that a new block has come
* in (removes all transactions contained in the
* block from the mempool).
+ * @method
* @param {ChainEntry} block
* @param {TX[]} txs
* @returns {Promise}
@@ -181,6 +183,7 @@ Mempool.prototype._addBlock = function addBlock(block, txs) {
/**
* Notify the mempool that a block has been disconnected
* from the main chain (reinserts transactions into the mempool).
+ * @method
* @param {ChainEntry} block
* @param {TX[]} txs
* @returns {Promise}
@@ -198,6 +201,7 @@ Mempool.prototype.removeBlock = co(function* removeBlock(block, txs) {
/**
* Notify the mempool that a block
* has been disconnected without a lock.
+ * @method
* @private
* @param {ChainEntry} block
* @param {TX[]} txs
@@ -238,6 +242,7 @@ Mempool.prototype._removeBlock = co(function* removeBlock(block, txs) {
/**
* Reset the mempool.
+ * @method
* @returns {Promise}
*/
@@ -605,6 +610,7 @@ Mempool.prototype.hasReject = function hasReject(hash) {
* Add a transaction to the mempool. Note that this
* will lock the mempool until the transaction is
* fully processed.
+ * @method
* @param {TX} tx
* @returns {Promise}
*/
@@ -627,6 +633,7 @@ Mempool.prototype.addTX = co(function* addTX(tx) {
/**
* Add a transaction to the mempool without a lock.
+ * @method
* @private
* @param {TX} tx
* @returns {Promise}
@@ -765,6 +772,7 @@ Mempool.prototype._addTX = co(function* _addTX(tx) {
/**
* Verify a transaction with mempool standards.
+ * @method
* @param {TX} tx
* @param {CoinView} view
* @returns {Promise}
@@ -905,6 +913,7 @@ Mempool.prototype.verify = co(function* verify(entry, view) {
/**
* Verify inputs, return a boolean
* instead of an error based on success.
+ * @method
* @param {TX} tx
* @param {CoinView} view
* @param {VerifyFlags} flags
@@ -925,6 +934,7 @@ Mempool.prototype.verifyResult = co(function* verifyResult(tx, view, flags) {
/**
* Verify inputs for standard
* _and_ mandatory flags on failure.
+ * @method
* @param {TX} tx
* @param {CoinView} view
* @param {VerifyFlags} flags
@@ -958,6 +968,7 @@ Mempool.prototype.verifyInputs = co(function* verifyInputs(tx, view, flags) {
* and may lend itself to race conditions if used unwisely.
* This function will also resolve orphans if possible (the
* resolved orphans _will_ be validated).
+ * @method
* @param {MempoolEntry} entry
* @param {CoinView} view
* @returns {Promise}
@@ -1328,6 +1339,7 @@ Mempool.prototype.storeOrphan = function storeOrphan(tx, missing) {
/**
* Resolve orphans and attempt to add to mempool.
+ * @method
* @param {TX} tx
* @returns {Promise} - Returns {@link TX}[].
*/
@@ -1478,6 +1490,7 @@ Mempool.prototype.isDoubleSpend = function isDoubleSpend(tx) {
/**
* Get coin viewpoint (lock).
+ * @method
* @param {TX} tx
* @param {CoinView} view
* @returns {Promise} - Returns {@link CoinView}.
@@ -1802,6 +1815,7 @@ Mempool.prototype.getSize = function getSize() {
/**
* MempoolOptions
+ * @alias module:mempool.MempoolOptions
* @constructor
* @param {Object}
*/
@@ -1942,6 +1956,9 @@ MempoolOptions.fromOptions = function fromOptions(options) {
/**
* TX Address Index
+ * @constructor
+ * @ignore
+ * @param {Mempool} mempool
*/
function TXIndex(mempool) {
@@ -2041,6 +2058,9 @@ TXIndex.prototype.remove = function remove(tx) {
/**
* Coin Address Index
+ * @constructor
+ * @ignore
+ * @param {Mempool} mempool
*/
function CoinIndex(mempool) {
diff --git a/lib/mempool/mempoolentry.js b/lib/mempool/mempoolentry.js
index 5ddcc307e..4e8379cd5 100644
--- a/lib/mempool/mempoolentry.js
+++ b/lib/mempool/mempoolentry.js
@@ -1,6 +1,6 @@
/*!
* mempoolentry.js - mempool entry object for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -12,7 +12,7 @@ var Script = require('../script/script');
/**
* Represents a mempool entry.
- * @exports MempoolEntry
+ * @alias module:mempool.MempoolEntry
* @constructor
* @param {Object} options
* @param {TX} options.tx - Transaction in mempool.
diff --git a/lib/mining/index.js b/lib/mining/index.js
index 40829c9d5..ebc7d99d2 100644
--- a/lib/mining/index.js
+++ b/lib/mining/index.js
@@ -1,5 +1,9 @@
'use strict';
+/**
+ * @module mining
+ */
+
exports.mine = require('./mine');
exports.Miner = require('./miner');
exports.MinerBlock = require('./minerblock');
diff --git a/lib/mining/mine.js b/lib/mining/mine.js
index ac0b03571..7d1a5d870 100644
--- a/lib/mining/mine.js
+++ b/lib/mining/mine.js
@@ -1,6 +1,6 @@
/*!
* mine.js - mining function for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -9,6 +9,7 @@ var crypto = require('../crypto/crypto');
/**
* Hash until the nonce overflows.
+ * @alias module:mining.mine
* @param {Buffer} data
* @param {Buffer} target - Big endian.
* @param {Number} min
@@ -27,11 +28,10 @@ function mine(data, target, min, max) {
if (rcmp(crypto.hash256(data), target) <= 0)
return nonce;
- // Increment the nonce to get a different hash
+ // Increment the nonce to get a different hash.
nonce++;
- // Update the raw buffer (faster than
- // constantly serializing the headers).
+ // Update the raw buffer.
data.writeUInt32LE(nonce, 76, true);
}
@@ -41,7 +41,7 @@ function mine(data, target, min, max) {
/**
* "Reverse" comparison so we don't have
* to waste time reversing the block hash.
- * @memberof Miner
+ * @ignore
* @param {Buffer} a
* @param {Buffer} b
* @returns {Number}
diff --git a/lib/mining/miner.js b/lib/mining/miner.js
index c41650a32..3223a0f33 100644
--- a/lib/mining/miner.js
+++ b/lib/mining/miner.js
@@ -1,7 +1,7 @@
/*!
* miner.js - inefficient miner for bcoin (because we can)
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -20,11 +20,11 @@ var BlockEntry = MinerBlock.BlockEntry;
/**
* A bitcoin miner (supports mining witness blocks).
- * @exports Miner
+ * @alias module:mining.Miner
* @constructor
* @param {Object} options
- * @param {Base58Address} options.address - Payout address.
- * @param {String?} [options.coinbaseFlags="mined by bcoin"]
+ * @param {Address} options.address - Payout address.
+ * @param {String} [options.coinbaseFlags="mined by bcoin"]
* @property {Boolean} running
* @property {MinerBlock} attempt
* @emits Miner#block
@@ -92,7 +92,8 @@ Miner.prototype._init = function _init() {
/**
* Open the miner, wait for the chain and mempool to load.
- * @alias Miner#open
+ * @method
+ * @alias module:mining.Miner#open
* @returns {Promise}
*/
@@ -108,7 +109,8 @@ Miner.prototype._open = co(function* open() {
/**
* Close the miner.
- * @alias Miner#close
+ * @method
+ * @alias module:mining.Miner#close
* @returns {Promise}
*/
@@ -126,7 +128,9 @@ Miner.prototype._close = co(function* close() {
/**
* Start mining.
+ * @method
* @param {Number?} version - Custom block version.
+ * @returns {Promise}
*/
Miner.prototype.start = co(function* start() {
@@ -192,6 +196,8 @@ Miner.prototype.start = co(function* start() {
/**
* Stop mining.
+ * @method
+ * @returns {Promise}
*/
Miner.prototype.stop = co(function* stop() {
@@ -214,6 +220,8 @@ Miner.prototype.stop = co(function* stop() {
/**
* Wait for `done` event.
+ * @private
+ * @returns {Promise}
*/
Miner.prototype._onDone = function _onDone() {
@@ -225,6 +233,8 @@ Miner.prototype._onDone = function _onDone() {
/**
* Wait for `stop` event.
+ * @private
+ * @returns {Promise}
*/
Miner.prototype._onStop = function _onStop() {
@@ -236,6 +246,7 @@ Miner.prototype._onStop = function _onStop() {
/**
* Create a block "attempt".
+ * @method
* @param {ChainEntry} tip
* @returns {Promise} - Returns {@link MinerBlock}.
*/
@@ -251,6 +262,8 @@ Miner.prototype.createBlock = co(function* createBlock(tip, address) {
/**
* Create a block "attempt" (without a lock).
+ * @method
+ * @private
* @param {ChainEntry} tip
* @returns {Promise} - Returns {@link MinerBlock}.
*/
@@ -297,6 +310,7 @@ Miner.prototype._createBlock = co(function* createBlock(tip, address) {
/**
* Mine a single block.
+ * @method
* @param {ChainEntry} tip
* @returns {Promise} - Returns [{@link Block}].
*/
@@ -456,6 +470,7 @@ Miner.prototype.build = function build(attempt) {
/**
* MinerOptions
+ * @alias module:mining.MinerOptions
* @constructor
* @param {Object}
*/
@@ -580,6 +595,7 @@ MinerOptions.fromOptions = function fromOptions(options) {
/**
* Queue
* @constructor
+ * @ignore
*/
function Queue(cmp) {
diff --git a/lib/mining/minerblock.js b/lib/mining/minerblock.js
index 030614da0..762099b86 100644
--- a/lib/mining/minerblock.js
+++ b/lib/mining/minerblock.js
@@ -1,7 +1,7 @@
/*!
* minerblock.js - miner block object for bcoin (because we can)
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -24,8 +24,8 @@ var consensus = require('../protocol/consensus');
var encoding = require('../utils/encoding');
/**
- * MinerBlock
- * @exports MinerBlock
+ * MinerBlock (block attempt)
+ * @alias module:mining.MinerBlock
* @constructor
* @param {Object} options
* @param {ChainEntry} options.tip
@@ -356,7 +356,8 @@ MinerBlock.prototype.findNonce = function findNonce() {
/**
* Hash until the nonce overflows.
- * @returns {Boolean} Whether the nonce was found.
+ * @method
+ * @returns {Promise} - Returns Boolean.
*/
MinerBlock.prototype.findNonceAsync = co(function* findNonceAsync() {
@@ -415,6 +416,7 @@ MinerBlock.prototype.mine = function mine() {
/**
* Mine asynchronously until the block is found.
+ * @method
* @returns {Promise} - Returns {@link Block}.
*/
@@ -495,7 +497,17 @@ MinerBlock.prototype.destroy = function destroy() {
/**
* BlockEntry
+ * @alias module:mining.BlockEntry
* @constructor
+ * @param {TX} tx
+ * @property {TX} tx
+ * @property {Hash} hash
+ * @property {Amount} fee
+ * @property {Rate} rate
+ * @property {Number} priority
+ * @property {Boolean} free
+ * @property {Sigops} sigops
+ * @property {Number} depCount
*/
function BlockEntry(tx) {
@@ -509,6 +521,14 @@ function BlockEntry(tx) {
this.depCount = 0;
}
+/**
+ * Instantiate block entry from transaction.
+ * @param {TX} tx
+ * @param {CoinView} view
+ * @param {MinerBlock} attempt
+ * @returns {BlockEntry}
+ */
+
BlockEntry.fromTX = function fromTX(tx, view, attempt) {
var entry = new BlockEntry(tx);
entry.fee = tx.getFee(view);
@@ -519,6 +539,13 @@ BlockEntry.fromTX = function fromTX(tx, view, attempt) {
return entry;
};
+/**
+ * Instantiate block entry from mempool entry.
+ * @param {MempoolEntry} entry
+ * @param {MinerBlock} attempt
+ * @returns {BlockEntry}
+ */
+
BlockEntry.fromEntry = function fromEntry(entry, attempt) {
var item = new BlockEntry(entry.tx);
item.fee = entry.getFee();
diff --git a/lib/net/bip150.js b/lib/net/bip150.js
index 656363010..b272518c8 100644
--- a/lib/net/bip150.js
+++ b/lib/net/bip150.js
@@ -1,6 +1,6 @@
/*!
* bip150.js - peer auth.
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
* Resources:
* https://github.com/bitcoin/bips/blob/master/bip-0150.mediawiki
@@ -23,7 +23,7 @@ var dns = require('./dns');
/**
* Represents a BIP150 input/output stream.
- * @exports BIP150
+ * @alias module:net.BIP150
* @constructor
* @param {BIP151} bip151
* @param {String} host
@@ -458,7 +458,7 @@ BIP150.address = function address(key) {
/**
* AuthDB
- * @exports AuthDB
+ * @alias module:net.AuthDB
* @constructor
*/
@@ -597,7 +597,7 @@ AuthDB.prototype.getKnown = function getKnown(hostname) {
/**
* Lookup known peers.
- * @private
+ * @method
* @returns {Promise}
*/
@@ -617,6 +617,7 @@ AuthDB.prototype.discover = co(function* discover() {
/**
* Populate known peers with hosts.
+ * @method
* @private
* @param {Object} addr
* @param {Buffer} key
diff --git a/lib/net/bip151.js b/lib/net/bip151.js
index 8cf8f8dfb..ebc9b50c7 100644
--- a/lib/net/bip151.js
+++ b/lib/net/bip151.js
@@ -1,6 +1,6 @@
/*!
* bip151.js - peer-to-peer communication encryption.
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
* Resources:
* https://github.com/bitcoin/bips/blob/master/bip-0151.mediawiki
@@ -38,7 +38,7 @@ var HIGH_WATERMARK = 1024 * (1 << 20);
/**
* Represents a BIP151 input or output stream.
- * @exports BIP151Stream
+ * @alias module:net.BIP151Stream
* @constructor
* @param {Number} cipher
* @property {Buffer} publicKey
@@ -285,7 +285,7 @@ BIP151Stream.prototype.verify = function verify(tag) {
/**
* Represents a BIP151 input and output stream.
* Holds state for peer communication.
- * @exports BIP151
+ * @alias module:net.BIP151
* @constructor
* @param {Number} cipher
* @property {BIP151Stream} input
diff --git a/lib/net/bip152.js b/lib/net/bip152.js
index f59166635..e4fdb17e6 100644
--- a/lib/net/bip152.js
+++ b/lib/net/bip152.js
@@ -1,11 +1,15 @@
/*!
* bip152.js - compact block object for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module net/bip152
+ */
+
var util = require('../utils/util');
var BufferReader = require('../utils/reader');
var BufferWriter = require('../utils/writer');
@@ -23,7 +27,6 @@ var Block = require('../primitives/block');
/**
* Represents a compact block (bip152): `cmpctblock` packet.
* @see https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki
- * @exports CompactBlock
* @constructor
* @extends AbstractBlock
* @param {Object} options
diff --git a/lib/net/common.js b/lib/net/common.js
index fcb103f10..53b4362bc 100644
--- a/lib/net/common.js
+++ b/lib/net/common.js
@@ -1,12 +1,16 @@
/*!
* common.js - p2p constants for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module net/common
+ */
+
var pkg = require('../../package.json');
/**
@@ -98,7 +102,7 @@ exports.services = {
};
/**
- * BCoin's services (we support everything).
+ * Bcoin's services (we support everything).
* @const {Number}
* @default
*/
diff --git a/lib/net/dns-browser.js b/lib/net/dns-browser.js
index 521bfd781..255cdeaad 100644
--- a/lib/net/dns-browser.js
+++ b/lib/net/dns-browser.js
@@ -1,6 +1,6 @@
/*!
* dns.js - dns backend for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -9,6 +9,15 @@
var ProxySocket = require('./proxysocket');
var socket;
+/**
+ * Resolve host (no getaddrinfo).
+ * @ignore
+ * @param {String} host
+ * @param {String?} proxy
+ * @param {Boolean?} onion
+ * @returns {Promise}
+ */
+
exports.resolve = function resolve(host, proxy, onion) {
return new Promise(function(resolve, reject) {
if (!socket)
@@ -30,6 +39,15 @@ exports.resolve = function resolve(host, proxy, onion) {
});
};
+/**
+ * Resolve host (getaddrinfo).
+ * @ignore
+ * @param {String} host
+ * @param {String?} proxy
+ * @param {Boolean?} onion
+ * @returns {Promise}
+ */
+
exports.lookup = function lookup(host, proxy, onion) {
return exports.resolve(host, proxy, onion);
};
diff --git a/lib/net/dns.js b/lib/net/dns.js
index 653a72ade..bac107461 100644
--- a/lib/net/dns.js
+++ b/lib/net/dns.js
@@ -1,11 +1,15 @@
/*!
* dns.js - dns backend for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module net/dns
+ */
+
var dns = require('dns');
var socks = require('./socks');
@@ -15,6 +19,14 @@ var options = {
all: true
};
+/**
+ * Resolve host (no getaddrinfo).
+ * @param {String} host
+ * @param {String?} proxy
+ * @param {Boolean?} onion
+ * @returns {Promise}
+ */
+
exports.resolve = function resolve(host, proxy, onion) {
if (proxy && onion)
return socks.resolve(proxy, host);
@@ -36,6 +48,14 @@ exports.resolve = function resolve(host, proxy, onion) {
});
};
+/**
+ * Resolve host (getaddrinfo).
+ * @param {String} host
+ * @param {String?} proxy
+ * @param {Boolean?} onion
+ * @returns {Promise}
+ */
+
exports.lookup = function lookup(host, proxy, onion) {
if (proxy && onion)
return socks.resolve(proxy, host);
diff --git a/lib/net/framer.js b/lib/net/framer.js
index fa8221877..29426d49c 100644
--- a/lib/net/framer.js
+++ b/lib/net/framer.js
@@ -1,7 +1,7 @@
/*!
* framer.js - packet framer for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -13,7 +13,7 @@ var crypto = require('../crypto/crypto');
/**
* Protocol packet framer
- * @exports Framer
+ * @alias module:net.Framer
* @constructor
* @param {Network} network
*/
diff --git a/lib/net/hostlist.js b/lib/net/hostlist.js
index 386ed2595..cfb0a87a9 100644
--- a/lib/net/hostlist.js
+++ b/lib/net/hostlist.js
@@ -1,6 +1,6 @@
/*!
* hostlist.js - address management for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -20,6 +20,7 @@ var dns = require('./dns');
/**
* Host List
+ * @alias module:net.HostList
* @constructor
* @param {Object} options
*/
@@ -722,6 +723,7 @@ HostList.prototype.setNodes = function setNodes(nodes) {
/**
* Discover hosts from seeds and nodes.
+ * @method
* @returns {Promise}
*/
@@ -746,6 +748,7 @@ HostList.prototype.discover = co(function* discover() {
/**
* Lookup node's domain.
+ * @method
* @param {Object} addr
* @returns {Promise}
*/
@@ -762,6 +765,7 @@ HostList.prototype.populateNode = co(function* populateNode(addr) {
/**
* Populate from seed.
+ * @method
* @param {Object} seed
* @returns {Promise}
*/
@@ -778,6 +782,7 @@ HostList.prototype.populateSeed = co(function* populateSeed(seed) {
/**
* Lookup hosts from dns host.
+ * @method
* @param {Object} target
* @returns {Promise}
*/
@@ -940,6 +945,7 @@ HostList.fromJSON = function fromJSON(options, json) {
/**
* HostEntry
+ * @alias module:net.HostEntry
* @constructor
* @param {NetAddress} addr
* @param {NetAddress} src
diff --git a/lib/net/index.js b/lib/net/index.js
index e728abbf7..b8b339754 100644
--- a/lib/net/index.js
+++ b/lib/net/index.js
@@ -1,5 +1,9 @@
'use strict';
+/**
+ * @module net
+ */
+
exports.BIP150 = require('./bip150');
exports.BIP151 = require('./bip151');
exports.bip152 = require('./bip152');
diff --git a/lib/net/packets.js b/lib/net/packets.js
index bf746d076..e5bcb0ce7 100644
--- a/lib/net/packets.js
+++ b/lib/net/packets.js
@@ -1,12 +1,16 @@
/*!
* packets.js - packets for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module net/packets
+ */
+
var common = require('./common');
var util = require('../utils/util');
var assert = require('assert');
@@ -133,7 +137,6 @@ Packet.prototype.fromRaw = function fromRaw(data) {
/**
* Version Packet
* @constructor
- * @exports VersionPacket
* @param {Object?} options
* @param {Number} options.version - Protocol version.
* @param {Number} options.services - Service bits.
@@ -353,7 +356,6 @@ VersionPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `verack` packet.
- * @exports VerackPacket
* @constructor
*/
@@ -394,7 +396,6 @@ VerackPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `ping` packet.
- * @exports PingPacket
* @constructor
* @param {BN?} nonce
* @property {BN|null} nonce
@@ -491,7 +492,6 @@ PingPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `pong` packet.
- * @exports PongPacket
* @constructor
* @param {BN?} nonce
* @property {BN} nonce
@@ -585,7 +585,6 @@ PongPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `getaddr` packet.
- * @exports GetAddrPacket
* @constructor
*/
@@ -626,7 +625,6 @@ GetAddrPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `addr` packet.
- * @exports AddrPacket
* @constructor
* @param {(NetAddress[])?} items
* @property {NetAddress[]} items
@@ -729,7 +727,6 @@ AddrPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `inv` packet.
- * @exports InvPacket
* @constructor
* @param {(InvItem[])?} items
* @property {InvItem[]} items
@@ -845,7 +842,6 @@ InvPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `getdata` packet.
- * @exports GetDataPacket
* @extends InvPacket
* @constructor
* @param {(InvItem[])?} items
@@ -888,7 +884,6 @@ GetDataPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `notfound` packet.
- * @exports NotFoundPacket
* @extends InvPacket
* @constructor
* @param {(InvItem[])?} items
@@ -931,7 +926,6 @@ NotFoundPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `getblocks` packet.
- * @exports GetBlocksPacket
* @constructor
* @param {Hash[]} locator
* @param {Hash?} stop
@@ -1051,7 +1045,6 @@ GetBlocksPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `getheaders` packet.
- * @exports GetHeadersPacket
* @extends GetBlocksPacket
* @constructor
* @param {Hash[]} locator
@@ -1095,7 +1088,6 @@ GetHeadersPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `headers` packet.
- * @exports HeadersPacket
* @constructor
* @param {(Headers[])?} items
* @property {Headers[]} items
@@ -1207,7 +1199,6 @@ HeadersPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `sendheaders` packet.
- * @exports SendHeadersPacket
* @constructor
*/
@@ -1248,7 +1239,6 @@ SendHeadersPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `block` packet.
- * @exports BlockPacket
* @constructor
* @param {Block|null} block
* @param {Boolean?} witness
@@ -1351,7 +1341,6 @@ BlockPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `tx` packet.
- * @exports TXPacket
* @constructor
* @param {TX|null} tx
* @param {Boolean?} witness
@@ -1454,7 +1443,6 @@ TXPacket.fromRaw = function fromRaw(data, enc) {
/**
* Reject Packet
- * @exports RejectPacket
* @constructor
* @property {(Number|String)?} code - Code
* (see {@link RejectPacket.codes}).
@@ -1750,7 +1738,6 @@ RejectPacket.prototype.inspect = function inspect() {
/**
* Represents a `mempool` packet.
- * @exports MempoolPacket
* @constructor
*/
@@ -1791,7 +1778,6 @@ MempoolPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `filterload` packet.
- * @exports FilterLoadPacket
* @constructor
* @param {Bloom|null} filter
*/
@@ -1893,7 +1879,6 @@ FilterLoadPacket.prototype.isWithinConstraints = function isWithinConstraints()
/**
* Represents a `filteradd` packet.
- * @exports FilterAddPacket
* @constructor
* @param {Buffer?} data
* @property {Buffer} data
@@ -1978,7 +1963,6 @@ FilterAddPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `filterclear` packet.
- * @exports FilterClearPacket
* @constructor
*/
@@ -2009,7 +1993,6 @@ FilterClearPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `merkleblock` packet.
- * @exports MerkleBlockPacket
* @constructor
* @param {MerkleBlock?} block
* @property {MerkleBlock} block
@@ -2093,7 +2076,6 @@ MerkleBlockPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `feefilter` packet.
- * @exports FeeFilterPacket
* @constructor
* @param {Rate?} rate
* @property {Rate} rate
@@ -2187,7 +2169,6 @@ FeeFilterPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `sendcmpct` packet.
- * @exports SendCmpctPacket
* @constructor
* @param {Number|null} mode
* @param {Number|null} version
@@ -2296,7 +2277,6 @@ SendCmpctPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `cmpctblock` packet.
- * @exports CmpctBlockPacket
* @constructor
* @param {Block|null} block
* @param {Boolean|null} witness
@@ -2399,7 +2379,6 @@ CmpctBlockPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `getblocktxn` packet.
- * @exports GetBlockTxnPacket
* @constructor
* @param {TXRequest?} request
* @property {TXRequest} request
@@ -2493,7 +2472,6 @@ GetBlockTxnPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `blocktxn` packet.
- * @exports BlockTxnPacket
* @constructor
* @param {TXResponse?} response
* @param {Boolean?} witness
@@ -2596,7 +2574,6 @@ BlockTxnPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `encinit` packet.
- * @exports EncinitPacket
* @constructor
* @param {Buffer|null} publicKey
* @param {Number|null} cipher
@@ -2695,7 +2672,6 @@ EncinitPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `encack` packet.
- * @exports EncackPacket
* @constructor
* @param {Buffer?} publicKey
* @property {Buffer} publicKey
@@ -2789,7 +2765,6 @@ EncackPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `authchallenge` packet.
- * @exports AuthChallengePacket
* @constructor
* @param {Buffer?} hash
* @property {Buffer} hash
@@ -2883,7 +2858,6 @@ AuthChallengePacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `authreply` packet.
- * @exports AuthReplyPacket
* @constructor
* @param {Buffer?} signature
* @property {Buffer} signature
@@ -2977,7 +2951,6 @@ AuthReplyPacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents a `authpropose` packet.
- * @exports AuthProposePacket
* @constructor
* @param {Hash?} hash
* @property {Hash} hash
@@ -3071,7 +3044,6 @@ AuthProposePacket.fromRaw = function fromRaw(data, enc) {
/**
* Represents an unknown packet.
- * @exports UnknownPacket
* @constructor
* @param {String|null} cmd
* @param {Buffer|null} data
diff --git a/lib/net/parser.js b/lib/net/parser.js
index f20a13e97..5977f66a3 100644
--- a/lib/net/parser.js
+++ b/lib/net/parser.js
@@ -1,7 +1,7 @@
/*!
* parser.js - packet parser for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -17,7 +17,7 @@ var packets = require('./packets');
/**
* Protocol packet parser
- * @exports Parser
+ * @alias module:net.Parser
* @constructor
* @param {Network} network
* @emits Parser#error
@@ -177,7 +177,7 @@ Parser.prototype.parsePayload = function parsePayload(cmd, data) {
/**
* Packet Header
* @constructor
- * @private
+ * @ignore
*/
function Header(cmd, size, checksum) {
diff --git a/lib/net/peer.js b/lib/net/peer.js
index a3db335a7..3bff434a2 100644
--- a/lib/net/peer.js
+++ b/lib/net/peer.js
@@ -1,7 +1,7 @@
/*!
* peer.js - peer object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -36,7 +36,7 @@ var packetTypes = packets.types;
/**
* Represents a remote peer.
- * @exports Peer
+ * @alias module:net.Peer
* @constructor
* @param {PeerOptions} options
* @property {net.Socket} socket
@@ -437,6 +437,7 @@ Peer.prototype.connect = function connect(addr) {
/**
* Open and perform initial handshake (without rejection).
+ * @method
* @returns {Promise}
*/
@@ -450,6 +451,7 @@ Peer.prototype.tryOpen = co(function* tryOpen() {
/**
* Open and perform initial handshake.
+ * @method
* @returns {Promise}
*/
@@ -465,6 +467,7 @@ Peer.prototype.open = co(function* open() {
/**
* Open and perform initial handshake.
+ * @method
* @returns {Promise}
*/
@@ -552,6 +555,7 @@ Peer.prototype.initStall = function initStall() {
/**
* Handle `connect` event (called immediately
* if a socket was passed into peer).
+ * @method
* @private
* @returns {Promise}
*/
@@ -588,6 +592,7 @@ Peer.prototype.initBIP151 = co(function* initBIP151() {
/**
* Handle post bip151-handshake.
+ * @method
* @private
* @returns {Promise}
*/
@@ -626,6 +631,7 @@ Peer.prototype.initBIP150 = co(function* initBIP150() {
/**
* Handle post handshake.
+ * @method
* @private
* @returns {Promise}
*/
@@ -662,6 +668,7 @@ Peer.prototype.initVersion = co(function* initVersion() {
/**
* Finalize peer after handshake.
+ * @method
* @private
* @returns {Promise}
*/
@@ -1481,6 +1488,7 @@ Peer.prototype.getTX = function getTX(hashes) {
/**
* Handle a packet payload.
+ * @method
* @private
* @param {Packet} packet
*/
@@ -1526,6 +1534,7 @@ Peer.prototype.readPacket = co(function* readPacket(packet) {
/**
* Handle a packet payload without a lock.
+ * @method
* @private
* @param {Packet} packet
*/
@@ -1614,6 +1623,7 @@ Peer.prototype.handlePacket = co(function* handlePacket(packet) {
/**
* Handle `version` packet.
+ * @method
* @private
* @param {VersionPacket} packet
*/
@@ -1669,6 +1679,7 @@ Peer.prototype.handleVersion = co(function* handleVersion(packet) {
/**
* Handle `verack` packet.
+ * @method
* @private
* @param {VerackPacket} packet
*/
@@ -1685,6 +1696,7 @@ Peer.prototype.handleVerack = co(function* handleVerack(packet) {
/**
* Handle `ping` packet.
+ * @method
* @private
* @param {PingPacket} packet
*/
@@ -1698,6 +1710,7 @@ Peer.prototype.handlePing = co(function* handlePing(packet) {
/**
* Handle `pong` packet.
+ * @method
* @private
* @param {PongPacket} packet
*/
@@ -1735,6 +1748,7 @@ Peer.prototype.handlePong = co(function* handlePong(packet) {
/**
* Handle `sendheaders` packet.
+ * @method
* @private
* @param {SendHeadersPacket} packet
*/
@@ -1752,6 +1766,7 @@ Peer.prototype.handleSendHeaders = co(function* handleSendHeaders(packet) {
/**
* Handle `filterload` packet.
+ * @method
* @private
* @param {FilterLoadPacket} packet
*/
@@ -1768,6 +1783,7 @@ Peer.prototype.handleFilterLoad = co(function* handleFilterLoad(packet) {
/**
* Handle `filteradd` packet.
+ * @method
* @private
* @param {FilterAddPacket} packet
*/
@@ -1788,6 +1804,7 @@ Peer.prototype.handleFilterAdd = co(function* handleFilterAdd(packet) {
/**
* Handle `filterclear` packet.
+ * @method
* @private
* @param {FilterClearPacket} packet
*/
@@ -1801,6 +1818,7 @@ Peer.prototype.handleFilterClear = co(function* handleFilterClear(packet) {
/**
* Handle `feefilter` packet.
+ * @method
* @private
* @param {FeeFilterPacket} packet
*/
@@ -1818,6 +1836,7 @@ Peer.prototype.handleFeeFilter = co(function* handleFeeFilter(packet) {
/**
* Handle `sendcmpct` packet.
+ * @method
* @private
* @param {SendCmpctPacket}
*/
@@ -1855,6 +1874,7 @@ Peer.prototype.handleSendCmpct = co(function* handleSendCmpct(packet) {
/**
* Handle `encinit` packet.
+ * @method
* @private
* @param {EncinitPacket} packet
*/
@@ -1870,6 +1890,7 @@ Peer.prototype.handleEncinit = co(function* handleEncinit(packet) {
/**
* Handle `encack` packet.
+ * @method
* @private
* @param {EncackPacket} packet
*/
@@ -1883,6 +1904,7 @@ Peer.prototype.handleEncack = co(function* handleEncack(packet) {
/**
* Handle `authchallenge` packet.
+ * @method
* @private
* @param {AuthChallengePacket} packet
*/
@@ -1900,6 +1922,7 @@ Peer.prototype.handleAuthChallenge = co(function* handleAuthChallenge(packet) {
/**
* Handle `authreply` packet.
+ * @method
* @private
* @param {AuthReplyPacket} packet
*/
@@ -1918,6 +1941,7 @@ Peer.prototype.handleAuthReply = co(function* handleAuthReply(packet) {
/**
* Handle `authpropose` packet.
+ * @method
* @private
* @param {AuthProposePacket} packet
*/
@@ -2023,10 +2047,10 @@ Peer.prototype.sendReject = function sendReject(code, reason, msg) {
var reject = packets.RejectPacket.fromReason(code, reason, msg);
if (msg) {
- this.logger.debug('Rejecting %s %s (%s): ccode=%s reason=%s.',
+ this.logger.debug('Rejecting %s %s (%s): code=%s reason=%s.',
reject.message, msg.rhash(), this.hostname(), code, reason);
} else {
- this.logger.debug('Rejecting packet from %s: ccode=%s reason=%s.',
+ this.logger.debug('Rejecting packet from %s: code=%s reason=%s.',
this.hostname(), code, reason);
}
@@ -2149,6 +2173,7 @@ Peer.prototype.inspect = function inspect() {
/**
* PeerOptions
+ * @alias module:net.PeerOptions
* @constructor
*/
@@ -2358,6 +2383,7 @@ PeerOptions.getRate = function getRate(hash) {
/**
* RequestEntry
* @constructor
+ * @ignore
*/
function RequestEntry() {
diff --git a/lib/net/pool.js b/lib/net/pool.js
index c1171ca82..d688e192a 100644
--- a/lib/net/pool.js
+++ b/lib/net/pool.js
@@ -1,7 +1,7 @@
/*!
* pool.js - peer management for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -38,7 +38,7 @@ var packetTypes = packets.types;
/**
* A pool of peers for handling all network activity.
- * @exports Pool
+ * @alias module:net.Pool
* @constructor
* @param {Object} options
* @param {Chain} options.chain
@@ -62,25 +62,12 @@ var packetTypes = packets.types;
* @param {Function?} options.createServer - Custom function to create a server.
* Must return a node-like server.
* @emits Pool#block
- * @emits Pool#block
* @emits Pool#tx
* @emits Pool#peer
* @emits Pool#open
* @emits Pool#close
* @emits Pool#error
- * @emits Pool#fork
- * @emits Pool#invalid
- * @emits Pool#exists
- * @emits Pool#orphan
- * @emits Pool#full
- * @emits Pool#blocks
- * @emits Pool#txs
- * @emits Pool#chain-progress
* @emits Pool#reject
- * @emits Pool#addr
- * @emits Pool#version
- * @emits Pool#ack
- * @emits Pool#watched
*/
function Pool(options) {
@@ -202,6 +189,7 @@ Pool.prototype._init = function _init() {
/**
* Open the pool, wait for the chain to load.
+ * @method
* @alias Pool#open
* @returns {Promise}
*/
@@ -254,6 +242,7 @@ Pool.prototype.resetChain = function resetChain() {
/**
* Close and destroy the pool.
+ * @method
* @alias Pool#close
* @returns {Promise}
*/
@@ -265,6 +254,7 @@ Pool.prototype._close = co(function* close() {
/**
* Connect to the network.
+ * @method
* @returns {Promise}
*/
@@ -279,6 +269,7 @@ Pool.prototype.connect = co(function* connect() {
/**
* Connect to the network (no lock).
+ * @method
* @returns {Promise}
*/
@@ -320,6 +311,7 @@ Pool.prototype._connect = co(function* connect() {
/**
* Disconnect from the network.
+ * @method
* @returns {Promise}
*/
@@ -334,6 +326,7 @@ Pool.prototype.disconnect = co(function* disconnect() {
/**
* Disconnect from the network.
+ * @method
* @returns {Promise}
*/
@@ -384,6 +377,7 @@ Pool.prototype._disconnect = co(function* disconnect() {
/**
* Start listening on a server socket.
+ * @method
* @private
* @returns {Promise}
*/
@@ -402,6 +396,7 @@ Pool.prototype.listen = co(function* listen() {
/**
* Stop listening on server socket.
+ * @method
* @private
* @returns {Promise}
*/
@@ -588,6 +583,7 @@ Pool.prototype.stopSync = function stopSync() {
/**
* Start syncing from peer.
+ * @method
* @param {Peer} peer
* @returns {Promise}
*/
@@ -776,6 +772,7 @@ Pool.prototype.getBroadcasted = function getBroadcasted(peer, item) {
/**
* Get a block/tx either from the broadcast map, mempool, or blockchain.
+ * @method
* @private
* @param {Peer} peer
* @param {InvItem} item
@@ -808,6 +805,7 @@ Pool.prototype.getItem = co(function* getItem(peer, item) {
/**
* Send a block from the broadcast list or chain.
+ * @method
* @private
* @param {Peer} peer
* @param {InvItem} item
@@ -942,6 +940,7 @@ Pool.prototype.bindPeer = function bindPeer(peer) {
/**
* Handle peer packet event.
+ * @method
* @private
* @param {Peer} peer
* @param {Packet} packet
@@ -1056,6 +1055,7 @@ Pool.prototype.handlePacket = co(function* handlePacket(peer, packet) {
/**
* Handle peer connect event.
+ * @method
* @private
* @param {Peer} peer
*/
@@ -1071,6 +1071,7 @@ Pool.prototype.handleConnect = co(function* handleConnect(peer) {
/**
* Handle peer open event.
+ * @method
* @private
* @param {Peer} peer
*/
@@ -1132,6 +1133,7 @@ Pool.prototype.handleOpen = co(function* handleOpen(peer) {
/**
* Handle peer close event.
+ * @method
* @private
* @param {Peer} peer
* @param {Boolean} connected
@@ -1167,6 +1169,7 @@ Pool.prototype.handleClose = co(function* handleClose(peer, connected) {
/**
* Handle ban event.
+ * @method
* @private
* @param {Peer} peer
*/
@@ -1178,6 +1181,7 @@ Pool.prototype.handleBan = co(function* handleBan(peer) {
/**
* Handle peer version event.
+ * @method
* @private
* @param {Peer} peer
* @param {VersionPacket} packet
@@ -1198,6 +1202,7 @@ Pool.prototype.handleVersion = co(function* handleVersion(peer, packet) {
/**
* Handle `verack` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {VerackPacket} packet
@@ -1209,6 +1214,7 @@ Pool.prototype.handleVerack = co(function* handleVerack(peer, packet) {
/**
* Handle `ping` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {PingPacket} packet
@@ -1220,6 +1226,7 @@ Pool.prototype.handlePing = co(function* handlePing(peer, packet) {
/**
* Handle `pong` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {PongPacket} packet
@@ -1231,6 +1238,7 @@ Pool.prototype.handlePong = co(function* handlePong(peer, packet) {
/**
* Handle `getaddr` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {GetAddrPacket} packet
@@ -1279,6 +1287,7 @@ Pool.prototype.handleGetAddr = co(function* handleGetAddr(peer, packet) {
/**
* Handle peer addr event.
+ * @method
* @private
* @param {Peer} peer
* @param {AddrPacket} packet
@@ -1319,6 +1328,7 @@ Pool.prototype.handleAddr = co(function* handleAddr(peer, packet) {
/**
* Handle `inv` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {InvPacket} packet
@@ -1335,6 +1345,7 @@ Pool.prototype.handleInv = co(function* handleInv(peer, packet) {
/**
* Handle `inv` packet (without a lock).
+ * @method
* @private
* @param {Peer} peer
* @param {InvPacket} packet
@@ -1387,6 +1398,7 @@ Pool.prototype._handleInv = co(function* handleInv(peer, packet) {
/**
* Handle `inv` packet from peer (containing only BLOCK types).
+ * @method
* @private
* @param {Peer} peer
* @param {Hash[]} hashes
@@ -1450,6 +1462,7 @@ Pool.prototype.handleBlockInv = co(function* handleBlockInv(peer, hashes) {
/**
* Handle peer inv packet (txs).
+ * @method
* @private
* @param {Peer} peer
* @param {Hash[]} hashes
@@ -1476,6 +1489,7 @@ Pool.prototype.handleTXInv = co(function* handleTXInv(peer, hashes) {
/**
* Handle `getdata` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {GetDataPacket} packet
@@ -1636,6 +1650,7 @@ Pool.prototype.handleGetData = co(function* handleGetData(peer, packet) {
/**
* Handle peer notfound packet.
+ * @method
* @private
* @param {Peer} peer
* @param {NotFoundPacket} packet
@@ -1653,6 +1668,7 @@ Pool.prototype.handleNotFound = co(function* handleNotFound(peer, packet) {
/**
* Handle `getblocks` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {GetBlocksPacket} packet
@@ -1698,6 +1714,7 @@ Pool.prototype.handleGetBlocks = co(function* handleGetBlocks(peer, packet) {
/**
* Handle `getheaders` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {GetHeadersPacket} packet
@@ -1747,6 +1764,7 @@ Pool.prototype.handleGetHeaders = co(function* handleGetHeaders(peer, packet) {
/**
* Handle `headers` packet from a given peer.
+ * @method
* @private
* @param {Peer} peer
* @param {HeadersPacket} packet
@@ -1765,6 +1783,7 @@ Pool.prototype.handleHeaders = co(function* handleHeaders(peer, packet) {
/**
* Handle `headers` packet from
* a given peer without a lock.
+ * @method
* @private
* @param {Peer} peer
* @param {HeadersPacket} packet
@@ -1875,6 +1894,7 @@ Pool.prototype._handleHeaders = co(function* handleHeaders(peer, packet) {
/**
* Handle `sendheaders` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {SendHeadersPacket} packet
@@ -1887,6 +1907,7 @@ Pool.prototype.handleSendHeaders = co(function* handleSendHeaders(peer, packet)
/**
* Handle `block` packet. Attempt to add to chain.
+ * @method
* @private
* @param {Peer} peer
* @param {BlockPacket} packet
@@ -1906,6 +1927,7 @@ Pool.prototype.handleBlock = co(function* handleBlock(peer, packet) {
/**
* Attempt to add block to chain.
+ * @method
* @private
* @param {Peer} peer
* @param {Block} block
@@ -1924,6 +1946,7 @@ Pool.prototype.addBlock = co(function* addBlock(peer, block) {
/**
* Attempt to add block to chain (without a lock).
+ * @method
* @private
* @param {Peer} peer
* @param {Block} block
@@ -1974,6 +1997,7 @@ Pool.prototype._addBlock = co(function* addBlock(peer, block) {
/**
* Resolve header chain.
+ * @method
* @private
* @param {Peer} peer
* @param {Hash} hash
@@ -2034,6 +2058,7 @@ Pool.prototype.resolveChain = co(function* resolveChain(peer, hash) {
/**
* Switch to getblocks.
+ * @method
* @private
* @param {Peer} peer
* @param {Hash} hash
@@ -2085,6 +2110,7 @@ Pool.prototype.logStatus = function logStatus(block) {
/**
* Handle a transaction. Attempt to add to mempool.
+ * @method
* @private
* @param {Peer} peer
* @param {TXPacket} packet
@@ -2103,6 +2129,7 @@ Pool.prototype.handleTX = co(function* handleTX(peer, packet) {
/**
* Handle a transaction. Attempt to add to mempool (without a lock).
+ * @method
* @private
* @param {Peer} peer
* @param {TXPacket} packet
@@ -2163,6 +2190,7 @@ Pool.prototype._handleTX = co(function* handleTX(peer, packet) {
/**
* Handle peer reject event.
+ * @method
* @private
* @param {Peer} peer
* @param {RejectPacket} packet
@@ -2192,6 +2220,7 @@ Pool.prototype.handleReject = co(function* handleReject(peer, packet) {
/**
* Handle `mempool` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {MempoolPacket} packet
@@ -2234,6 +2263,7 @@ Pool.prototype.handleMempool = co(function* handleMempool(peer, packet) {
/**
* Handle `filterload` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {FilterLoadPacket} packet
@@ -2245,6 +2275,7 @@ Pool.prototype.handleFilterLoad = co(function* handleFilterLoad(peer, packet) {
/**
* Handle `filteradd` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {FilterAddPacket} packet
@@ -2256,6 +2287,7 @@ Pool.prototype.handleFilterAdd = co(function* handleFilterAdd(peer, packet) {
/**
* Handle `filterclear` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {FilterClearPacket} packet
@@ -2267,6 +2299,7 @@ Pool.prototype.handleFilterClear = co(function* handleFilterClear(peer, packet)
/**
* Handle `merkleblock` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {MerkleBlockPacket} block
@@ -2284,6 +2317,7 @@ Pool.prototype.handleMerkleBlock = co(function* handleMerkleBlock(peer, packet)
/**
* Handle `merkleblock` packet (without a lock).
+ * @method
* @private
* @param {Peer} peer
* @param {MerkleBlockPacket} block
@@ -2341,6 +2375,7 @@ Pool.prototype._handleMerkleBlock = co(function* handleMerkleBlock(peer, packet)
/**
* Handle `sendcmpct` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {FeeFilterPacket} packet
@@ -2352,6 +2387,7 @@ Pool.prototype.handleFeeFilter = co(function* handleFeeFilter(peer, packet) {
/**
* Handle `sendcmpct` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {SendCmpctPacket} packet
@@ -2363,6 +2399,7 @@ Pool.prototype.handleSendCmpct = co(function* handleSendCmpct(peer, packet) {
/**
* Handle `cmpctblock` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {CompactBlockPacket} packet
@@ -2456,6 +2493,7 @@ Pool.prototype.handleCmpctBlock = co(function* handleCmpctBlock(peer, packet) {
/**
* Handle `getblocktxn` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {GetBlockTxnPacket} packet
@@ -2502,6 +2540,7 @@ Pool.prototype.handleGetBlockTxn = co(function* handleGetBlockTxn(peer, packet)
/**
* Handle `blocktxn` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {BlockTxnPacket} packet
@@ -2540,6 +2579,7 @@ Pool.prototype.handleBlockTxn = co(function* handleBlockTxn(peer, packet) {
/**
* Handle `encinit` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {EncinitPacket} packet
@@ -2551,6 +2591,7 @@ Pool.prototype.handleEncinit = co(function* handleEncinit(peer, packet) {
/**
* Handle `encack` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {EncackPacket} packet
@@ -2562,6 +2603,7 @@ Pool.prototype.handleEncack = co(function* handleEncack(peer, packet) {
/**
* Handle `authchallenge` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {AuthChallengePacket} packet
@@ -2573,6 +2615,7 @@ Pool.prototype.handleAuthChallenge = co(function* handleAuthChallenge(peer, pack
/**
* Handle `authreply` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {AuthReplyPacket} packet
@@ -2584,6 +2627,7 @@ Pool.prototype.handleAuthReply = co(function* handleAuthReply(peer, packet) {
/**
* Handle `authpropose` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {AuthProposePacket} packet
@@ -2595,6 +2639,7 @@ Pool.prototype.handleAuthPropose = co(function* handleAuthPropose(peer, packet)
/**
* Handle `unknown` packet.
+ * @method
* @private
* @param {Peer} peer
* @param {UnknownPacket} packet
@@ -2904,6 +2949,7 @@ Pool.prototype.watchOutpoint = function watchOutpoint(outpoint) {
/**
* Send `getblocks` to peer after building
* locator and resolving orphan root.
+ * @method
* @param {Peer} peer
* @param {Hash} orphan - Orphan hash to resolve.
* @returns {Promise}
@@ -2920,6 +2966,7 @@ Pool.prototype.resolveOrphan = co(function* resolveOrphan(peer, orphan) {
/**
* Send `getheaders` to peer after building locator.
+ * @method
* @param {Peer} peer
* @param {Hash} tip - Tip to build chain locator from.
* @param {Hash?} stop
@@ -2933,6 +2980,7 @@ Pool.prototype.getHeaders = co(function* getHeaders(peer, tip, stop) {
/**
* Send `getblocks` to peer after building locator.
+ * @method
* @param {Peer} peer
* @param {Hash} tip - Tip hash to build chain locator from.
* @param {Hash?} stop
@@ -3032,6 +3080,7 @@ Pool.prototype.getTX = function getTX(peer, hashes) {
/**
* Test whether the chain has or has seen an item.
+ * @method
* @param {Hash} hash
* @returns {Promise} - Returns Boolean.
*/
@@ -3148,6 +3197,7 @@ Pool.prototype.announceTX = function announceTX(msg) {
/**
* Attempt to retrieve external IP from icanhazip.com.
+ * @method
* @returns {Promise}
*/
@@ -3181,6 +3231,7 @@ Pool.prototype.getIP = co(function* getIP() {
/**
* Attempt to retrieve external IP from dyndns.org.
+ * @method
* @returns {Promise}
*/
@@ -3209,6 +3260,7 @@ Pool.prototype.getIP2 = co(function* getIP2() {
/**
* PoolOptions
+ * @alias module:net.PoolOptions
* @constructor
*/
@@ -3624,6 +3676,7 @@ PoolOptions.prototype._resolve = function resolve(name) {
/**
* Peer List
+ * @alias module:net.PeerList
* @constructor
* @param {Object} options
*/
@@ -3738,7 +3791,7 @@ PeerList.prototype.destroy = function destroy() {
/**
* Represents an item that is broadcasted via an inv/getdata cycle.
- * @exports BroadcastItem
+ * @alias module:net.BroadcastItem
* @constructor
* @private
* @param {Pool} pool
@@ -3930,6 +3983,7 @@ BroadcastItem.prototype.inspect = function inspect() {
/**
* NonceList
* @constructor
+ * @ignore
*/
function NonceList() {
@@ -3976,6 +4030,7 @@ NonceList.prototype.remove = function remove(hostname) {
/**
* HeaderEntry
* @constructor
+ * @ignore
*/
function HeaderEntry(hash, height) {
diff --git a/lib/net/socks.js b/lib/net/socks.js
index 0a6d68747..736a72161 100644
--- a/lib/net/socks.js
+++ b/lib/net/socks.js
@@ -1,6 +1,6 @@
/*!
* socks.js - socks proxy for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -15,6 +15,10 @@ var IP = require('../utils/ip');
var StaticWriter = require('../utils/staticwriter');
var BufferReader = require('../utils/reader');
+/**
+ * @module net/socks
+ */
+
/**
* SOCKS state machine
* @constructor
diff --git a/lib/net/tcp-browser.js b/lib/net/tcp-browser.js
index ee0076a2d..e3a9e33e4 100644
--- a/lib/net/tcp-browser.js
+++ b/lib/net/tcp-browser.js
@@ -1,6 +1,6 @@
/*!
* tcp.js - tcp backend for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/net/tcp.js b/lib/net/tcp.js
index f5f1327e7..4f05c323b 100644
--- a/lib/net/tcp.js
+++ b/lib/net/tcp.js
@@ -1,6 +1,6 @@
/*!
* tcp.js - tcp backend for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -9,14 +9,32 @@
var EventEmitter = require('events').EventEmitter;
var net = require('net');
var socks = require('./socks');
+
+/**
+ * @exports net/tcp
+ */
+
var tcp = exports;
+/**
+ * Create a TCP socket and connect.
+ * @param {Number} port
+ * @param {String} host
+ * @param {String?} proxy
+ * @returns {Object}
+ */
+
tcp.createSocket = function createSocket(port, host, proxy) {
if (proxy)
return socks.connect(proxy, port, host);
return net.connect(port, host);
};
+/**
+ * Create a TCP server.
+ * @returns {Object}
+ */
+
tcp.createServer = function createServer() {
var server = new net.Server();
var ee = new EventEmitter();
@@ -61,6 +79,10 @@ tcp.createServer = function createServer() {
return ee;
};
+/*
+ * Helpers
+ */
+
function wrap(resolve, reject) {
return function(err, result) {
if (err) {
diff --git a/lib/node/config.js b/lib/node/config.js
index 41fb90a30..ed3e2c9ad 100644
--- a/lib/node/config.js
+++ b/lib/node/config.js
@@ -1,6 +1,6 @@
/*!
* config.js - bcoin configuration
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -12,7 +12,7 @@ var util = require('../utils/util');
var global = util.global;
/**
- * @exports config
+ * @exports node/config
*/
function config(options) {
diff --git a/lib/node/fullnode.js b/lib/node/fullnode.js
index acdedfd87..152d5114f 100644
--- a/lib/node/fullnode.js
+++ b/lib/node/fullnode.js
@@ -1,7 +1,7 @@
/*!
* fullnode.js - full node for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -22,7 +22,7 @@ var policy = require('../protocol/policy');
/**
* Create a fullnode complete with a chain,
* mempool, miner, wallet, etc.
- * @exports FullNode
+ * @alias module:node.FullNode
* @extends Node
* @constructor
* @param {Object?} options
diff --git a/lib/node/index.js b/lib/node/index.js
index a7df515ab..e318a666d 100644
--- a/lib/node/index.js
+++ b/lib/node/index.js
@@ -1,5 +1,9 @@
'use strict';
+/**
+ * @module node
+ */
+
exports.config = require('./config');
exports.FullNode = require('./fullnode');
exports.Logger = require('./logger');
diff --git a/lib/node/logger.js b/lib/node/logger.js
index b0ed36566..436b6261c 100644
--- a/lib/node/logger.js
+++ b/lib/node/logger.js
@@ -1,6 +1,6 @@
/*!
* logger.js - basic logger for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -12,7 +12,7 @@ var util = require('../utils/util');
/**
* Basic stdout and file logger.
- * @exports Logger
+ * @alias module:node.Logger
* @constructor
* @param {(String|Object)?} options/level
* @param {String?} options.level
diff --git a/lib/node/node.js b/lib/node/node.js
index f0922e84b..44ebeeaf7 100644
--- a/lib/node/node.js
+++ b/lib/node/node.js
@@ -1,7 +1,7 @@
/*!
* node.js - node object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -21,7 +21,7 @@ var native = require('../utils/native');
/**
* Base class from which every other
* Node-like object inherits.
- * @exports Node
+ * @alias module:node.Node
* @constructor
* @abstract
* @param {Object} options
diff --git a/lib/node/nodeclient.js b/lib/node/nodeclient.js
index 92abffa3b..f242171d0 100644
--- a/lib/node/nodeclient.js
+++ b/lib/node/nodeclient.js
@@ -1,6 +1,6 @@
/*!
* nodeclient.js - node client for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -13,6 +13,7 @@ var AsyncObject = require('../utils/async');
/**
* NodeClient
* Sort of a fake local client for separation of concerns.
+ * @alias module:node.NodeClient
* @constructor
*/
diff --git a/lib/node/spvnode.js b/lib/node/spvnode.js
index 03a2f2e97..8aec8abd7 100644
--- a/lib/node/spvnode.js
+++ b/lib/node/spvnode.js
@@ -1,7 +1,7 @@
/*!
* spvnode.js - spv node for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -19,7 +19,7 @@ var HTTPServer = require('../http/server');
/**
* Create an spv node which only maintains
* a chain, a pool, and a wallet database.
- * @exports SPVNode
+ * @alias module:node.SPVNode
* @extends Node
* @constructor
* @param {Object?} options
diff --git a/lib/primitives/abstractblock.js b/lib/primitives/abstractblock.js
index 8c45b388a..1ae10678e 100644
--- a/lib/primitives/abstractblock.js
+++ b/lib/primitives/abstractblock.js
@@ -1,7 +1,7 @@
/*!
* abstractblock.js - abstract block object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -18,11 +18,11 @@ var consensus = require('../protocol/consensus');
/**
* The class which all block-like objects inherit from.
- * @exports AbstractBlock
+ * @alias module:primitives.AbstractBlock
* @constructor
* @abstract
* @property {Number} version - Block version. Note
- * that BCoin reads versions as unsigned despite
+ * that Bcoin reads versions as unsigned despite
* them being signed on the protocol level. This
* number will never be negative.
* @property {Hash} prevBlock - Previous block hash.
diff --git a/lib/primitives/address.js b/lib/primitives/address.js
index 520ac8cf3..4f046cda5 100644
--- a/lib/primitives/address.js
+++ b/lib/primitives/address.js
@@ -1,7 +1,7 @@
/*!
* address.js - address object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -20,7 +20,7 @@ var base58 = require('../utils/base58');
/**
* Represents an address.
- * @exports Address
+ * @alias module:primitives.Address
* @constructor
* @param {Object} options
* @param {Buffer|Hash} options.hash - Address hash.
diff --git a/lib/primitives/block.js b/lib/primitives/block.js
index 9d9e4fda0..6b76f0963 100644
--- a/lib/primitives/block.js
+++ b/lib/primitives/block.js
@@ -1,7 +1,7 @@
/*!
* block.js - block object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -23,7 +23,7 @@ var Network = require('../protocol/network');
/**
* Represents a full block.
- * @exports Block
+ * @alias module:primitives.Block
* @constructor
* @extends AbstractBlock
* @param {NakedBlock} options
diff --git a/lib/primitives/coin.js b/lib/primitives/coin.js
index 14fe812d6..9a95ce78d 100644
--- a/lib/primitives/coin.js
+++ b/lib/primitives/coin.js
@@ -1,7 +1,7 @@
/*!
* coin.js - coin object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -20,7 +20,7 @@ var encoding = require('../utils/encoding');
/**
* Represents an unspent output.
- * @exports Coin
+ * @alias module:primitives.Coin
* @constructor
* @extends Output
* @param {NakedCoin|Coin} options
diff --git a/lib/primitives/headers.js b/lib/primitives/headers.js
index 2dd86ab78..f24b0e345 100644
--- a/lib/primitives/headers.js
+++ b/lib/primitives/headers.js
@@ -1,7 +1,7 @@
/*!
* headers.js - headers object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -15,7 +15,7 @@ var BufferReader = require('../utils/reader');
/**
* Represents block headers obtained from the network via `headers`.
- * @exports Headers
+ * @alias module:primitives.Headers
* @constructor
* @extends AbstractBlock
* @param {NakedBlock} options
diff --git a/lib/primitives/index.js b/lib/primitives/index.js
index 137eec485..9e0c8685b 100644
--- a/lib/primitives/index.js
+++ b/lib/primitives/index.js
@@ -1,5 +1,9 @@
'use strict';
+/**
+ * @module primitives
+ */
+
exports.AbstractBlock = require('./abstractblock');
exports.Address = require('./address');
exports.Block = require('./block');
diff --git a/lib/primitives/input.js b/lib/primitives/input.js
index 4a334b8d5..45091406f 100644
--- a/lib/primitives/input.js
+++ b/lib/primitives/input.js
@@ -1,7 +1,7 @@
/*!
* input.js - input object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -18,7 +18,7 @@ var BufferReader = require('../utils/reader');
/**
* Represents a transaction input.
- * @exports Input
+ * @alias module:primitives.Input
* @constructor
* @param {NakedInput} options
* @property {Outpoint} prevout - Outpoint.
diff --git a/lib/primitives/invitem.js b/lib/primitives/invitem.js
index 9966b19f8..0d8bbe06d 100644
--- a/lib/primitives/invitem.js
+++ b/lib/primitives/invitem.js
@@ -1,7 +1,7 @@
/*!
* invitem.js - inv item object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -13,6 +13,8 @@ var util = require('../utils/util');
/**
* Inv Item
+ * @alias module:primitives.InvItem
+ * @constructor
* @param {Number} type
* @param {Hash} hash
* @property {InvType} type
diff --git a/lib/primitives/keyring.js b/lib/primitives/keyring.js
index affc3927d..d9bba9d50 100644
--- a/lib/primitives/keyring.js
+++ b/lib/primitives/keyring.js
@@ -1,7 +1,7 @@
/*!
* keyring.js - keyring object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -23,7 +23,7 @@ var ec = require('../crypto/ec');
/**
* Represents a key ring which amounts to an address.
- * @exports KeyRing
+ * @alias module:primitives.KeyRing
* @constructor
* @param {Object} options
* @param {Network} network
diff --git a/lib/primitives/memblock.js b/lib/primitives/memblock.js
index 4b2865448..e59b867a1 100644
--- a/lib/primitives/memblock.js
+++ b/lib/primitives/memblock.js
@@ -1,7 +1,7 @@
/*!
* memblock.js - memblock block object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -21,7 +21,7 @@ var BufferReader = require('../utils/reader');
* data on the javascript heap. Blocks can currently
* be up to 1mb in size. In the future, they may be
* 2mb, 8mb, or maybe 20mb, who knows? A MemBlock
- * is an optimization in BCoin which defers parsing of
+ * is an optimization in Bcoin which defers parsing of
* the serialized transactions (the block Buffer) until
* the block has passed through the chain queue and
* is about to enter the chain. This keeps a lot data
@@ -30,7 +30,7 @@ var BufferReader = require('../utils/reader');
* lot of strain off of the garbage collector. Having
* 500mb of blocks on the js heap would not be a good
* thing.
- * @exports MemBlock
+ * @alias module:primitives.MemBlock
* @constructor
* @param {NakedBlock} options
*/
diff --git a/lib/primitives/merkleblock.js b/lib/primitives/merkleblock.js
index 3337bda73..1aa423d75 100644
--- a/lib/primitives/merkleblock.js
+++ b/lib/primitives/merkleblock.js
@@ -1,7 +1,7 @@
/*!
* merkleblock.js - merkleblock object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -22,7 +22,7 @@ var DUMMY = new Buffer([0]);
/**
* Represents a merkle (filtered) block.
- * @exports MerkleBlock
+ * @alias module:primitives.MerkleBlock
* @constructor
* @extends AbstractBlock
* @param {NakedBlock} options
diff --git a/lib/primitives/mtx.js b/lib/primitives/mtx.js
index 22510bba1..6a0a9a262 100644
--- a/lib/primitives/mtx.js
+++ b/lib/primitives/mtx.js
@@ -1,7 +1,7 @@
/*!
* mtx.js - mutable transaction object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -27,7 +27,7 @@ var opcodes = Script.opcodes;
/**
* A mutable transaction object.
- * @exports MTX
+ * @alias module:primitives.MTX
* @extends TX
* @constructor
* @param {Object} options
@@ -1430,6 +1430,7 @@ MTX.isMTX = function isMTX(obj) {
/**
* Coin Selector
+ * @alias module:primitives.CoinSelector
* @constructor
* @param {TX} tx
* @param {Object?} options
@@ -1792,8 +1793,8 @@ CoinSelector.prototype.selectHard = function selectHard() {
/**
* An error thrown from the coin selector.
- * @exports FundingError
* @constructor
+ * @ignore
* @extends Error
* @param {String} msg
* @param {Amount} available
diff --git a/lib/primitives/netaddress.js b/lib/primitives/netaddress.js
index 22639f25f..9ec8b2805 100644
--- a/lib/primitives/netaddress.js
+++ b/lib/primitives/netaddress.js
@@ -1,6 +1,6 @@
/*!
* netaddress.js - network address object for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -16,7 +16,7 @@ var BufferReader = require('../utils/reader');
/**
* Represents a network address.
- * @exports NetAddress
+ * @alias module:primitives.NetAddress
* @constructor
* @param {Object} options
* @param {Number?} options.ts - Timestamp.
diff --git a/lib/primitives/outpoint.js b/lib/primitives/outpoint.js
index c00130353..2c44c25d2 100644
--- a/lib/primitives/outpoint.js
+++ b/lib/primitives/outpoint.js
@@ -1,6 +1,6 @@
/*!
* outpoint.js - outpoint object for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -14,7 +14,7 @@ var encoding = require('../utils/encoding');
/**
* Represents a COutPoint.
- * @exports Outpoint
+ * @alias module:primitives.Outpoint
* @constructor
* @param {Hash?} hash
* @param {Number?} index
diff --git a/lib/primitives/output.js b/lib/primitives/output.js
index d8bb11a8c..2d37a6f49 100644
--- a/lib/primitives/output.js
+++ b/lib/primitives/output.js
@@ -1,7 +1,7 @@
/*!
* output.js - output object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -20,7 +20,7 @@ var policy = require('../protocol/policy');
/**
* Represents a transaction output.
- * @exports Output
+ * @alias module:primitives.Output
* @constructor
* @param {NakedOutput} options
* @property {Amount} value - Value in satoshis.
diff --git a/lib/primitives/tx.js b/lib/primitives/tx.js
index 8a7f9791e..95265d31c 100644
--- a/lib/primitives/tx.js
+++ b/lib/primitives/tx.js
@@ -1,7 +1,7 @@
/*!
* tx.js - transaction object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -38,10 +38,10 @@ var BAD_NONSTD_P2WSH = 3;
/**
* A static transaction object.
- * @exports TX
+ * @alias module:primitives.TX
* @constructor
* @param {Object} options - Transaction fields.
- * @property {Number} version - Transaction version. Note that BCoin reads
+ * @property {Number} version - Transaction version. Note that Bcoin reads
* versions as unsigned even though they are signed at the protocol level.
* This value will never be negative.
* @property {Number} flag - Flag field for segregated witness.
diff --git a/lib/primitives/txmeta.js b/lib/primitives/txmeta.js
index 3ab9c31e5..30c91eade 100644
--- a/lib/primitives/txmeta.js
+++ b/lib/primitives/txmeta.js
@@ -1,6 +1,6 @@
/*!
* txmeta.js - extended transaction object for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -14,6 +14,7 @@ var BufferReader = require('../utils/reader');
/**
* An extended transaction object.
+ * @alias module:primitives.TXMeta
* @constructor
* @param {Object} options
*/
diff --git a/lib/protocol/consensus.js b/lib/protocol/consensus.js
index 27a14ff1b..8851ea1cb 100644
--- a/lib/protocol/consensus.js
+++ b/lib/protocol/consensus.js
@@ -1,12 +1,16 @@
/*!
* consensus.js - consensus constants and helpers for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module protocol/consensus
+ */
+
var assert = require('assert');
var BN = require('bn.js');
diff --git a/lib/protocol/errors.js b/lib/protocol/errors.js
index 489bfdde4..f8e92f067 100644
--- a/lib/protocol/errors.js
+++ b/lib/protocol/errors.js
@@ -1,12 +1,16 @@
/*!
* errors.js - error objects for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module protocol/errors
+ */
+
var assert = require('assert');
var util = require('../utils/util');
@@ -15,11 +19,10 @@ var util = require('../utils/util');
* a mempool transaction validation error or a blockchain
* block verification error. Ultimately used to send
* `reject` packets to peers.
- * @exports VerifyError
* @constructor
* @extends Error
* @param {Block|TX} msg
- * @param {String} code - Reject packet ccode.
+ * @param {String} code - Reject packet code.
* @param {String} reason - Reject packet reason.
* @param {Number} score - Ban score increase
* (can be -1 for no reject packet).
diff --git a/lib/protocol/index.js b/lib/protocol/index.js
index f40b0705e..7ea3d2f61 100644
--- a/lib/protocol/index.js
+++ b/lib/protocol/index.js
@@ -1,5 +1,9 @@
'use strict';
+/**
+ * @module protocol
+ */
+
exports.consensus = require('./consensus');
exports.errors = require('./errors');
exports.networks = require('./networks');
diff --git a/lib/protocol/network.js b/lib/protocol/network.js
index 54d95aa9c..676922a26 100644
--- a/lib/protocol/network.js
+++ b/lib/protocol/network.js
@@ -1,7 +1,7 @@
/*!
* network.js - network object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -15,7 +15,7 @@ var TimeData = require('./timedata');
/**
* Represents a network.
- * @exports Network
+ * @alias module:protocol.Network
* @constructor
* @param {Object|NetworkType} options - See {@link module:network}.
*/
diff --git a/lib/protocol/networks.js b/lib/protocol/networks.js
index 7a5428e35..b75498a90 100644
--- a/lib/protocol/networks.js
+++ b/lib/protocol/networks.js
@@ -1,24 +1,24 @@
/*!
* network.js - bitcoin networks for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
-var BN = require('bn.js');
-
/**
- * @module network
+ * @module protocol/networks
*/
+var BN = require('bn.js');
+
var network = exports;
var main, testnet, regtest, segnet4, simnet;
/**
* Network type list.
- * @memberof module:network
+ * @memberof module:protocol/networks
* @const {String[]}
* @default
*/
@@ -26,9 +26,9 @@ var main, testnet, regtest, segnet4, simnet;
network.types = ['main', 'testnet', 'regtest', 'segnet4', 'simnet'];
/**
- * Main
+ * Mainnet
* @static
- * @lends module:network
+ * @lends module:protocol/networks
* @type {Object}
*/
diff --git a/lib/protocol/policy.js b/lib/protocol/policy.js
index 2dd3e37d3..50fd02187 100644
--- a/lib/protocol/policy.js
+++ b/lib/protocol/policy.js
@@ -1,12 +1,16 @@
/*!
* policy.js - bitcoin constants for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module protocol/policy
+ */
+
var consensus = require('./consensus');
/**
diff --git a/lib/protocol/timedata.js b/lib/protocol/timedata.js
index a656ab04c..227fd0d8b 100644
--- a/lib/protocol/timedata.js
+++ b/lib/protocol/timedata.js
@@ -1,7 +1,7 @@
/*!
* time.js - time management for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -15,7 +15,7 @@ var EventEmitter = require('events').EventEmitter;
* look it, but this is actually a semi-consensus-critical
* piece of code. It handles version packets from peers
* and calculates what to offset our system clock's time by.
- * @exports TimeData
+ * @alias module:protocol.TimeData
* @constructor
* @param {Number} [limit=200]
* @property {Array} samples
diff --git a/lib/script/common.js b/lib/script/common.js
index fa63e1775..25ed28045 100644
--- a/lib/script/common.js
+++ b/lib/script/common.js
@@ -1,12 +1,16 @@
/*!
- * encoding.js - script-related encoding for bcoin
+ * common.js - common script functions for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module script/common
+ */
+
var assert = require('assert');
var BN = require('bn.js');
var util = require('../utils/util');
diff --git a/lib/script/index.js b/lib/script/index.js
index 7c12cc5f3..8921f008e 100644
--- a/lib/script/index.js
+++ b/lib/script/index.js
@@ -1,5 +1,9 @@
'use strict';
+/**
+ * @module script
+ */
+
exports.common = require('./common');
exports.Opcode = require('./opcode');
exports.Program = require('./program');
diff --git a/lib/script/opcode.js b/lib/script/opcode.js
index e732dce13..94168bbcf 100644
--- a/lib/script/opcode.js
+++ b/lib/script/opcode.js
@@ -1,7 +1,7 @@
/*!
* opcode.js - opcode object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -18,7 +18,7 @@ var opcodes = common.opcodes;
/**
* A simple struct which contains
* an opcode and pushdata buffer.
- * @exports Opcode
+ * @alias module:script.Opcode
* @constructor
* @param {Number} value - Opcode.
* @param {Buffer?} data - Pushdata buffer.
diff --git a/lib/script/program.js b/lib/script/program.js
index 99dea39c5..72d1e084d 100644
--- a/lib/script/program.js
+++ b/lib/script/program.js
@@ -1,7 +1,7 @@
/*!
* program.js - program object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -15,6 +15,7 @@ var scriptTypes = common.types;
/**
* Witness Program
* @constructor
+ * @alias module:script.Program
* @param {Number} version
* @param {Buffer} data
* @property {Number} version - Ranges from 0 to 16.
diff --git a/lib/script/script.js b/lib/script/script.js
index d82f88991..185713ca0 100644
--- a/lib/script/script.js
+++ b/lib/script/script.js
@@ -1,7 +1,7 @@
/*!
* script.js - script interpreter for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -33,7 +33,7 @@ var STACK_NEGATE = common.STACK_NEGATE;
/**
* Represents a input or output script.
- * @exports Script
+ * @alias module:script.Script
* @constructor
* @param {Buffer|Array|Object|NakedScript} code - Array
* of script code or a serialized script Buffer.
diff --git a/lib/script/scriptnum.js b/lib/script/scriptnum.js
index 6371da826..98eae28c3 100644
--- a/lib/script/scriptnum.js
+++ b/lib/script/scriptnum.js
@@ -1,6 +1,6 @@
/*!
* scriptnum.js - script number for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -12,7 +12,9 @@ var EMPTY_ARRAY = new Buffer(0);
/**
* ScriptNum
+ * @alias module:script.ScriptNum
* @constructor
+ * @ignore
* @param {Number} value
*/
diff --git a/lib/script/sigcache.js b/lib/script/sigcache.js
index 6b2370cd0..116609c3a 100644
--- a/lib/script/sigcache.js
+++ b/lib/script/sigcache.js
@@ -1,6 +1,6 @@
/*!
* sigcache.js - signature cache for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -12,6 +12,7 @@ var ec = require('../crypto/ec');
/**
* Signature cache.
+ * @alias module:script.SigCache
* @constructor
* @param {Number} [size=50000]
* @property {Number} size
@@ -126,6 +127,7 @@ SigCache.prototype.verify = function verify(msg, sig, key, historical, high) {
/**
* Signature cache entry.
* @constructor
+ * @ignore
* @param {Buffer} sig
* @param {Buffer} key
* @property {Buffer} sig
diff --git a/lib/script/stack.js b/lib/script/stack.js
index ecdea6db5..6b0dcf99b 100644
--- a/lib/script/stack.js
+++ b/lib/script/stack.js
@@ -1,7 +1,7 @@
/*!
* stack.js - stack object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -11,7 +11,7 @@ var common = require('./common');
/**
* Represents the stack of a Script during execution.
- * @exports Stack
+ * @alias module:script.Stack
* @constructor
* @param {Buffer[]?} items - Stack items.
* @property {Buffer[]} items - Stack items.
diff --git a/lib/script/witness.js b/lib/script/witness.js
index 1741f4087..09c793310 100644
--- a/lib/script/witness.js
+++ b/lib/script/witness.js
@@ -1,7 +1,7 @@
/*!
* witness.js - witness object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -25,7 +25,7 @@ var STACK_NEGATE = common.STACK_NEGATE;
/**
* Refers to the witness field of segregated witness transactions.
- * @exports Witness
+ * @alias module:script.Witness
* @constructor
* @param {Buffer[]|NakedWitness} items - Array of
* stack items.
diff --git a/lib/utils/asn1.js b/lib/utils/asn1.js
index 7cd16ef22..a3faa8aad 100644
--- a/lib/utils/asn1.js
+++ b/lib/utils/asn1.js
@@ -1,6 +1,6 @@
/*!
* asn1.js - asn1 parsing for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*
* Parts of this software are based on asn1.js.
@@ -30,10 +30,17 @@
'use strict';
var BufferReader = require('./reader');
+
+/**
+ * @exports utils/asn1
+ */
+
var ASN1 = exports;
-/*
- * Primitives
+/**
+ * Read next tag.
+ * @param {BufferReader} br
+ * @returns {Object}
*/
ASN1.readTag = function readTag(br) {
@@ -60,6 +67,14 @@ ASN1.readTag = function readTag(br) {
};
};
+/**
+ * Read tag size.
+ * @param {BufferReader} br
+ * @param {Boolean} primitive
+ * @returns {Number}
+ * @throws on indefinite size
+ */
+
ASN1.readSize = function readSize(br, primitive) {
var size = br.readU8();
var bytes, i, j;
@@ -90,11 +105,25 @@ ASN1.readSize = function readSize(br, primitive) {
return size;
};
+/**
+ * Read implicit SEQ.
+ * @param {BufferReader} br
+ * @returns {Buffer}
+ */
+
ASN1.readSeq = function readSeq(br) {
var tag = ASN1.implicit(br, 0x10);
return br.readBytes(tag.size);
};
+/**
+ * Read next tag and assert implicit.
+ * @param {BufferReader} br
+ * @param {Number} type
+ * @returns {Object}
+ * @throws on unexpected tag
+ */
+
ASN1.implicit = function implicit(br, type) {
var tag = ASN1.readTag(br);
if (tag.type !== type)
@@ -102,6 +131,13 @@ ASN1.implicit = function implicit(br, type) {
return tag;
};
+/**
+ * Read implicit tag.
+ * @param {BufferReader} br
+ * @param {Number} type
+ * @returns {Boolean}
+ */
+
ASN1.explicit = function explicit(br, type) {
var offset = br.offset;
var tag = ASN1.readTag(br);
@@ -112,10 +148,23 @@ ASN1.explicit = function explicit(br, type) {
return true;
};
+/**
+ * Read next implicit SEQ and return a new reader.
+ * @param {BufferReader} br
+ * @returns {BufferReader}
+ */
+
ASN1.seq = function seq(br) {
return new BufferReader(ASN1.readSeq(br), true);
};
+/**
+ * Read implicit int.
+ * @param {BufferReader} br
+ * @param {Boolean?} readNum
+ * @returns {Buffer|Number}
+ */
+
ASN1.readInt = function readInt(br, readNum) {
var tag = ASN1.implicit(br, 0x02);
var num = br.readBytes(tag.size);
@@ -126,18 +175,38 @@ ASN1.readInt = function readInt(br, readNum) {
return num;
};
+/**
+ * Read explicit int.
+ * @param {BufferReader} br
+ * @param {Number} type
+ * @param {Boolean?} readNum
+ * @returns {Buffer|Number} `-1` on not present.
+ */
+
ASN1.readExplicitInt = function readExplicitInt(br, type, readNum) {
if (!ASN1.explicit(br, type))
return -1;
return ASN1.readInt(br, readNum);
};
+/**
+ * Read and align an implicit bitstr.
+ * @param {BufferReader} br
+ * @returns {Buffer}
+ */
+
ASN1.readBitstr = function readBitstr(br) {
var tag = ASN1.implicit(br, 0x03);
var str = br.readBytes(tag.size);
return ASN1.alignBitstr(str);
};
+/**
+ * Read an implicit string (any type).
+ * @param {BufferReader} br
+ * @returns {String}
+ */
+
ASN1.readString = function readString(br) {
var tag = ASN1.readTag(br);
var str;
@@ -167,6 +236,12 @@ ASN1.readString = function readString(br) {
}
};
+/**
+ * Align a bitstr.
+ * @param {Buffer} data
+ * @returns {Buffer}
+ */
+
ASN1.alignBitstr = function(data) {
var padding = data[0];
var bits = (data.length - 1) * 8 - padding;
@@ -188,8 +263,10 @@ ASN1.alignBitstr = function(data) {
return out;
};
-/*
- * Certificates
+/**
+ * Read an entire certificate.
+ * @param {BufferReader} br
+ * @returns {Object}
*/
ASN1.readCert = function readCert(br) {
@@ -207,6 +284,12 @@ ASN1.readCert = function readCert(br) {
};
};
+/**
+ * Read only the TBS certificate.
+ * @param {BufferReader} br
+ * @returns {Object}
+ */
+
ASN1.readTBS = function readTBS(br) {
var buf = br;
@@ -226,6 +309,12 @@ ASN1.readTBS = function readTBS(br) {
};
};
+/**
+ * Read an implicit pubkey.
+ * @param {BufferReader} br
+ * @returns {Object}
+ */
+
ASN1.readPubkey = function readPubkey(br) {
br = ASN1.seq(br);
return {
@@ -234,6 +323,12 @@ ASN1.readPubkey = function readPubkey(br) {
};
};
+/**
+ * Read implicit name.
+ * @param {BufferReader} br
+ * @returns {Object[]}
+ */
+
ASN1.readName = function readName(br) {
var values = [];
@@ -251,6 +346,12 @@ ASN1.readName = function readName(br) {
return values;
};
+/**
+ * Read implicit validity timerange.
+ * @param {BufferReader} br
+ * @returns {Object}
+ */
+
ASN1.readValidity = function readValidity(br) {
br = ASN1.seq(br);
return {
@@ -259,6 +360,12 @@ ASN1.readValidity = function readValidity(br) {
};
};
+/**
+ * Read implicit timestamp.
+ * @param {BufferReader} br
+ * @returns {Number}
+ */
+
ASN1.readTime = function readTime(br) {
var tag = ASN1.readTag(br);
var str = br.readString('ascii', tag.size);
@@ -292,12 +399,24 @@ ASN1.readTime = function readTime(br) {
return Date.UTC(year, mon - 1, day, hour, min, sec, 0) / 1000;
};
+/**
+ * Read and format OID to string.
+ * @param {BufferReader} br
+ * @returns {String}
+ */
+
ASN1.readOID = function readOID(br) {
var tag = ASN1.implicit(br, 0x06);
var data = br.readBytes(tag.size);
return ASN1.formatOID(data);
};
+/**
+ * Format an OID buffer to a string.
+ * @param {Buffer} data
+ * @returns {String}
+ */
+
ASN1.formatOID = function formatOID(data) {
var br = new BufferReader(data);
var ids = [];
@@ -325,6 +444,12 @@ ASN1.formatOID = function formatOID(data) {
return result.join('.');
};
+/**
+ * Read algorithm identifier.
+ * @param {BufferReader} br
+ * @returns {Object}
+ */
+
ASN1.readAlgIdent = function readAlgIdent(br) {
var params = null;
var alg, tag;
@@ -346,8 +471,10 @@ ASN1.readAlgIdent = function readAlgIdent(br) {
};
};
-/*
- * RSA
+/**
+ * Read RSA public key.
+ * @param {BufferReader} br
+ * @returns {Object}
*/
ASN1.readRSAPublic = function readRSAPublic(br) {
@@ -358,6 +485,12 @@ ASN1.readRSAPublic = function readRSAPublic(br) {
};
};
+/**
+ * Read RSA private key.
+ * @param {BufferReader} br
+ * @returns {Object}
+ */
+
ASN1.readRSAPrivate = function readRSAPrivate(br) {
br = ASN1.seq(br);
return {
@@ -373,22 +506,42 @@ ASN1.readRSAPrivate = function readRSAPrivate(br) {
};
};
-/*
- * Public
+/**
+ * Read RSA public key from buffer.
+ * @param {Buffer} data
+ * @returns {Object}
*/
ASN1.parseRSAPublic = function parseRSAPublic(data) {
return ASN1.readRSAPublic(new BufferReader(data, true));
};
+/**
+ * Read RSA private key from buffer.
+ * @param {Buffer} data
+ * @returns {Object}
+ */
+
ASN1.parseRSAPrivate = function parseRSAPrivate(data) {
return ASN1.readRSAPrivate(new BufferReader(data, true));
};
+/**
+ * Read certificate from buffer.
+ * @param {Buffer} data
+ * @returns {Object}
+ */
+
ASN1.parseCert = function parseCert(data) {
return ASN1.readCert(new BufferReader(data, true));
};
+/**
+ * Read TBS certificate from buffer.
+ * @param {Buffer} data
+ * @returns {Object}
+ */
+
ASN1.parseTBS = function parseTBS(data) {
return ASN1.readTBS(new BufferReader(data, true));
};
diff --git a/lib/utils/async.js b/lib/utils/async.js
index d6ae2f95b..b37a1c24d 100644
--- a/lib/utils/async.js
+++ b/lib/utils/async.js
@@ -1,6 +1,6 @@
/*!
* async.js - async object class for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -15,6 +15,7 @@ var EventEmitter = require('events').EventEmitter;
/**
* An abstract object that handles state and
* provides recallable open and close methods.
+ * @alias module:utils.AsyncObject
* @constructor
* @property {Boolean} loading
* @property {Boolean} closing
@@ -37,6 +38,7 @@ util.inherits(AsyncObject, EventEmitter);
/**
* Open the object (recallable).
+ * @method
* @returns {Promise}
*/
@@ -51,6 +53,7 @@ AsyncObject.prototype.open = co(function* open() {
/**
* Open the object (without a lock).
+ * @method
* @private
* @returns {Promise}
*/
@@ -79,6 +82,7 @@ AsyncObject.prototype.__open = co(function* open() {
/**
* Close the object (recallable).
+ * @method
* @returns {Promise}
*/
@@ -93,6 +97,7 @@ AsyncObject.prototype.close = co(function* close() {
/**
* Close the object (without a lock).
+ * @method
* @private
* @returns {Promise}
*/
diff --git a/lib/utils/asyncemitter.js b/lib/utils/asyncemitter.js
index 476131eff..5fac07e71 100644
--- a/lib/utils/asyncemitter.js
+++ b/lib/utils/asyncemitter.js
@@ -1,6 +1,6 @@
/*!
* asyncemitter.js - event emitter which resolves promises.
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -11,6 +11,7 @@ var co = require('./co');
/**
* Represents a promise-resolving event emitter.
+ * @alias module:utils.AsyncEmitter
* @see EventEmitter
* @constructor
*/
@@ -217,6 +218,7 @@ AsyncEmitter.prototype.listenerCount = function listenerCount(type) {
/**
* Emit an event. Wait for promises to resolve.
+ * @method
* @param {String} type
* @param {...Object} args
* @returns {Promise}
@@ -279,6 +281,7 @@ AsyncEmitter.prototype.emit = co(function* emit(type) {
/**
* Emit an event. Ignore rejections.
+ * @method
* @param {String} type
* @param {...Object} args
* @returns {Promise}
@@ -295,6 +298,7 @@ AsyncEmitter.prototype.tryEmit = co(function* tryEmit() {
/**
* Event Listener
* @constructor
+ * @ignore
* @param {Function} handler
* @param {Boolean} once
* @property {Function} handler
diff --git a/lib/utils/base32.js b/lib/utils/base32.js
index e93591690..aec74529e 100644
--- a/lib/utils/base32.js
+++ b/lib/utils/base32.js
@@ -1,13 +1,13 @@
/*!
* base32.js - base32 for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
-/*
- * Base32
+/**
+ * @module utils/base32
*/
var base32 = 'abcdefghijklmnopqrstuvwxyz234567';
diff --git a/lib/utils/base58.js b/lib/utils/base58.js
index 5c7df1888..edec079b5 100644
--- a/lib/utils/base58.js
+++ b/lib/utils/base58.js
@@ -1,12 +1,16 @@
/*!
* base58.js - base58 for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module utils/base58
+ */
+
var native = require('./native').binding;
var assert = require('assert');
diff --git a/lib/utils/bloom.js b/lib/utils/bloom.js
index 9493f8a15..2cc355a9f 100644
--- a/lib/utils/bloom.js
+++ b/lib/utils/bloom.js
@@ -1,7 +1,7 @@
/*!
* bloom.js - bloom filter for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -25,7 +25,7 @@ var LN2 = 0.6931471805599453094172321214581765680755001343602552;
/**
* Bloom Filter
- * @exports Bloom
+ * @alias module:utils.Bloom
* @constructor
* @param {Number} size - Filter size in bits.
* @param {Number} n - Number of hash functions.
@@ -387,7 +387,7 @@ Bloom.fromRaw = function fromRaw(data, enc) {
/**
* A rolling bloom filter used internally
* (do not relay this on the p2p network).
- * @exports RollingFilter
+ * @alias module:utils.RollingFilter
* @constructor
* @param {Number} items - Expected number of items.
* @param {Number} rate - False positive rate (0.0-1.0).
diff --git a/lib/utils/co.js b/lib/utils/co.js
index 36b21f95f..3787e47e4 100644
--- a/lib/utils/co.js
+++ b/lib/utils/co.js
@@ -1,12 +1,16 @@
/*!
* co.js - promise and generator control flow for bcoin
* Originally based on yoursnetwork's "asink" module.
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module utils/co
+ */
+
var nextTick = require('./nexttick');
var every;
@@ -209,6 +213,7 @@ function promisify(func, ctx) {
/**
* Execute each promise and
* have them pass a truth test.
+ * @method
* @param {Promise[]} jobs
* @returns {Promise}
*/
@@ -237,6 +242,7 @@ function job(resolve, reject) {
/**
* Job
* @constructor
+ * @ignore
* @param {Function} resolve
* @param {Function} reject
* @property {Function} resolve
diff --git a/lib/utils/encoding.js b/lib/utils/encoding.js
index eff488f32..1fa96fe96 100644
--- a/lib/utils/encoding.js
+++ b/lib/utils/encoding.js
@@ -1,12 +1,16 @@
/*!
* encoding.js - encoding utils for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module utils/encoding
+ */
+
var assert = require('assert');
var BN = require('bn.js');
var encoding = exports;
diff --git a/lib/utils/index.js b/lib/utils/index.js
index be78346f8..12b9c0a87 100644
--- a/lib/utils/index.js
+++ b/lib/utils/index.js
@@ -1,5 +1,9 @@
'use strict';
+/**
+ * @module utils
+ */
+
exports.ASN1 = require('./asn1');
exports.AsyncObject = require('./async');
exports.base32 = require('./base32');
diff --git a/lib/utils/ip.js b/lib/utils/ip.js
index d16399191..05e67727b 100644
--- a/lib/utils/ip.js
+++ b/lib/utils/ip.js
@@ -1,7 +1,7 @@
/*!
* ip.js - ip utils for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License).
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*
* Parts of this software are based on node-ip.
@@ -13,6 +13,11 @@
var assert = require('assert');
var base32 = require('./base32');
+
+/**
+ * @exports utils/ip
+ */
+
var IP = exports;
/*
@@ -875,17 +880,30 @@ IP.isEqual = function isEqual(a, b) {
/**
* Represents a parsed address.
+ * @constructor
+ * @alias module:utils/ip.Address
* @param {String} host
* @param {Number} port
* @param {Number} type
* @param {String} hostname
- * @param {Buffer} raw
+ * @param {Buffer|null} raw
+ * @property {String} host
+ * @property {Number} port
+ * @property {Number} type
+ * @property {String} hostname
+ * @property {Buffer} raw
*/
function Address(host, port, type, hostname, raw) {
- this.host = host;
- this.port = port;
- this.type = type;
- this.hostname = hostname;
+ this.host = host || '0.0.0.0';
+ this.port = port || 0;
+ this.type = type || IP.types.IPV4;
+ this.hostname = hostname || '0.0.0.0:0';
this.raw = raw || ZERO_IP;
}
+
+/*
+ * Expose
+ */
+
+IP.Address = Address;
diff --git a/lib/utils/lazy-browser.js b/lib/utils/lazy-browser.js
index fe1327092..92b907a27 100644
--- a/lib/utils/lazy-browser.js
+++ b/lib/utils/lazy-browser.js
@@ -1,6 +1,6 @@
/*!
* lazy-browser.js - lazy loading for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/utils/lazy.js b/lib/utils/lazy.js
index 27d6c3e46..7627315ad 100644
--- a/lib/utils/lazy.js
+++ b/lib/utils/lazy.js
@@ -1,11 +1,18 @@
/*!
* lazy.js - lazy loading for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * Setup a lazy loader.
+ * @alias module:utils.lazy
+ * @param {Function} require
+ * @param {Object} exports
+ */
+
module.exports = function lazy(require, exports) {
return function _require(name, path) {
var cache;
diff --git a/lib/utils/list.js b/lib/utils/list.js
index 17421acba..e5bfb568c 100644
--- a/lib/utils/list.js
+++ b/lib/utils/list.js
@@ -1,6 +1,6 @@
/*!
* list.js - double linked list for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -10,7 +10,7 @@ var assert = require('assert');
/**
* A double linked list.
- * @exports List
+ * @alias module:utils.List
* @constructor
* @property {ListItem|null} head
* @property {ListItem|null} tail
@@ -256,6 +256,7 @@ List.prototype.toArray = function toArray() {
/**
* Represents an linked list item.
+ * @alias module:utils.ListItem
* @constructor
* @private
* @param {String} key
diff --git a/lib/utils/lock.js b/lib/utils/lock.js
index d9f5d3a6f..f0a14ca05 100644
--- a/lib/utils/lock.js
+++ b/lib/utils/lock.js
@@ -1,7 +1,7 @@
/*!
* lock.js - lock and queue for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -11,7 +11,7 @@ var assert = require('assert');
/**
* Represents a mutex lock for locking asynchronous object methods.
- * @exports Lock
+ * @alias module:utils.Lock
* @constructor
* @param {Boolean?} named - Whether to
* maintain a map of queued jobs by job name.
@@ -181,7 +181,7 @@ Lock.prototype.destroy = function destroy() {
/**
* Represents a mutex lock for locking asynchronous object methods.
* Locks methods according to passed-in key.
- * @exports MappedLock
+ * @alias module:utils.MappedLock
* @constructor
*/
@@ -328,8 +328,8 @@ MappedLock.prototype.destroy = function destroy() {
/**
* Lock Job
- * @exports Job
* @constructor
+ * @ignore
* @param {Function} resolve
* @param {Function} reject
* @param {String?} name
diff --git a/lib/utils/lru.js b/lib/utils/lru.js
index 15bc99e9b..e177c7f92 100644
--- a/lib/utils/lru.js
+++ b/lib/utils/lru.js
@@ -1,7 +1,7 @@
/*!
* lru.js - LRU cache for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -11,7 +11,7 @@ var assert = require('assert');
/**
* An LRU cache, used for caching {@link ChainEntry}s.
- * @exports LRU
+ * @alias module:utils.LRU
* @constructor
* @param {Number} capacity
* @param {Function?} getSize
@@ -422,6 +422,7 @@ LRU.prototype.unpush = function unpush(key) {
/**
* Represents an LRU item.
+ * @alias module:utils.LRUItem
* @constructor
* @private
* @param {String} key
@@ -437,6 +438,7 @@ function LRUItem(key, value) {
/**
* LRU Batch
+ * @alias module:utils.LRUBatch
* @constructor
* @param {LRU} lru
*/
@@ -494,6 +496,7 @@ LRUBatch.prototype.commit = function commit() {
/**
* LRU Op
+ * @alias module:utils.LRUOp
* @constructor
* @private
* @param {Boolean} remove
diff --git a/lib/utils/map.js b/lib/utils/map.js
index a436c27ca..7883bc9e7 100644
--- a/lib/utils/map.js
+++ b/lib/utils/map.js
@@ -1,6 +1,6 @@
/*!
* map.js - hash table for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -10,6 +10,7 @@ var assert = require('assert');
/**
* Map
+ * @alias module:utils.Map
* @constructor
*/
diff --git a/lib/utils/murmur3.js b/lib/utils/murmur3.js
index 675cd65c2..c4df301d8 100644
--- a/lib/utils/murmur3.js
+++ b/lib/utils/murmur3.js
@@ -1,7 +1,7 @@
/*!
* murmur3.js - murmur3 hash for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -11,7 +11,7 @@ var native = require('./native').binding;
/**
* Murmur3 hash.
- * @memberof Bloom
+ * @alias module:utils.murmur3
* @param {Buffer} data
* @param {Number} seed
* @returns {Number}
diff --git a/lib/utils/native.js b/lib/utils/native.js
index 224517c7f..0c9df7333 100644
--- a/lib/utils/native.js
+++ b/lib/utils/native.js
@@ -1,6 +1,6 @@
/*!
* native.js - native bindings for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/utils/nexttick-browser.js b/lib/utils/nexttick-browser.js
index 0a7b470ac..77e92d1be 100644
--- a/lib/utils/nexttick-browser.js
+++ b/lib/utils/nexttick-browser.js
@@ -1,6 +1,6 @@
/*!
* nexttick.js - setimmediate for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/utils/nexttick.js b/lib/utils/nexttick.js
index 618599053..1ce33f81c 100644
--- a/lib/utils/nexttick.js
+++ b/lib/utils/nexttick.js
@@ -1,6 +1,6 @@
/*!
* nexttick.js - setimmediate for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/utils/nfkd-browser.js b/lib/utils/nfkd-browser.js
index 537771d75..6ca178832 100644
--- a/lib/utils/nfkd-browser.js
+++ b/lib/utils/nfkd-browser.js
@@ -1,6 +1,6 @@
-/**
+/*!
* nfkd-browser.js - unicode normalization for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/utils/nfkd.js b/lib/utils/nfkd.js
index 8c9431a71..92470ead4 100644
--- a/lib/utils/nfkd.js
+++ b/lib/utils/nfkd.js
@@ -1,11 +1,18 @@
-/**
+/*!
* nfkd.js - unicode normalization for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
var unorm;
+/**
+ * Normalize unicode string.
+ * @alias module:utils.nfkd
+ * @param {String} str
+ * @returns {String}
+ */
+
function nfkd(str) {
if (str.normalize)
return str.normalize('NFKD');
diff --git a/lib/utils/pem.js b/lib/utils/pem.js
index 2ed2d3486..15113bec7 100644
--- a/lib/utils/pem.js
+++ b/lib/utils/pem.js
@@ -1,14 +1,26 @@
/*!
* pem.js - pem parsing for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
var assert = require('assert');
+
+/**
+ * @exports utils/pem
+ */
+
var PEM = exports;
+/**
+ * Parse PEM into separated chunks.
+ * @param {String} pem
+ * @returns {Object[]}
+ * @throws on parse error
+ */
+
PEM.parse = function parse(pem) {
var buf = '';
var chunks = [];
@@ -49,6 +61,13 @@ PEM.parse = function parse(pem) {
return chunks;
};
+/**
+ * Decode PEM into a manageable format.
+ * @param {String} pem
+ * @returns {Object}
+ * @throws on parse error
+ */
+
PEM.decode = function decode(pem) {
var chunks = PEM.parse(pem);
var body = chunks[0];
@@ -80,6 +99,14 @@ PEM.decode = function decode(pem) {
};
};
+/**
+ * Encode DER to PEM.
+ * @param {Buffer} der
+ * @param {String} type - e.g. "ec".
+ * @param {String?} suffix - e.g. "public key".
+ * @returns {String}
+ */
+
PEM.encode = function encode(der, type, suffix) {
var pem = '';
var i;
diff --git a/lib/utils/protobuf.js b/lib/utils/protobuf.js
index 9cdfe34f0..d6541375b 100644
--- a/lib/utils/protobuf.js
+++ b/lib/utils/protobuf.js
@@ -1,11 +1,15 @@
/*!
* protobuf.js - protobufs for bcoin
- * Copyright (c) 2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module utils/protobuf
+ */
+
var util = require('../utils/util');
var assert = require('assert');
var BufferReader = require('../utils/reader');
diff --git a/lib/utils/reader.js b/lib/utils/reader.js
index c6339c614..9aad2f354 100644
--- a/lib/utils/reader.js
+++ b/lib/utils/reader.js
@@ -1,7 +1,7 @@
/*!
* reader.js - buffer reader for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -13,7 +13,7 @@ var crypto = require('../crypto/crypto');
/**
* An object that allows reading of buffers in a sane manner.
- * @exports BufferReader
+ * @alias module:utils.BufferReader
* @constructor
* @param {Buffer} data
* @param {Boolean?} zeroCopy - Do not reallocate buffers when
diff --git a/lib/utils/staticwriter.js b/lib/utils/staticwriter.js
index 0609aa3b4..1555652d8 100644
--- a/lib/utils/staticwriter.js
+++ b/lib/utils/staticwriter.js
@@ -1,6 +1,6 @@
/*!
* staticwriter.js - buffer writer for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -12,6 +12,7 @@ var crypto = require('../crypto/crypto');
/**
* Statically allocated buffer writer.
+ * @alias module:utils.StaticWriter
* @constructor
* @param {Number} size
*/
diff --git a/lib/utils/util.js b/lib/utils/util.js
index 96cfaeb4d..b438d73ef 100644
--- a/lib/utils/util.js
+++ b/lib/utils/util.js
@@ -1,7 +1,7 @@
/*!
* util.js - utils for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -13,9 +13,14 @@ var assert = require('assert');
var nodeUtil = require('util');
var fs = require('fs');
var os = require('os');
-var util = exports;
var Number, Math, Date;
+/**
+ * @exports utils/util
+ */
+
+var util = exports;
+
/**
* Reference to the global object.
* @const {Object}
@@ -201,7 +206,6 @@ util.equal = function equal(a, b) {
/**
* Call `setImmediate`, `process.nextTick`,
* or `setInterval` depending.
- * @name nextTick
* @function
* @returns {Promise}
*/
diff --git a/lib/utils/writer.js b/lib/utils/writer.js
index 6d94aee53..c1b53c452 100644
--- a/lib/utils/writer.js
+++ b/lib/utils/writer.js
@@ -1,7 +1,7 @@
/*!
* writer.js - buffer writer for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -51,7 +51,7 @@ var FILL = 24;
* of this, it can also act as a size calculator
* which is useful for guaging block size
* without actually serializing any data.
- * @exports BufferWriter
+ * @alias module:utils.BufferWriter
* @constructor
*/
diff --git a/lib/wallet/account.js b/lib/wallet/account.js
index 254762190..cba6c54f1 100644
--- a/lib/wallet/account.js
+++ b/lib/wallet/account.js
@@ -1,6 +1,6 @@
/*!
* account.js - account object for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -23,7 +23,7 @@ var HD = require('../hd/hd');
* 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.
- * @exports Account
+ * @alias module:wallet.Account
* @constructor
* @param {Object} options
* @param {WalletDB} options.db
diff --git a/lib/wallet/client.js b/lib/wallet/client.js
index 02ec32682..76af2be1c 100644
--- a/lib/wallet/client.js
+++ b/lib/wallet/client.js
@@ -1,7 +1,7 @@
/*!
* client.js - http client for wallets
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -19,8 +19,8 @@ var co = require('../utils/co');
var IOClient = require('socket.io-client');
/**
- * BCoin HTTP client.
- * @exports WalletClient
+ * Bcoin HTTP client.
+ * @alias module:wallet.WalletClient
* @constructor
* @param {String} uri
* @param {Object?} options
diff --git a/lib/wallet/common.js b/lib/wallet/common.js
index a2906e9d5..b439d2839 100644
--- a/lib/wallet/common.js
+++ b/lib/wallet/common.js
@@ -1,11 +1,15 @@
/*!
* common.js - commonly required functions for wallet.
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @exports wallet/common
+ */
+
var common = exports;
/**
diff --git a/lib/wallet/index.js b/lib/wallet/index.js
index 074f3c5fa..60118ed47 100644
--- a/lib/wallet/index.js
+++ b/lib/wallet/index.js
@@ -1,5 +1,9 @@
'use strict';
+/**
+ * @module wallet
+ */
+
exports.Account = require('./account');
exports.Client = require('./client');
exports.common = require('./common');
diff --git a/lib/wallet/layout-browser.js b/lib/wallet/layout-browser.js
index 92e173978..463ed2600 100644
--- a/lib/wallet/layout-browser.js
+++ b/lib/wallet/layout-browser.js
@@ -1,6 +1,6 @@
/*!
* layout-browser.js - walletdb and txdb layout for browser.
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/wallet/layout.js b/lib/wallet/layout.js
index c48cd7138..d493f3abb 100644
--- a/lib/wallet/layout.js
+++ b/lib/wallet/layout.js
@@ -1,6 +1,6 @@
/*!
* layout.js - data layout for wallets
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/wallet/masterkey.js b/lib/wallet/masterkey.js
index 4f1b4b719..30807497f 100644
--- a/lib/wallet/masterkey.js
+++ b/lib/wallet/masterkey.js
@@ -1,6 +1,6 @@
/*!
* masterkey.js - master bip32 key object for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -19,7 +19,7 @@ var HD = require('../hd/hd');
/**
* Master BIP32 key which can exist
* in a timed out encrypted state.
- * @exports MasterKey
+ * @alias module:wallet.MasterKey
* @constructor
* @param {Object} options
*/
diff --git a/lib/wallet/path.js b/lib/wallet/path.js
index ed3068a76..1a6497052 100644
--- a/lib/wallet/path.js
+++ b/lib/wallet/path.js
@@ -1,6 +1,6 @@
/*!
* path.js - path object for wallets
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -14,8 +14,8 @@ var Address = require('../primitives/address');
/**
* Path
+ * @alias module:wallet.Path
* @constructor
- * @private
* @property {WalletID} wid
* @property {String} name - Account name.
* @property {Number} account - Account index.
diff --git a/lib/wallet/records.js b/lib/wallet/records.js
index 6053b9650..a0a571341 100644
--- a/lib/wallet/records.js
+++ b/lib/wallet/records.js
@@ -1,11 +1,15 @@
/*!
* records.js - walletdb records
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module wallet/records
+ */
+
var assert = require('assert');
var util = require('../utils/util');
var encoding = require('../utils/encoding');
diff --git a/lib/wallet/txdb.js b/lib/wallet/txdb.js
index 15e8b156c..ae2593ee4 100644
--- a/lib/wallet/txdb.js
+++ b/lib/wallet/txdb.js
@@ -1,7 +1,7 @@
/*!
* txdb.js - persistent transaction pool
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -29,7 +29,7 @@ var DUMMY = new Buffer([0]);
/**
* TXDB
- * @exports TXDB
+ * @alias module:wallet.TXDB
* @constructor
* @param {Wallet} wallet
*/
@@ -2604,6 +2604,7 @@ TXDB.prototype.abandon = co(function* abandon(hash) {
/**
* Balance
+ * @alias module:wallet.Balance
* @constructor
* @param {WalletID} wid
* @param {String} id
@@ -2672,6 +2673,7 @@ Balance.prototype.inspect = function inspect() {
/**
* Chain State
+ * @alias module:wallet.ChainState
* @constructor
* @param {WalletID} wid
* @param {String} id
@@ -2793,6 +2795,7 @@ TXDBState.prototype.inspect = function inspect() {
/**
* Credit (wrapped coin)
+ * @alias module:wallet.Credit
* @constructor
* @param {Coin} coin
* @param {Boolean?} spent
@@ -2880,6 +2883,7 @@ Credit.fromTX = function fromTX(tx, index, height) {
/**
* Transaction Details
+ * @alias module:wallet.Details
* @constructor
* @param {TXDB} txdb
* @param {TX} tx
@@ -3079,6 +3083,7 @@ Details.prototype.toJSON = function toJSON() {
/**
* Transaction Details Member
+ * @alias module:wallet.DetailsMember
* @constructor
* @property {Number} value
* @property {Address} address
@@ -3123,6 +3128,7 @@ DetailsMember.prototype.getJSON = function getJSON(network) {
/**
* Block Record
+ * @alias module:wallet.BlockRecord
* @constructor
* @param {Hash} hash
* @param {Number} height
diff --git a/lib/wallet/wallet.js b/lib/wallet/wallet.js
index d29fa2959..5fc502749 100644
--- a/lib/wallet/wallet.js
+++ b/lib/wallet/wallet.js
@@ -1,7 +1,7 @@
/*!
* wallet.js - wallet object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -34,7 +34,7 @@ var consensus = require('../protocol/consensus');
/**
* BIP44 Wallet
- * @exports Wallet
+ * @alias module:wallet.Wallet
* @constructor
* @param {Object} options
* @param {WalletDB} options.db
diff --git a/lib/wallet/walletdb.js b/lib/wallet/walletdb.js
index 6370f7494..bfc6da04a 100644
--- a/lib/wallet/walletdb.js
+++ b/lib/wallet/walletdb.js
@@ -1,7 +1,7 @@
/*!
* walletdb.js - storage for wallets
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -39,7 +39,7 @@ var DUMMY = new Buffer([0]);
/**
* WalletDB
- * @exports WalletDB
+ * @alias module:wallet.WalletDB
* @constructor
* @param {Object} options
* @param {String?} options.name - Database name.
@@ -2148,6 +2148,7 @@ WalletDB.prototype._resetChain = co(function* resetChain(entry) {
/**
* WalletOptions
+ * @alias module:wallet.WalletOptions
* @constructor
* @param {Object} options
*/
diff --git a/lib/wallet/walletkey.js b/lib/wallet/walletkey.js
index cf069ac05..24ee2b942 100644
--- a/lib/wallet/walletkey.js
+++ b/lib/wallet/walletkey.js
@@ -1,7 +1,7 @@
/*!
* walletkey.js - walletkey object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -14,7 +14,7 @@ var Script = require('../script/script');
/**
* Represents a key ring which amounts to an address.
- * @exports WalletKey
+ * @alias module:wallet.WalletKey
* @constructor
* @param {Object} options
*/
diff --git a/lib/workers/framer.js b/lib/workers/framer.js
index b4b3dbc0a..758efc258 100644
--- a/lib/workers/framer.js
+++ b/lib/workers/framer.js
@@ -1,7 +1,7 @@
/*!
* workers.js - worker processes for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -13,6 +13,7 @@ var StaticWriter = require('../utils/staticwriter');
/**
* Framer
+ * @alias module:workers.Framer
* @constructor
*/
diff --git a/lib/workers/index.js b/lib/workers/index.js
index fa86f83a5..3a409404f 100644
--- a/lib/workers/index.js
+++ b/lib/workers/index.js
@@ -1,5 +1,9 @@
'use strict';
+/**
+ * @module workers
+ */
+
exports.jobs = require('./jobs');
exports.Framer = require('./framer');
exports.Parser = require('./parser');
diff --git a/lib/workers/jobs.js b/lib/workers/jobs.js
index 51edd5904..c95ca90fa 100644
--- a/lib/workers/jobs.js
+++ b/lib/workers/jobs.js
@@ -1,6 +1,6 @@
/*!
* jobs.js - worker jobs for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -12,9 +12,7 @@ var mine = require('../mining/mine');
var packets = require('./packets');
/**
- * Jobs to execute within the worker.
- * @memberof Workers
- * @const {Object}
+ * @exports workers/jobs
*/
var jobs = exports;
diff --git a/lib/workers/master.js b/lib/workers/master.js
index c713aca28..a51fef0ce 100644
--- a/lib/workers/master.js
+++ b/lib/workers/master.js
@@ -1,7 +1,7 @@
/*!
* workers.js - worker processes for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -20,7 +20,7 @@ var server;
/**
* Represents the master process.
- * @exports Master
+ * @alias module:workers.Master
* @constructor
*/
diff --git a/lib/workers/packets.js b/lib/workers/packets.js
index d08cb4660..3d3e30b38 100644
--- a/lib/workers/packets.js
+++ b/lib/workers/packets.js
@@ -1,11 +1,15 @@
/*!
* packets.js - worker packets for bcoin
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
+/**
+ * @module workers/packets
+ */
+
var assert = require('assert');
var util = require('../utils/util');
var BufferReader = require('../utils/reader');
diff --git a/lib/workers/parser-client.js b/lib/workers/parser-client.js
index b4a735225..05d20f000 100644
--- a/lib/workers/parser-client.js
+++ b/lib/workers/parser-client.js
@@ -1,7 +1,7 @@
/*!
* workers.js - worker processes for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -17,6 +17,7 @@ var CoinView = require('../coins/coinview');
/**
* Parser
+ * @alias module:workers.ParserClient
* @constructor
*/
diff --git a/lib/workers/parser.js b/lib/workers/parser.js
index aab56fda9..ad3b67710 100644
--- a/lib/workers/parser.js
+++ b/lib/workers/parser.js
@@ -1,7 +1,7 @@
/*!
* workers.js - worker processes for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -14,6 +14,7 @@ var packets = require('./packets');
/**
* Parser
+ * @alias module:workers.Parser
* @constructor
*/
@@ -166,6 +167,7 @@ Parser.prototype.parsePacket = function parsePacket(header, data) {
/**
* Header
* @constructor
+ * @ignore
*/
function Header(id, cmd, size) {
diff --git a/lib/workers/worker-browser.js b/lib/workers/worker-browser.js
index 212d46311..a1fa25d9a 100644
--- a/lib/workers/worker-browser.js
+++ b/lib/workers/worker-browser.js
@@ -1,7 +1,7 @@
/*!
* worker.js - worker thread/process for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/workers/worker.js b/lib/workers/worker.js
index 1e71b37fa..97878bb03 100644
--- a/lib/workers/worker.js
+++ b/lib/workers/worker.js
@@ -1,7 +1,7 @@
/*!
* worker.js - worker thread/process for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
diff --git a/lib/workers/workerpool.js b/lib/workers/workerpool.js
index c4d08ecb2..dbbcdd852 100644
--- a/lib/workers/workerpool.js
+++ b/lib/workers/workerpool.js
@@ -1,7 +1,7 @@
/*!
* workerpool.js - worker processes for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
- * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
+ * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
@@ -22,7 +22,7 @@ var packets = require('./packets');
/**
* A worker pool.
- * @exports WorkerPool
+ * @alias module:workers.WorkerPool
* @constructor
* @param {Object} options
* @param {Number} [options.size=num-cores] - Max pool size.
@@ -297,6 +297,7 @@ WorkerPool.prototype.execute = function execute(packet, timeout) {
/**
* Execute the tx verification job (default timeout).
+ * @method
* @param {TX} tx
* @param {CoinView} view
* @param {VerifyFlags} flags
@@ -311,6 +312,7 @@ WorkerPool.prototype.verify = co(function* verify(tx, view, flags) {
/**
* Execute the tx signing job (default timeout).
+ * @method
* @param {MTX} tx
* @param {KeyRing[]} ring
* @param {SighashType} type
@@ -334,6 +336,7 @@ WorkerPool.prototype.sign = co(function* sign(tx, ring, type) {
/**
* Execute the tx input verification job (default timeout).
+ * @method
* @param {TX} tx
* @param {Number} index
* @param {Coin|Output} coin
@@ -349,6 +352,7 @@ WorkerPool.prototype.verifyInput = co(function* verifyInput(tx, index, coin, fla
/**
* Execute the tx input signing job (default timeout).
+ * @method
* @param {MTX} tx
* @param {Number} index
* @param {Coin|Output} coin
@@ -366,6 +370,7 @@ WorkerPool.prototype.signInput = co(function* signInput(tx, index, coin, ring, t
/**
* Execute the ec verify job (no timeout).
+ * @method
* @param {Buffer} msg
* @param {Buffer} sig - DER formatted.
* @param {Buffer} key
@@ -380,6 +385,7 @@ WorkerPool.prototype.ecVerify = co(function* ecVerify(msg, sig, key) {
/**
* Execute the ec signing job (no timeout).
+ * @method
* @param {Buffer} msg
* @param {Buffer} key
* @returns {Promise}
@@ -393,6 +399,7 @@ WorkerPool.prototype.ecSign = co(function* ecSign(msg, key) {
/**
* Execute the mining job (no timeout).
+ * @method
* @param {Buffer} data
* @param {Buffer} target
* @param {Number} min
@@ -408,6 +415,7 @@ WorkerPool.prototype.mine = co(function* mine(data, target, min, max) {
/**
* Execute scrypt job (no timeout).
+ * @method
* @param {Buffer} passwd
* @param {Buffer} salt
* @param {Number} N
@@ -425,7 +433,7 @@ WorkerPool.prototype.scrypt = co(function* scrypt(passwd, salt, N, r, p, len) {
/**
* Represents a worker.
- * @exports Worker
+ * @alias module:workers.Worker
* @constructor
* @param {Number?} id
*/
@@ -772,8 +780,9 @@ Worker.prototype.killJobs = function killJobs() {
};
/**
- * PendingWorker
+ * Pending Job
* @constructor
+ * @ignore
* @param {Worker} worker
* @param {Number} id
* @param {Function} resolve