From 61699cca3a675313767b65cacfaf46f5bb931e78 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 19 Dec 2015 15:43:28 -0800 Subject: [PATCH] style: function names. --- lib/bcoin/chain.js | 2 +- lib/bcoin/hd.js | 34 +++++++++++++++++----------------- lib/bcoin/protocol/network.js | 2 +- lib/bcoin/script.js | 10 +++++----- lib/bcoin/utils.js | 20 ++++++++++---------- lib/bcoin/wallet.js | 4 ++-- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/lib/bcoin/chain.js b/lib/bcoin/chain.js index 058121ad..e394d953 100644 --- a/lib/bcoin/chain.js +++ b/lib/bcoin/chain.js @@ -537,7 +537,7 @@ Chain.prototype.getStartHeight = function getStartHeight() { return this.index.heights[this.index.heights.length - 1]; }; -Chain.prototype.locatorHashes = function(start) { +Chain.prototype.locatorHashes = function locatorHashes(start) { var chain = this.index.hashes; var hashes = []; var top = chain.length - 1; diff --git a/lib/bcoin/hd.js b/lib/bcoin/hd.js index 753c7390..9fc60aca 100644 --- a/lib/bcoin/hd.js +++ b/lib/bcoin/hd.js @@ -83,21 +83,21 @@ function HDSeed(options) { this.seed = this.createSeed(options.passphrase); } -HDSeed.create = function(options) { +HDSeed.create = function create(options) { var obj = new HDSeed(options); return obj.seed || obj; }; -HDSeed.prototype.createSeed = function(passphrase) { +HDSeed.prototype.createSeed = function createSeed(passphrase) { this.passphrase = passphrase || ''; return pbkdf2(this.mnemonic, 'mnemonic' + passphrase, 2048, 64); }; -HDSeed._entropy = function(size) { +HDSeed._entropy = function _entropy(size) { return randomBytes(size); }; -HDSeed._mnemonic = function(entropy) { +HDSeed._mnemonic = function _mnemonic(entropy) { var bin = ''; var mnemonic = []; var i, wi; @@ -161,7 +161,7 @@ function HDPrivateKey(options) { this._build(data); } -HDPrivateKey.prototype._normalize = function(data, version) { +HDPrivateKey.prototype._normalize = function _normalize(data, version) { data.version = version || network.prefixes.xprivkey; data.privateKey = data.privateKey || data.priv; data.publicKey = data.publicKey || data.pub; @@ -223,7 +223,7 @@ HDPrivateKey.prototype._normalize = function(data, version) { return data; }; -HDPrivateKey.prototype._seed = function(seed) { +HDPrivateKey.prototype._seed = function _seed(seed) { if (seed instanceof bcoin.hd.seed) seed = seed.seed; @@ -248,7 +248,7 @@ HDPrivateKey.prototype._seed = function(seed) { }; }; -HDPrivateKey.prototype._unbuild = function(xkey) { +HDPrivateKey.prototype._unbuild = function _unbuild(xkey) { var raw = utils.fromBase58(xkey); var data = {}; var off = 0; @@ -277,7 +277,7 @@ HDPrivateKey.prototype._unbuild = function(xkey) { return data; }; -HDPrivateKey.prototype._build = function(data) { +HDPrivateKey.prototype._build = function _build(data) { var sequence = []; var off = 0; var checksum, xprivkey, pair, privateKey, publicKey, size, fingerPrint; @@ -326,7 +326,7 @@ HDPrivateKey.prototype._build = function(data) { this.pair = bcoin.ecdsa.keyPair({ priv: this.privateKey }); }; -HDPrivateKey.prototype.derive = function(index, hardened) { +HDPrivateKey.prototype.derive = function derive(index, hardened) { var data, hash, leftPart, chainCode, privateKey; if (typeof index === 'string') @@ -359,7 +359,7 @@ HDPrivateKey.prototype.derive = function(index, hardened) { }; // https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki -HDPrivateKey._getIndexes = function(path) { +HDPrivateKey._getIndexes = function _getIndexes(path) { var steps = path.split('/'); var root = steps.shift(); var indexes = []; @@ -391,7 +391,7 @@ HDPrivateKey._getIndexes = function(path) { return indexes; }; -HDPrivateKey.isValidPath = function(path, hardened) { +HDPrivateKey.isValidPath = function isValidPath(path, hardened) { if (typeof path === 'string') { var indexes = HDPrivateKey._getIndexes(path); return indexes !== null && indexes.every(HDPrivateKey.isValidPath); @@ -407,7 +407,7 @@ HDPrivateKey.isValidPath = function(path, hardened) { return false; }; -HDPrivateKey.prototype.deriveString = function(path) { +HDPrivateKey.prototype.deriveString = function deriveString(path) { if (!HDPrivateKey.isValidPath(path)) throw new Error('invalid path'); @@ -447,7 +447,7 @@ function HDPublicKey(options) { HDPublicKey.prototype._normalize = HDPrivateKey.prototype._normalize; -HDPublicKey.prototype._unbuild = function(xkey) { +HDPublicKey.prototype._unbuild = function _unbuild(xkey) { var raw = utils.fromBase58(xkey); var data = {}; var off = 0; @@ -475,7 +475,7 @@ HDPublicKey.prototype._unbuild = function(xkey) { return data; }; -HDPublicKey.prototype._build = function(data) { +HDPublicKey.prototype._build = function _build(data) { var sequence = []; var off = 0; var checksum, xpubkey, publicKey, size, fingerPrint; @@ -522,7 +522,7 @@ HDPublicKey.prototype._build = function(data) { this.pair = bcoin.ecdsa.keyPair({ pub: this.publicKey }); }; -HDPublicKey.prototype.derive = function(index, hardened) { +HDPublicKey.prototype.derive = function derive(index, hardened) { var data, hash, leftPart, chainCode, pair, pubkeyPoint, publicKey; if (typeof index === 'string') @@ -554,7 +554,7 @@ HDPublicKey.prototype.derive = function(index, hardened) { }); }; -HDPublicKey.isValidPath = function(arg) { +HDPublicKey.isValidPath = function isValidPath(arg) { if (typeof arg === 'string') { var indexes = HDPrivateKey._getIndexes(arg); return indexes !== null && indexes.every(HDPublicKey.isValidPath); @@ -566,7 +566,7 @@ HDPublicKey.isValidPath = function(arg) { return false; }; -HDPublicKey.prototype.deriveString = function(path) { +HDPublicKey.prototype.deriveString = function deriveString(path) { if (~path.indexOf('\'')) throw new Error('cannot derive hardened'); else if (!HDPublicKey.isValidPath(path)) diff --git a/lib/bcoin/protocol/network.js b/lib/bcoin/protocol/network.js index 98afca55..d6c9413b 100644 --- a/lib/bcoin/protocol/network.js +++ b/lib/bcoin/protocol/network.js @@ -14,7 +14,7 @@ var utils = bcoin.utils; var network = exports; var main, testnet; -network.set = function(type) { +network.set = function set(type) { var net = network[type]; utils.merge(network, net); }; diff --git a/lib/bcoin/script.js b/lib/bcoin/script.js index c6d1e7a2..81f58c29 100644 --- a/lib/bcoin/script.js +++ b/lib/bcoin/script.js @@ -203,7 +203,7 @@ script.verify = function verify(hash, sig, pub) { } }; -script._next = function(to, s, pc) { +script._next = function _next(to, s, pc) { var depth = 0; var o; @@ -831,7 +831,7 @@ script.execute = function execute(s, stack, tx, index, recurse) { return true; }; -script.exec = function(input, output, tx, i, recurse) { +script.exec = function exec(input, output, tx, i, recurse) { var stack = []; var res; @@ -845,7 +845,7 @@ script.exec = function(input, output, tx, i, recurse) { return true; }; -script.multisig = function(keys, m, n) { +script.multisig = function multisig(keys, m, n) { if (keys.length < m) throw new Error('Wrong amount of pubkeys for multisig script'); @@ -1126,7 +1126,7 @@ script.isScripthashInput = function isScripthashInput(s, redeem) { * * This function is consensus-critical since BIP66. */ -script.isValidSig = function(sig, allowZero) { +script.isValidSig = function isValidSig(sig, allowZero) { var lenR, lenS; if (!Array.isArray(sig)) @@ -1215,7 +1215,7 @@ script.isValidSig = function(sig, allowZero) { return true; }; -script.format = function(input, output) { +script.format = function format(input, output) { var scripts = []; var prev, redeem; diff --git a/lib/bcoin/utils.js b/lib/bcoin/utils.js index 6400e167..15ecd317 100644 --- a/lib/bcoin/utils.js +++ b/lib/bcoin/utils.js @@ -570,7 +570,7 @@ utils.toBTC = function toBTC(satoshi, strict) { return satoshi.div(m).toString(10) + lo.replace(/0+$/, ''); }; -utils.fromBTC = function(btc, strict) { +utils.fromBTC = function fromBTC(btc, strict) { var m = new bn(10000000).mul(new bn(10)); var satoshi; @@ -598,7 +598,7 @@ utils.fromBTC = function(btc, strict) { return satoshi; }; -utils.isIP = function(ip) { +utils.isIP = function isIP(ip) { if (typeof ip !== 'string') return 0; @@ -611,11 +611,11 @@ utils.isIP = function(ip) { return 0; }; -utils.isHex = function(msg) { +utils.isHex = function isHex(msg) { return typeof msg === 'string' && /^[0-9a-f]+$/i.test(msg); }; -utils.toKeyArray = function(msg) { +utils.toKeyArray = function toKeyArray(msg) { if (typeof msg !== 'string') return msg; @@ -625,25 +625,25 @@ utils.toKeyArray = function(msg) { return utils.fromBase58(msg); }; -utils.inspect = function(obj) { +utils.inspect = function inspect(obj) { return typeof obj !== 'string' ? util.inspect(obj, null, 20, true) : obj; }; -utils.print = function(msg) { +utils.print = function print(msg) { return typeof msg === 'object' ? process.stdout.write(utils.inspect(msg) + '\n') : console.log.apply(console, arguments); }; -utils.debug = function() { +utils.debug = function debug() { var args = Array.prototype.slice.call(arguments); args[0] = '\x1b[31m' + args[0] + '\x1b[m'; return utils.print.apply(null, args); }; -utils.merge = function(target) { +utils.merge = function merge(target) { var args = Array.prototype.slice.call(arguments, 1); args.forEach(function(obj) { Object.keys(obj).forEach(function(key) { @@ -653,7 +653,7 @@ utils.merge = function(target) { return target; }; -utils.hidden = function(obj, prop, value) { +utils.hidden = function hidden(obj, prop, value) { Object.defineProperty(obj, prop, { value: value, enumerable: false, @@ -663,7 +663,7 @@ utils.hidden = function(obj, prop, value) { return obj; }; -utils.sortKeys = function(keys) { +utils.sortKeys = function sortKeys(keys) { return keys.sort(function(a, b) { return new bn(a).cmp(new bn(b)) > 0; }); diff --git a/lib/bcoin/wallet.js b/lib/bcoin/wallet.js index 37ae9b0e..b9c2f7e9 100644 --- a/lib/bcoin/wallet.js +++ b/lib/bcoin/wallet.js @@ -275,7 +275,7 @@ Wallet.prototype.getPublicKey = function getPublicKey(enc) { return this.getFullPublicKey(enc); }; -Wallet.prototype.getPublicKeys = function() { +Wallet.prototype.getPublicKeys = function getPublicKeys() { var keys = this.keys.slice().map(utils.toKeyArray); keys = utils.sortKeys(keys); @@ -492,7 +492,7 @@ Wallet.prototype.scriptInputs = function scriptInputs(tx, inputs) { return inputs.length; }; -Wallet.prototype.signInputs = function(tx, type, inputs) { +Wallet.prototype.signInputs = function signInputs(tx, type, inputs) { var key = this.key; if (!type)