diff --git a/lib/bcoin/abstractblock.js b/lib/bcoin/abstractblock.js index 5cb65ce3..fc68ee19 100644 --- a/lib/bcoin/abstractblock.js +++ b/lib/bcoin/abstractblock.js @@ -153,4 +153,8 @@ AbstractBlock.prototype.__defineGetter__('rhash', function() { return utils.revHex(this.hash('hex')); }); +/* + * Expose + */ + module.exports = AbstractBlock; diff --git a/lib/bcoin/address.js b/lib/bcoin/address.js index 5858c33b..d5e6943a 100644 --- a/lib/bcoin/address.js +++ b/lib/bcoin/address.js @@ -467,4 +467,9 @@ Address.getHash = function getHash(data) { return hash.toString('hex'); }; + +/* + * Expose + */ + module.exports = Address; diff --git a/lib/bcoin/block.js b/lib/bcoin/block.js index e11b4965..fe236ecf 100644 --- a/lib/bcoin/block.js +++ b/lib/bcoin/block.js @@ -426,7 +426,7 @@ Block.prototype.getCoinbaseHeight = function getCoinbaseHeight() { /** * Calculate the block reward. - * @returns {BN} reward + * @returns {Amount} reward */ Block.prototype.getReward = function getReward(network) { @@ -457,7 +457,7 @@ Block.prototype.getReward = function getReward(network) { /** * Get the "claimed" reward by the coinbase. - * @returns {BN} claimed + * @returns {Amount} claimed */ Block.prototype.getClaimed = function getClaimed() { @@ -469,7 +469,7 @@ Block.prototype.getClaimed = function getClaimed() { /** * Calculate block subsidy. * @param {Number} height - Reward era by height. - * @returns {BN} + * @returns {Amount} */ Block.reward = function _reward(height, network) { @@ -682,4 +682,8 @@ Block.isBlock = function isBlock(obj) { && typeof obj.toCompact === 'function'; }; +/* + * Expose + */ + module.exports = Block; diff --git a/lib/bcoin/bloom.js b/lib/bcoin/bloom.js index dd0c3e40..046079e1 100644 --- a/lib/bcoin/bloom.js +++ b/lib/bcoin/bloom.js @@ -236,4 +236,8 @@ function murmur(data, seed) { Bloom.hash = murmur; +/* + * Expose + */ + module.exports = Bloom; diff --git a/lib/bcoin/bst.js b/lib/bcoin/bst.js index 791a82d3..0d3d1d25 100644 --- a/lib/bcoin/bst.js +++ b/lib/bcoin/bst.js @@ -716,4 +716,8 @@ function clone(node) { }; } +/* + * Expose + */ + module.exports = BST; diff --git a/lib/bcoin/chain.js b/lib/bcoin/chain.js index efd82250..c79f3eff 100644 --- a/lib/bcoin/chain.js +++ b/lib/bcoin/chain.js @@ -2502,4 +2502,8 @@ Chain.prototype.checkLocks = function checkLocks(prev, tx, flags, callback) { }); }; +/* + * Expose + */ + module.exports = Chain; diff --git a/lib/bcoin/chaindb.js b/lib/bcoin/chaindb.js index 4d925ec4..cf66fc57 100644 --- a/lib/bcoin/chaindb.js +++ b/lib/bcoin/chaindb.js @@ -1464,6 +1464,12 @@ ChainDB.prototype._pruneBlock = function _pruneBlock(block, batch, callback) { }); }; +/** + * A null cache. Every method is a NOP. + * @constructor + * @param {Number} size + */ + function NullCache(size) {} NullCache.prototype.set = function set(key, value) {}; @@ -1472,4 +1478,8 @@ NullCache.prototype.get = function get(key) {}; NullCache.prototype.has = function has(key) {}; NullCache.prototype.reset = function reset() {}; +/* + * Expose + */ + module.exports = ChainDB; diff --git a/lib/bcoin/chainentry.js b/lib/bcoin/chainentry.js index d0a99806..016adf1f 100644 --- a/lib/bcoin/chainentry.js +++ b/lib/bcoin/chainentry.js @@ -487,4 +487,8 @@ ChainEntry.isChainEntry = function isChainEntry(obj) { && typeof obj.getMedianTime === 'function'; }; +/* + * Expose + */ + module.exports = ChainEntry; diff --git a/lib/bcoin/coin.js b/lib/bcoin/coin.js index 7c94c982..ced0ed9a 100644 --- a/lib/bcoin/coin.js +++ b/lib/bcoin/coin.js @@ -22,7 +22,7 @@ var assert = utils.assert; * @param {Number?} index - Output index. * @property {Number} version - Transaction version. * @property {Number} height - Transaction height (-1 if unconfirmed). - * @property {BN} value - Output value in satoshis. + * @property {Amount} value - Output value in satoshis. * @property {Script} script - Output script. * @property {Boolean} coinbase - Whether the containing * transaction is a coinbase. @@ -280,4 +280,8 @@ Coin.isCoin = function isCoin(obj) { && typeof obj.getConfirmations === 'function'; }; +/* + * Expose + */ + module.exports = Coin; diff --git a/lib/bcoin/coins.js b/lib/bcoin/coins.js index 9e161cd3..4f55b42e 100644 --- a/lib/bcoin/coins.js +++ b/lib/bcoin/coins.js @@ -273,4 +273,8 @@ Coins.fromRaw = function fromRaw(buf, hash) { return new Coins(Coins.parseRaw(buf), hash); }; +/* + * Expose + */ + module.exports = Coins; diff --git a/lib/bcoin/coinview.js b/lib/bcoin/coinview.js index e57e21d6..76507cfd 100644 --- a/lib/bcoin/coinview.js +++ b/lib/bcoin/coinview.js @@ -161,4 +161,8 @@ CoinView.prototype.toArray = function toArray() { return out; }; +/* + * Expose + */ + module.exports = CoinView; diff --git a/lib/bcoin/compactblock.js b/lib/bcoin/compactblock.js index 25ae3fda..e1eb44b3 100644 --- a/lib/bcoin/compactblock.js +++ b/lib/bcoin/compactblock.js @@ -116,4 +116,8 @@ CompactBlock.isCompactBlock = function isCompactBlock(obj) { return obj && typeof obj.toBlock === 'function'; }; +/* + * Expose + */ + module.exports = CompactBlock; diff --git a/lib/bcoin/errors.js b/lib/bcoin/errors.js index f6080757..adaac1ae 100644 --- a/lib/bcoin/errors.js +++ b/lib/bcoin/errors.js @@ -109,5 +109,9 @@ function ScriptError(code, op, ip) { utils.inherits(ScriptError, Error); +/* + * Expose + */ + exports.VerifyError = VerifyError; exports.ScriptError = ScriptError; diff --git a/lib/bcoin/fullnode.js b/lib/bcoin/fullnode.js index 618cd654..342dbeb4 100644 --- a/lib/bcoin/fullnode.js +++ b/lib/bcoin/fullnode.js @@ -601,4 +601,8 @@ Fullnode.prototype.getConfidence = function getConfidence(tx, callback) { return this.mempool.getConfidence(tx, callback); }; +/* + * Expose + */ + module.exports = Fullnode; diff --git a/lib/bcoin/headers.js b/lib/bcoin/headers.js index 840ac6c1..b60548ae 100644 --- a/lib/bcoin/headers.js +++ b/lib/bcoin/headers.js @@ -154,4 +154,8 @@ Headers.isHeaders = function isHeaders(obj) { && typeof obj.toBlock !== 'function'; }; +/* + * Expose + */ + module.exports = Headers; diff --git a/lib/bcoin/http/base.js b/lib/bcoin/http/base.js index 7af4228d..cda1d83b 100644 --- a/lib/bcoin/http/base.js +++ b/lib/bcoin/http/base.js @@ -506,4 +506,8 @@ function unescape(str) { } } +/* + * Expose + */ + module.exports = HTTPBase; diff --git a/lib/bcoin/http/client.js b/lib/bcoin/http/client.js index b8b9dcce..a38abfba 100644 --- a/lib/bcoin/http/client.js +++ b/lib/bcoin/http/client.js @@ -769,7 +769,7 @@ HTTPClient.prototype.broadcast = function broadcast(tx, callback) { * @param {WalletID} id * @param {Object} options * @param {Base58Address} options.address - * @param {BN} options.value + * @param {Amount} options.value * @param {Function} callback - Returns [Error, {@link TX}]. */ @@ -913,4 +913,8 @@ HTTPClient.prototype.getInfo = function getInfo(callback) { }); }; +/* + * Expose + */ + module.exports = HTTPClient; diff --git a/lib/bcoin/http/provider.js b/lib/bcoin/http/provider.js index d388f773..c1a42a3e 100644 --- a/lib/bcoin/http/provider.js +++ b/lib/bcoin/http/provider.js @@ -202,4 +202,8 @@ HTTPProvider.prototype.zap = function zap(now, age, callback) { return this.client.zapWallet(this.id, now, age, callback); }; +/* + * Expose + */ + module.exports = HTTPProvider; diff --git a/lib/bcoin/http/request.js b/lib/bcoin/http/request.js index bd6b9b01..add19586 100644 --- a/lib/bcoin/http/request.js +++ b/lib/bcoin/http/request.js @@ -336,4 +336,8 @@ ReqStream.prototype.destroy = function destroy() { } }; +/* + * Expose + */ + module.exports = request; diff --git a/lib/bcoin/http/server.js b/lib/bcoin/http/server.js index 153761ef..74fdfb39 100644 --- a/lib/bcoin/http/server.js +++ b/lib/bcoin/http/server.js @@ -785,4 +785,8 @@ HTTPServer.prototype.listen = function listen(port, host, callback) { }); }; +/* + * Expose + */ + module.exports = HTTPServer; diff --git a/lib/bcoin/input.js b/lib/bcoin/input.js index e4ab3487..0c0f5da8 100644 --- a/lib/bcoin/input.js +++ b/lib/bcoin/input.js @@ -429,4 +429,8 @@ Input.isInput = function isInput(obj) { && typeof obj.getAddress === 'function'; }; +/* + * Expose + */ + module.exports = Input; diff --git a/lib/bcoin/keypair.js b/lib/bcoin/keypair.js index e50dbfc6..d5ac5d4f 100644 --- a/lib/bcoin/keypair.js +++ b/lib/bcoin/keypair.js @@ -276,4 +276,8 @@ KeyPair.fromJSON = function fromJSON(json, passphrase) { return new KeyPair(KeyPair.parseJSON(json, passphrase)); }; +/* + * Expose + */ + module.exports = KeyPair; diff --git a/lib/bcoin/keyring.js b/lib/bcoin/keyring.js index 28da7658..0b370f8f 100644 --- a/lib/bcoin/keyring.js +++ b/lib/bcoin/keyring.js @@ -659,4 +659,8 @@ KeyRing.fromJSON = function fromJSON(json, passphrase) { return w; }; +/* + * Expose + */ + module.exports = KeyRing; diff --git a/lib/bcoin/ldb.js b/lib/bcoin/ldb.js index 34b88079..eccfe318 100644 --- a/lib/bcoin/ldb.js +++ b/lib/bcoin/ldb.js @@ -127,7 +127,13 @@ function repair(options, callback) { backend.repair(file, callback); } -ldb.destroy = destroy; -ldb.repair = repair; +/* + * Expose + */ -module.exports = ldb; +exports = ldb; + +exports.destroy = destroy; +exports.repair = repair; + +module.exports = exports; diff --git a/lib/bcoin/locker.js b/lib/bcoin/locker.js index fb4cb437..5f76b5b4 100644 --- a/lib/bcoin/locker.js +++ b/lib/bcoin/locker.js @@ -164,4 +164,8 @@ Locker.prototype.onFlush = function onFlush(callback) { this.once('flush', callback); }; +/* + * Expose + */ + module.exports = Locker; diff --git a/lib/bcoin/lowlevelup.js b/lib/bcoin/lowlevelup.js index 0ff3eda5..c4d70b7c 100644 --- a/lib/bcoin/lowlevelup.js +++ b/lib/bcoin/lowlevelup.js @@ -338,4 +338,8 @@ LowlevelUp.prototype.lookup = function lookup(options, callback) { }); }; +/* + * Expose + */ + module.exports = LowlevelUp; diff --git a/lib/bcoin/lru.js b/lib/bcoin/lru.js index f7e5c20e..05f0973e 100644 --- a/lib/bcoin/lru.js +++ b/lib/bcoin/lru.js @@ -305,4 +305,8 @@ LRU.prototype.toArray = function toArray() { return items; }; +/* + * Expose + */ + module.exports = LRU; diff --git a/lib/bcoin/mempool.js b/lib/bcoin/mempool.js index 0356566e..17cfd154 100644 --- a/lib/bcoin/mempool.js +++ b/lib/bcoin/mempool.js @@ -32,6 +32,7 @@ var DUMMY = new Buffer([0]); * @param {String?} options.db - Database backend (`"memory"` by default). * @param {Boolean?} options.limitFree * @param {Number?} options.limitFreeRelay + * @param {Number?} options.maxSize - Max pool size (default ~300mb). * @param {Boolean?} options.relayPriority * @param {Boolean?} options.requireStandard * @param {Boolean?} options.rejectAbsurdFees @@ -43,6 +44,12 @@ var DUMMY = new Buffer([0]); * @property {Locker} locker * @property {Number} freeCount * @property {Number} lastTime + * @property {Number} maxSize + * @property {Boolean} blockSinceBump + * @property {Number} lastFeeUpdate + * @property {Rate} minFeeRate + * @property {Rate} minReasonableFee + * @property {Rate} minRelayFee * @emits Mempool#open * @emits Mempool#error * @emits Mempool#tx @@ -92,9 +99,9 @@ function Mempool(options) { this.accurateMemory = !!this.options.accurateMemory; this.maxSize = options.maxSize || constants.mempool.MAX_MEMPOOL_SIZE; - this.minFeeRate = 0; this.blockSinceBump = false; this.lastFeeUpdate = utils.now(); + this.minFeeRate = 0; this.minReasonableFee = constants.tx.MIN_RELAY; this.minRelayFee = constants.tx.MIN_RELAY; @@ -861,7 +868,7 @@ Mempool.prototype.removeUnchecked = function removeUnchecked(entry, limit, callb /** * Calculate and update the minimum rolling fee rate. - * @returns {Number} Rate. + * @returns {Rate} Rate. */ Mempool.prototype.getMinRate = function getMinRate() { @@ -1789,20 +1796,20 @@ Mempool.prototype.getSize = function getSize() { * @param {Object} options * @param {TX} options.tx - Transaction in mempool. * @param {Number} options.height - Entry height. - * @param {BN} options.priority - Entry priority. + * @param {Number} options.priority - Entry priority. * @param {Number} options.ts - Entry time. - * @param {BN} options.chainValue - Value of on-chain coins. + * @param {Amount} options.chainValue - Value of on-chain coins. * @param {Number} options.count - Number of descendants (includes tx). * @param {Number} options.size - TX and descendant modified size. - * @param {BN} options.fees - TX and descendant delta-applied fees. + * @param {Amount} options.fees - TX and descendant delta-applied fees. * @property {TX} tx * @property {Number} height - * @property {BN} priority + * @property {Number} priority * @property {Number} ts - * @property {BN} chainValue + * @property {Amount} chainValue * @property {Number} count * @property {Number} size - * @property {BN} fees + * @property {Amount} fees */ function MempoolEntry(options) { @@ -1890,7 +1897,7 @@ MempoolEntry.fromRaw = function fromRaw(data) { * the entry height delta, modified size, * and chain value. * @param {Number} height - * @returns {BN} Priority. + * @returns {Number} Priority. */ MempoolEntry.prototype.getPriority = function getPriority(height) { @@ -1953,4 +1960,8 @@ function mallocUsage(alloc) { Mempool.MempoolEntry = MempoolEntry; +/* + * Expose + */ + module.exports = Mempool; diff --git a/lib/bcoin/merkleblock.js b/lib/bcoin/merkleblock.js index 5a85046c..c7db120b 100644 --- a/lib/bcoin/merkleblock.js +++ b/lib/bcoin/merkleblock.js @@ -402,4 +402,8 @@ MerkleBlock.isMerkleBlock = function isMerkleBlock(obj) { && typeof obj.verifyPartial === 'function'; }; +/* + * Expose + */ + module.exports = MerkleBlock; diff --git a/lib/bcoin/miner.js b/lib/bcoin/miner.js index 6ccf06db..3a78c942 100644 --- a/lib/bcoin/miner.js +++ b/lib/bcoin/miner.js @@ -674,4 +674,8 @@ function rcmp(a, b) { Miner.MinerBlock = MinerBlock; +/* + * Expose + */ + module.exports = Miner; diff --git a/lib/bcoin/mtx.js b/lib/bcoin/mtx.js index fe8ddce1..5758f8cf 100644 --- a/lib/bcoin/mtx.js +++ b/lib/bcoin/mtx.js @@ -784,7 +784,7 @@ MTX.prototype.sign = function sign(index, addr, type) { * tx.addOutput(receivingWallet, utils.satoshi('0.1')); * @param {Wallet|Address|Object} obj - Wallet, Address, * or options (see {@link Script.createOutputScript} for options). - * @param {BN?} value - Only needs to be present for non-options. + * @param {Amount?} value - Only needs to be present for non-options. */ MTX.prototype.addOutput = function addOutput(address, value) { @@ -1053,7 +1053,8 @@ MTX.prototype.maxSize = function maxSize(options, force) { * @param {Boolean} options.confirmed - Select only confirmed coins. * @param {Boolean} options.free - Do not apply a fee if the * transaction priority is high enough to be considered free. - * @param {BN?} options.fee - Use a hard fee rather than calculating one. + * @param {Amount?} options.fee - Use a hard fee rather than calculating one. + * @param {Rate?} options.rate - Rate used for fee calculation. * @param {Number|Boolean} options.subtractFee - Whether to subtract the * fee from * existing outputs rather than adding more inputs. * @returns {CoinSelection} @@ -1423,4 +1424,8 @@ MTX.isMTX = function isMTX(obj) { && typeof obj.scriptInput === 'function'; }; +/* + * Expose + */ + module.exports = MTX; diff --git a/lib/bcoin/network.js b/lib/bcoin/network.js index 66f510c8..090ebe4c 100644 --- a/lib/bcoin/network.js +++ b/lib/bcoin/network.js @@ -15,8 +15,8 @@ var network = require('./protocol/network'); * @constructor * @param {Object|String} options - See {@link module:network}. * @property {Number} height - * @property {Number} feeRate - * @property {Number} minRelay + * @property {Rate} feeRate + * @property {Rate} minRelay */ function Network(options) { @@ -66,7 +66,7 @@ Network.prototype.updateHeight = function updateHeight(height) { /** * Update the estimated fee rate of the network. - * @param {Number} rate + * @param {Rate} rate */ Network.prototype.updateRate = function updateRate(rate) { @@ -75,7 +75,7 @@ Network.prototype.updateRate = function updateRate(rate) { /** * Update the minimum relay rate (reject rate) of the network. - * @param {Number} rate + * @param {Rate} rate */ Network.prototype.updateMinRelay = function updateMinRelay(rate) { @@ -85,7 +85,7 @@ Network.prototype.updateMinRelay = function updateMinRelay(rate) { /** * Calculate the minimum relay rate. If the network is * inactive (height=-1), return the default minimum relay. - * @return {Number} Rate + * @return {Rate} Rate */ Network.prototype.getMinRelay = function getMinRelay() { @@ -98,7 +98,7 @@ Network.prototype.getMinRelay = function getMinRelay() { /** * Calculate the normal relay rate. If the network is * inactive (height=-1), return the default rate. - * @return {Number} Rate + * @return {Rate} Rate */ Network.prototype.getRate = function getRate() { @@ -161,4 +161,8 @@ Network.prototype.inspect = function inspect() { return ''; }; +/* + * Expose + */ + module.exports = Network; diff --git a/lib/bcoin/node.js b/lib/bcoin/node.js index e2ea7f0b..2b795288 100644 --- a/lib/bcoin/node.js +++ b/lib/bcoin/node.js @@ -39,4 +39,8 @@ function Node(options) { utils.inherits(Node, EventEmitter); +/* + * Expose + */ + module.exports = Node; diff --git a/lib/bcoin/output.js b/lib/bcoin/output.js index 52e2200f..b9512b9e 100644 --- a/lib/bcoin/output.js +++ b/lib/bcoin/output.js @@ -18,7 +18,7 @@ var Framer = bcoin.protocol.framer; * @constructor * @param {NakedOutput} options * @param {Boolean?} mutable - * @property {BN} value - Value in satoshis. + * @property {Amount} value - Value in satoshis. * @property {Script} script * @property {String} type - Script type. * @property {String?} address - Input address. @@ -151,8 +151,8 @@ Output.prototype.toJSON = function toJSON() { /** * Calculate the dust threshold for this * output, based on serialize size and rate. - * @param {Number?} rate - * @returns {BN} + * @param {Rate?} rate + * @returns {Amount} */ Output.prototype.getDustThreshold = function getDustThreshold(rate) { @@ -172,7 +172,7 @@ Output.prototype.getDustThreshold = function getDustThreshold(rate) { /** * Test whether the output should be considered dust. - * @param {Number?} rate + * @param {Rate?} rate * @returns {Boolean} */ @@ -259,4 +259,8 @@ Output.isOutput = function isOutput(obj) { && typeof obj.getAddress === 'function'; }; +/* + * Expose + */ + module.exports = Output; diff --git a/lib/bcoin/peer.js b/lib/bcoin/peer.js index 7d63fa1c..0d22ce41 100644 --- a/lib/bcoin/peer.js +++ b/lib/bcoin/peer.js @@ -1445,4 +1445,8 @@ Peer.prototype.sendReject = function sendReject(obj, code, reason, score) { return this.pool.reject(this, obj, code, reason, score); }; +/* + * Expose + */ + module.exports = Peer; diff --git a/lib/bcoin/pool.js b/lib/bcoin/pool.js index 86412658..4db17635 100644 --- a/lib/bcoin/pool.js +++ b/lib/bcoin/pool.js @@ -2321,4 +2321,8 @@ LoadRequest.prototype.finish = function finish() { } }; +/* + * Expose + */ + module.exports = Pool; diff --git a/lib/bcoin/protocol/constants.js b/lib/bcoin/protocol/constants.js index 426ab9fb..54e400d9 100644 --- a/lib/bcoin/protocol/constants.js +++ b/lib/bcoin/protocol/constants.js @@ -301,7 +301,7 @@ exports.opcodesByVal = utils.revMap(exports.opcodes); /** * One bitcoin in satoshis. - * @const {BN} + * @const {Amount} * @default */ @@ -309,7 +309,7 @@ exports.COIN = 100000000; /** * One bitcoin / 100. - * @const {BN} + * @const {Amount} * @default */ @@ -317,7 +317,7 @@ exports.CENT = 1000000; /** * Maximum amount of money in satoshis (1btc * 21million) - * @const {BN} + * @const {Amount} * @default */ diff --git a/lib/bcoin/protocol/framer.js b/lib/bcoin/protocol/framer.js index 901f8ea2..9b50770b 100644 --- a/lib/bcoin/protocol/framer.js +++ b/lib/bcoin/protocol/framer.js @@ -1514,4 +1514,8 @@ Framer.tx.cost = function txCost(tx) { return base * (scale - 1) + sizes.size; }; +/* + * Expose + */ + module.exports = Framer; diff --git a/lib/bcoin/protocol/network.js b/lib/bcoin/protocol/network.js index d435876d..b85369e8 100644 --- a/lib/bcoin/protocol/network.js +++ b/lib/bcoin/protocol/network.js @@ -416,7 +416,7 @@ main.rpcPort = 8332; /** * Default min relay rate (the rate for mempoolRejectFee). - * @const {Number} + * @const {Rate} * @default */ @@ -424,7 +424,7 @@ main.minRelay = 10000; /** * Default normal relay rate. - * @const {Number} + * @const {Rate} * @default */ @@ -432,7 +432,7 @@ main.feeRate = 40000; /** * Default min rate. - * @const {Number} + * @const {Rate} * @default */ @@ -440,7 +440,7 @@ main.minRate = 10000; /** * Default max rate. - * @const {Number} + * @const {Rate} * @default */ diff --git a/lib/bcoin/protocol/parser.js b/lib/bcoin/protocol/parser.js index 90505bfd..c30927e7 100644 --- a/lib/bcoin/protocol/parser.js +++ b/lib/bcoin/protocol/parser.js @@ -1227,4 +1227,8 @@ Parser.parseAlert = function parseAlert(p) { }; }; +/* + * Expose + */ + module.exports = Parser; diff --git a/lib/bcoin/reader.js b/lib/bcoin/reader.js index 8de37004..25cdc9dd 100644 --- a/lib/bcoin/reader.js +++ b/lib/bcoin/reader.js @@ -545,4 +545,8 @@ BufferReader.prototype.verifyChecksum = function verifyChecksum() { return checksum; }; +/* + * Expose + */ + module.exports = BufferReader; diff --git a/lib/bcoin/script.js b/lib/bcoin/script.js index 730dff9f..bdbea5b1 100644 --- a/lib/bcoin/script.js +++ b/lib/bcoin/script.js @@ -4205,7 +4205,14 @@ Script.isScript = function isScript(obj) { && typeof obj.getSubscript === 'function'; }; -Script.Witness = Witness; -Script.Stack = Stack; +/* + * Expose + */ -module.exports = Script; +exports = Script; + +exports.Script = Script; +exports.Witness = Witness; +exports.Stack = Stack; + +module.exports = exports; diff --git a/lib/bcoin/spvnode.js b/lib/bcoin/spvnode.js index 43e49d38..75ab8b04 100644 --- a/lib/bcoin/spvnode.js +++ b/lib/bcoin/spvnode.js @@ -296,4 +296,8 @@ SPVNode.prototype.getWallet = function getWallet(id, passphrase, callback) { return this.walletdb.get(id, passphrase, callback); }; +/* + * Expose + */ + module.exports = SPVNode; diff --git a/lib/bcoin/timedata.js b/lib/bcoin/timedata.js index 3514f714..fae2ce13 100644 --- a/lib/bcoin/timedata.js +++ b/lib/bcoin/timedata.js @@ -103,8 +103,16 @@ TimeData.prototype.now = function now() { return utils.now() + this.offset; }; +/* + * Helpers + */ + function compare(a, b) { return a - b; } +/* + * Expose + */ + module.exports = TimeData; diff --git a/lib/bcoin/tx.js b/lib/bcoin/tx.js index f64b9b03..e0ec171c 100644 --- a/lib/bcoin/tx.js +++ b/lib/bcoin/tx.js @@ -660,7 +660,7 @@ TX.prototype.isCoinbase = function isCoinbase() { /** * Calculate the fee for the transaction. - * @returns {BN} fee (zero if not all coins are available). + * @returns {Amount} fee (zero if not all coins are available). */ TX.prototype.getFee = function getFee() { @@ -672,7 +672,7 @@ TX.prototype.getFee = function getFee() { /** * Calculate the total input value. - * @returns {BN} value + * @returns {Amount} value */ TX.prototype.getInputValue = function getInputValue() { @@ -696,7 +696,7 @@ TX.prototype.getInputValue = function getInputValue() { /** * Calculate the total output value. - * @returns {BN} value + * @returns {Amount} value */ TX.prototype.getOutputValue = function getOutputValue() { @@ -1411,7 +1411,7 @@ TX.prototype.getModifiedSize = function getModifiedSize(size) { * @param {Number?} size - Size to calculate priority * based on. If not present, modified size will be * calculated and used. - * @returns {BN} priority + * @returns {Number} priority */ TX.prototype.getPriority = function getPriority(height, size) { @@ -1485,8 +1485,8 @@ TX.prototype.isFree = function isFree(height, size) { * to be relayable (not the constant min relay fee). * @param {Number?} size - If not present, max size * estimation will be calculated and used. - * @param {Number?} rate - Rate of satoshi per kB. - * @returns {BN} fee + * @param {Rate?} rate - Rate of satoshi per kB. + * @returns {Amount} fee */ TX.prototype.getMinFee = function getMinFee(size, rate) { @@ -1499,8 +1499,8 @@ TX.prototype.getMinFee = function getMinFee(size, rate) { /** * Calculate minimum fee based on rate and size. * @param {Number?} size - * @param {Number?} rate - Rate of satoshi per kB. - * @returns {BN} fee + * @param {Rate?} rate - Rate of satoshi per kB. + * @returns {Amount} fee */ TX.getMinFee = function getMinFee(size, rate) { @@ -1523,8 +1523,8 @@ TX.getMinFee = function getMinFee(size, rate) { * when taking into account size. * @param {Number?} size - If not present, max size * estimation will be calculated and used. - * @param {Number?} rate - Rate of satoshi per kB. - * @returns {BN} fee + * @param {Rate?} rate - Rate of satoshi per kB. + * @returns {Amount} fee */ TX.prototype.getMaxFee = function getMaxFee(size, rate) { @@ -1917,4 +1917,9 @@ TX.isTX = function isTX(obj) { && typeof obj.getVirtualSize === 'function'; }; +/* + * Expose + */ + + module.exports = TX; diff --git a/lib/bcoin/txdb.js b/lib/bcoin/txdb.js index 8cb5a6ec..e10694a1 100644 --- a/lib/bcoin/txdb.js +++ b/lib/bcoin/txdb.js @@ -1735,4 +1735,8 @@ TXDB.prototype.zap = function zap(address, now, age, callback, force) { }); }; +/* + * Expose + */ + module.exports = TXDB; diff --git a/lib/bcoin/types.js b/lib/bcoin/types.js index 2f39088d..17382deb 100644 --- a/lib/bcoin/types.js +++ b/lib/bcoin/types.js @@ -58,7 +58,7 @@ /** * @typedef {Object} ParsedURI * @property {Base58Address} address - * @property {BN?} amount? - Amount in satoshis. + * @property {Amount?} amount? - Amount in satoshis. * @property {String?} label * @property {String?} message * @property {String?} request - Payment request URL. @@ -105,9 +105,25 @@ /** * Wallet balance. * @typedef {Object} Balance - * @property {BN} confirmed - * @property {BN} unconfirmed - * @property {BN} total + * @property {Amount} confirmed + * @property {Amount} unconfirmed + * @property {Amount} total + * @global + */ + +/** + * A satoshi amount. This is technically a + * JS double float, but it is regularly + * enforced to be less than 53 bits and + * less than MAX_MONEY regularly in + * various functions. + * @typedef {Number} Amount + * @global + */ + +/** + * Rate of satoshis per kB. + * @typedef {Amount} Rate * @global */ @@ -143,9 +159,9 @@ /** * @typedef {Object} CoinSelection * @property {Coin[]?} chosen - Selected coins. - * @property {BN} change - Amount of change to add. - * @property {BN} fee - Estimated fee. - * @property {BN} total - Total value. + * @property {Amount} change - Amount of change to add. + * @property {Amount} fee - Estimated fee. + * @property {Amount} total - Total value. * @global */ @@ -202,7 +218,7 @@ * @typedef {Object} NakedCoin * @property {Number} version - Transaction version. * @property {Number} height - Transaction height (-1 if unconfirmed). - * @property {BN} value - Output value in satoshis. + * @property {Amount} value - Output value in satoshis. * @property {Script} script - Output script. * @property {Boolean} coinbase - Whether the containing * transaction is a coinbase. @@ -295,7 +311,7 @@ /** * @typedef {Object} NakedOutput - * @property {BN} value - Value in satoshis. + * @property {Amount} value - Value in satoshis. * @property {NakedScript} script - Output script. * @global */ @@ -304,7 +320,7 @@ * @typedef {Object} NakedCoin * @property {Number} version - Transaction version. * @property {Number} height - Transaction height (-1 if unconfirmed). - * @property {BN} value - Output value in satoshis. + * @property {Amount} value - Output value in satoshis. * @property {Script} script - Output script. * @property {Boolean} coinbase - Whether the containing * transaction is a coinbase. diff --git a/lib/bcoin/uri.js b/lib/bcoin/uri.js index 61edafe0..945f6551 100644 --- a/lib/bcoin/uri.js +++ b/lib/bcoin/uri.js @@ -52,7 +52,7 @@ exports.validate = function validate(uri) { /** * Encode data as a bitcoin URI. * @param {ParsedURI|Base58Address} data/address - * @param {BN?} amount + * @param {Amount?} amount * @returns {String} URI * @throws when no address provided */ diff --git a/lib/bcoin/utils.js b/lib/bcoin/utils.js index 22473117..cb47a254 100644 --- a/lib/bcoin/utils.js +++ b/lib/bcoin/utils.js @@ -651,7 +651,7 @@ utils.assert.fatal = function fatal(value, message) { * Safely convert satoshis to a BTC string. * This function explicitly avoids any * floating point arithmetic. - * @param {Number} value - Satoshis. + * @param {Amount} value - Satoshis. * @returns {String} BTC string. */ @@ -701,7 +701,7 @@ utils.btc = function btc(value) { * extra validation to ensure the resulting * Number will be 53 bits or less. * @param {String} value - BTC - * @returns {Number} Satoshis. + * @returns {Amount} Satoshis. * @throws on parse error */ @@ -777,7 +777,7 @@ utils.isFloat = function isFloat(value) { /** * Test whether an object is a finite number and int. - * @param {BN?} value + * @param {Number?} value * @returns {Boolean} */ @@ -1272,16 +1272,14 @@ utils.time = function time(date) { /** * UINT32_MAX - * @type BN - * @const + * @const {BN} */ utils.U32 = new bn(0xffffffff); /** * UINT64_MAX - * @type BN - * @const + * @const {BN} */ utils.U64 = new bn('ffffffffffffffff', 'hex'); @@ -1640,17 +1638,15 @@ utils.writeU64NBE = function writeU64NBE(dst, num, off) { /** * Max safe integer (53 bits). - * @type Number - * @const + * @const {Number} */ utils.MAX_SAFE_INTEGER = 0x1fffffffffffff; /** * Max 52 bit integer (safe for additions). - * (MAX_SAFE_INTEGER - 1) / 2 - * @type Number - * @const + * `(MAX_SAFE_INTEGER - 1) / 2` + * @const {Number} */ utils.MAX_SAFE_ADDITION = 0xfffffffffffff; diff --git a/lib/bcoin/wallet.js b/lib/bcoin/wallet.js index 55294b71..35a07517 100644 --- a/lib/bcoin/wallet.js +++ b/lib/bcoin/wallet.js @@ -679,10 +679,11 @@ Wallet.prototype.ownOutput = function ownOutput(tx, index) { * @param {Boolean} options.accurate - Whether to use "accurate" * fee calculatation rather than rounding to the nearest kilobyte. * See {@link TX#getMinFee} vs. {@link TX#getMaxFee}. + * @param {Rate} options.rate - Rate used for fee calculation. * @param {Boolean} options.confirmed - Select only confirmed coins. * @param {Boolean} options.free - Do not apply a fee if the * transaction priority is high enough to be considered free. - * @param {BN?} options.fee - Use a hard fee rather than calculating one. + * @param {Amount?} options.fee - Use a hard fee rather than calculating one. * @param {Number|Boolean} options.subtractFee - Whether to subtract the * fee from existing outputs rather than adding more inputs. */ @@ -1778,4 +1779,8 @@ Wallet.isWallet = function isWallet(obj) { && obj.deriveAddress === 'function'; }; +/* + * Expose + */ + module.exports = Wallet; diff --git a/lib/bcoin/walletdb.js b/lib/bcoin/walletdb.js index 874dce51..08b8a409 100644 --- a/lib/bcoin/walletdb.js +++ b/lib/bcoin/walletdb.js @@ -1169,6 +1169,12 @@ Provider.prototype.zap = function zap(now, age, callback) { return this.db.zapWallet(this.id, now, age, callback); }; -WalletDB.Provider = Provider; +/* + * Expose + */ -module.exports = WalletDB; +exports = WalletDB; + +exports.Provider = Provider; + +module.exports = exports; diff --git a/lib/bcoin/workers.js b/lib/bcoin/workers.js index 14405899..84c793c7 100644 --- a/lib/bcoin/workers.js +++ b/lib/bcoin/workers.js @@ -882,10 +882,17 @@ function getCores() { return os.cpus().length; } -Workers.Worker = Worker; -Workers.Master = Master; -Workers.Framer = Framer; -Workers.Parser = Parser; -Workers.listen = Master.listen; +/* + * Expose + */ -module.exports = Workers; +exports = Workers; + +exports.Workers = Workers; +exports.Worker = Worker; +exports.Master = Master; +exports.Framer = Framer; +exports.Parser = Parser; +exports.listen = Master.listen; + +module.exports = exports; diff --git a/lib/bcoin/writer.js b/lib/bcoin/writer.js index 22284658..05b552c8 100644 --- a/lib/bcoin/writer.js +++ b/lib/bcoin/writer.js @@ -350,4 +350,8 @@ BufferWriter.prototype.fill = function fill(value, size) { this.data.push(['bytes', buf]); }; +/* + * Expose + */ + module.exports = BufferWriter;