style: function names.

This commit is contained in:
Christopher Jeffrey 2015-12-19 15:43:28 -08:00
parent 0aff6d7cfe
commit 61699cca3a
6 changed files with 36 additions and 36 deletions

View File

@ -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;

View File

@ -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))

View File

@ -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);
};

View File

@ -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;

View File

@ -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;
});

View File

@ -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)