Remove globals
This commit is contained in:
parent
4433bd422b
commit
d4b8c4adc6
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
"tags": {
|
||||||
|
"allowUnknownTags": true
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"include": ["docs/README.md"],
|
||||||
|
"exclude": [],
|
||||||
|
"includePattern": "lib/.+\\.js(doc)?$",
|
||||||
|
"excludePattern": "(^|\\/|\\\\)_"
|
||||||
|
},
|
||||||
|
"plugins": ["plugins/markdown"],
|
||||||
|
"templates": {
|
||||||
|
"cleverLinks": false,
|
||||||
|
"monospaceLinks": false
|
||||||
|
},
|
||||||
|
"opts": {
|
||||||
|
"template": "node_modules/ink-docstrap/template",
|
||||||
|
"encoding": "utf8",
|
||||||
|
"destination": "./apiref/",
|
||||||
|
"recurse": true,
|
||||||
|
"query": "value",
|
||||||
|
"private": true,
|
||||||
|
"lenient": true
|
||||||
|
},
|
||||||
|
"templates": {
|
||||||
|
"systemName": "bitcore",
|
||||||
|
"copyright": "© 2013-2014, BitPay Inc.",
|
||||||
|
"navType": "vertical",
|
||||||
|
"theme": "journal",
|
||||||
|
"linenums": true,
|
||||||
|
"collapseSymbols": false,
|
||||||
|
"inverseNav": false,
|
||||||
|
"outputSourceFiles": true
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
24
gulpfile.js
24
gulpfile.js
|
@ -120,26 +120,12 @@ gulp.task('lint', function() {
|
||||||
.pipe(jshint.reporter('default'));
|
.pipe(jshint.reporter('default'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('plato', shell.task[
|
gulp.task('plato', shell.task['plato -d report -r -l .jshintrc -t bitcore lib']);
|
||||||
'plato -d report -r -l .jshintrc -t bitcore lib'
|
|
||||||
]);
|
gulp.task('jsdoc', shell.task['jsdoc -c .jsdoc.conf lib']);
|
||||||
|
|
||||||
gulp.task('coverage', shell.task(['istanbul cover _mocha -- --recursive']));
|
gulp.task('coverage', shell.task(['istanbul cover _mocha -- --recursive']));
|
||||||
|
|
||||||
gulp.task('jsdoc', function() {
|
|
||||||
return gulp.src(files.concat([jsdocReadme]))
|
|
||||||
.pipe(jsdoc.parser({
|
|
||||||
name: 'bitcore',
|
|
||||||
version: '0.8.0',
|
|
||||||
description: 'API Reference for the bitcore bitcoin javascript library',
|
|
||||||
plugins: ['plugins/markdown']
|
|
||||||
}))
|
|
||||||
.pipe(jsdoc.generator('./apiref', {
|
|
||||||
path: 'ink-docstrap',
|
|
||||||
theme: 'journal'
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Watch tasks
|
* Watch tasks
|
||||||
*/
|
*/
|
||||||
|
@ -189,7 +175,7 @@ gulp.task('watch:browser', function() {
|
||||||
*/
|
*/
|
||||||
gulp.task('default', function(callback) {
|
gulp.task('default', function(callback) {
|
||||||
return runSequence(['lint', 'jsdoc'],
|
return runSequence(['lint', 'jsdoc'],
|
||||||
['browser:compressed', 'test'],
|
['browser:uncompressed', 'test'],
|
||||||
['coverage', 'minify'],
|
['coverage', 'browser:compressed'],
|
||||||
callback);
|
callback);
|
||||||
});
|
});
|
||||||
|
|
6
index.js
6
index.js
|
@ -20,16 +20,12 @@ bitcore.encoding.Varint = require('./lib/encoding/varint');
|
||||||
|
|
||||||
// utilities
|
// utilities
|
||||||
bitcore.util = {};
|
bitcore.util = {};
|
||||||
bitcore.util.bitcoin = require('./lib/util/bitcoin');
|
|
||||||
bitcore.util.buffer = require('./lib/util/buffer');
|
bitcore.util.buffer = require('./lib/util/buffer');
|
||||||
bitcore.util.js = require('./lib/util/js');
|
bitcore.util.js = require('./lib/util/js');
|
||||||
bitcore.util.preconditions = require('./lib/util/preconditions');
|
bitcore.util.preconditions = require('./lib/util/preconditions');
|
||||||
|
|
||||||
// transport
|
// transport
|
||||||
bitcore.transport = {};
|
bitcore.transport = require('./lib/transport');
|
||||||
bitcore.transport.Peer = require('./lib/transport/peer');
|
|
||||||
bitcore.transport.Messages = require('./lib/transport/messages');
|
|
||||||
bitcore.transport.Pool = require('./lib/transport/pool');
|
|
||||||
|
|
||||||
// errors thrown by the library
|
// errors thrown by the library
|
||||||
bitcore.errors = require('./lib/errors');
|
bitcore.errors = require('./lib/errors');
|
||||||
|
|
34
lib/block.js
34
lib/block.js
|
@ -12,6 +12,7 @@ var Transaction = require('./transaction');
|
||||||
var Varint = require('./encoding/varint');
|
var Varint = require('./encoding/varint');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @class Block
|
||||||
* Instantiate a Block from a Buffer, JSON object, or Object with
|
* Instantiate a Block from a Buffer, JSON object, or Object with
|
||||||
* the properties of the Block
|
* the properties of the Block
|
||||||
*
|
*
|
||||||
|
@ -42,10 +43,26 @@ Block._from = function _from(arg) {
|
||||||
info = Block._fromJSON(arg);
|
info = Block._fromJSON(arg);
|
||||||
} else if (_.isObject(arg)) {
|
} else if (_.isObject(arg)) {
|
||||||
info = {
|
info = {
|
||||||
|
/**
|
||||||
|
* @name Block#magicnum
|
||||||
|
* @type number
|
||||||
|
*/
|
||||||
magicnum: arg.magicnum,
|
magicnum: arg.magicnum,
|
||||||
|
/**
|
||||||
|
* @name Block#blocksize
|
||||||
|
* @type number
|
||||||
|
*/
|
||||||
blocksize: arg.blocksize,
|
blocksize: arg.blocksize,
|
||||||
|
/**
|
||||||
|
* @name Block#blockheader
|
||||||
|
* @type {BlockHeader}
|
||||||
|
*/
|
||||||
blockheader: arg.blockheader,
|
blockheader: arg.blockheader,
|
||||||
txsvi: arg.txsvi,
|
txsvi: arg.txsvi,
|
||||||
|
/**
|
||||||
|
* @name Block#txs
|
||||||
|
* @type {Transaction[]}
|
||||||
|
*/
|
||||||
txs: arg.txs
|
txs: arg.txs
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
@ -59,18 +76,35 @@ Block._from = function _from(arg) {
|
||||||
* easier access
|
* easier access
|
||||||
*/
|
*/
|
||||||
Block.prototype._setupProperties = function() {
|
Block.prototype._setupProperties = function() {
|
||||||
|
/**
|
||||||
|
* @name Block#version
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
Object.defineProperty(this, 'version', {
|
Object.defineProperty(this, 'version', {
|
||||||
configurable: false,
|
configurable: false,
|
||||||
value: this.blockheader.version
|
value: this.blockheader.version
|
||||||
});
|
});
|
||||||
|
/**
|
||||||
|
* @name Block#timestamp
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
Object.defineProperty(this, 'timestamp', {
|
Object.defineProperty(this, 'timestamp', {
|
||||||
configurable: false,
|
configurable: false,
|
||||||
value: this.blockheader.timestamp
|
value: this.blockheader.timestamp
|
||||||
});
|
});
|
||||||
|
/**
|
||||||
|
* @name Block#nonce
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
Object.defineProperty(this, 'nonce', {
|
Object.defineProperty(this, 'nonce', {
|
||||||
configurable: false,
|
configurable: false,
|
||||||
value: this.blockheader.nonce
|
value: this.blockheader.nonce
|
||||||
});
|
});
|
||||||
|
/**
|
||||||
|
* Amount of bytes of the serialized block
|
||||||
|
* @name Block#size
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
Object.defineProperty(this, 'size', {
|
Object.defineProperty(this, 'size', {
|
||||||
configurable: false,
|
configurable: false,
|
||||||
value: this.blockheader.size
|
value: this.blockheader.size
|
||||||
|
|
|
@ -35,7 +35,7 @@ var traverseRoot = function(errorsDefinition) {
|
||||||
var fullName = 'bitcore.Error';
|
var fullName = 'bitcore.Error';
|
||||||
var path = 'Error';
|
var path = 'Error';
|
||||||
var generated = '\'use strict\';\n\nvar inherits = require(\'inherits\');\n\n';
|
var generated = '\'use strict\';\n\nvar inherits = require(\'inherits\');\n\n';
|
||||||
generated += '/** AUTOGENERATED FILE. DON\'T EDIT, MODIFY "lib/errors/spec.js" INSTEAD */\n\n';
|
generated += '/* AUTOGENERATED FILE. DON\'T EDIT, MODIFY "lib/errors/spec.js" INSTEAD */\n\n';
|
||||||
generated += 'var bitcore = {};\n\n';
|
generated += 'var bitcore = {};\n\n';
|
||||||
generated += defineElement(fullName, path, '\'Internal error\'');
|
generated += defineElement(fullName, path, '\'Internal error\'');
|
||||||
generated += childDefinitions(fullName, errorsDefinition);
|
generated += childDefinitions(fullName, errorsDefinition);
|
||||||
|
|
|
@ -12,6 +12,9 @@ var Signature = require('../../crypto/signature');
|
||||||
var Sighash = require('../sighash');
|
var Sighash = require('../sighash');
|
||||||
var BufferUtil = require('../../util/buffer');
|
var BufferUtil = require('../../util/buffer');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
function MultiSigScriptHashInput(input, pubkeys, threshold) {
|
function MultiSigScriptHashInput(input, pubkeys, threshold) {
|
||||||
Input.apply(this, arguments);
|
Input.apply(this, arguments);
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
|
@ -14,6 +14,7 @@ var Signature = require('../../crypto/signature');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a special kind of input of PayToPublicKeyHash kind.
|
* Represents a special kind of input of PayToPublicKeyHash kind.
|
||||||
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function PublicKeyHashInput() {
|
function PublicKeyHashInput() {
|
||||||
Input.apply(this, arguments);
|
Input.apply(this, arguments);
|
||||||
|
|
|
@ -19,6 +19,7 @@ var BITS_64_ON = 'ffffffffffffffff';
|
||||||
* Returns a buffer of length 32 bytes with the hash that needs to be signed
|
* Returns a buffer of length 32 bytes with the hash that needs to be signed
|
||||||
* for OP_CHECKSIG.
|
* for OP_CHECKSIG.
|
||||||
*
|
*
|
||||||
|
* @name Signing.sighash
|
||||||
* @param {Transaction} transaction the transaction to sign
|
* @param {Transaction} transaction the transaction to sign
|
||||||
* @param {number} sighashType the type of the hash
|
* @param {number} sighashType the type of the hash
|
||||||
* @param {number} inputNumber the input index for the signature
|
* @param {number} inputNumber the input index for the signature
|
||||||
|
@ -90,21 +91,46 @@ var sighash = function sighash(transaction, sighashType, inputNumber, subscript)
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
var sign = function sign(transaction, keypair, nhashtype, nin, subscript) {
|
/**
|
||||||
var hashbuf = sighash(transaction, nhashtype, nin, subscript);
|
* Create a signature
|
||||||
var sig = ECDSA.sign(hashbuf, keypair, 'little').set({
|
*
|
||||||
nhashtype: nhashtype
|
* @name Signing.sign
|
||||||
|
* @param {Transaction} transaction
|
||||||
|
* @param {PrivateKey} privateKey
|
||||||
|
* @param {number} sighash
|
||||||
|
* @param {number} inputIndex
|
||||||
|
* @param {Script} subscript
|
||||||
|
* @return {Signature}
|
||||||
|
*/
|
||||||
|
function sign(transaction, privateKey, sighashType, inputIndex, subscript) {
|
||||||
|
var hashbuf = sighash(transaction, sighashType, inputIndex, subscript);
|
||||||
|
var sig = ECDSA.sign(hashbuf, privateKey, 'little').set({
|
||||||
|
nhashtype: sighashType
|
||||||
});
|
});
|
||||||
return sig;
|
return sig;
|
||||||
};
|
}
|
||||||
|
|
||||||
var verify = function verify(transaction, sig, pubkey, nin, subscript) {
|
/**
|
||||||
|
* Verify a signature
|
||||||
|
*
|
||||||
|
* @name Signing.verify
|
||||||
|
* @param {Transaction} transaction
|
||||||
|
* @param {Signature} signature
|
||||||
|
* @param {PublicKey} publicKey
|
||||||
|
* @param {number} inputIndex
|
||||||
|
* @param {Script} subscript
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
function verify(transaction, signature, publicKey, inputIndex, subscript) {
|
||||||
$.checkArgument(transaction);
|
$.checkArgument(transaction);
|
||||||
$.checkArgument(sig && sig.nhashtype);
|
$.checkArgument(signature && signature.nhashtype);
|
||||||
var hashbuf = sighash(transaction, sig.nhashtype, nin, subscript);
|
var hashbuf = sighash(transaction, signature.nhashtype, inputIndex, subscript);
|
||||||
return ECDSA.verify(hashbuf, sig, pubkey, 'little');
|
return ECDSA.verify(hashbuf, signature, publicKey, 'little');
|
||||||
};
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @namespace Signing
|
||||||
|
*/
|
||||||
module.exports = {
|
module.exports = {
|
||||||
sighash: sighash,
|
sighash: sighash,
|
||||||
sign: sign,
|
sign: sign,
|
||||||
|
|
|
@ -31,6 +31,7 @@ var DEFAULT_SEQNUMBER = 0xFFFFFFFF;
|
||||||
* ownership of tokens
|
* ownership of tokens
|
||||||
*
|
*
|
||||||
* @param {*} serialized
|
* @param {*} serialized
|
||||||
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function Transaction(serialized) {
|
function Transaction(serialized) {
|
||||||
if (!(this instanceof Transaction)) {
|
if (!(this instanceof Transaction)) {
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
/**
|
||||||
|
* @namespace Transport
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
Peer: require('./peer'),
|
||||||
|
Messages: require('./messages'),
|
||||||
|
Pool: require('./pool')
|
||||||
|
};
|
|
@ -1,4 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
/**
|
||||||
|
* @namespace Transport.Message
|
||||||
|
*/
|
||||||
/* jshint curly: false */
|
/* jshint curly: false */
|
||||||
|
|
||||||
var Buffers = require('buffers');
|
var Buffers = require('buffers');
|
||||||
|
@ -19,6 +22,7 @@ var PROTOCOL_VERSION = 70000;
|
||||||
/**
|
/**
|
||||||
* Static helper for consuming a data buffer until the next message.
|
* Static helper for consuming a data buffer until the next message.
|
||||||
*
|
*
|
||||||
|
* @name Transport.Message#parseMessage
|
||||||
* @param{Network} network - the network object
|
* @param{Network} network - the network object
|
||||||
* @param{Buffer} dataBuffer - the buffer to read from
|
* @param{Buffer} dataBuffer - the buffer to read from
|
||||||
* @returns{Message|undefined} A message or undefined if there is nothing to read.
|
* @returns{Message|undefined} A message or undefined if there is nothing to read.
|
||||||
|
@ -55,7 +59,8 @@ var parseMessage = function(network, dataBuffer) {
|
||||||
module.exports.parseMessage = parseMessage;
|
module.exports.parseMessage = parseMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal function that discards data until founds the next message.
|
* @desc Internal function that discards data until founds the next message.
|
||||||
|
* @name Transport.Message#discardUntilNextMessage
|
||||||
*/
|
*/
|
||||||
function discardUntilNextMessage(network, dataBuffer) {
|
function discardUntilNextMessage(network, dataBuffer) {
|
||||||
var magicNumber = network.networkMagic;
|
var magicNumber = network.networkMagic;
|
||||||
|
@ -82,11 +87,20 @@ function discardUntilNextMessage(network, dataBuffer) {
|
||||||
/**
|
/**
|
||||||
* Abstract Message that knows how to parse and serialize itself.
|
* Abstract Message that knows how to parse and serialize itself.
|
||||||
* Concret subclases should implement {fromBuffer} and {getPayload} methods.
|
* Concret subclases should implement {fromBuffer} and {getPayload} methods.
|
||||||
|
* @name Transport.Message
|
||||||
*/
|
*/
|
||||||
function Message() {}
|
function Message() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @value
|
||||||
|
* @name Transport.Message.COMMANDS
|
||||||
|
*/
|
||||||
Message.COMMANDS = {};
|
Message.COMMANDS = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look up a message type by command name and instantiate the correct Message
|
||||||
|
* @name Transport.Message#buildMessage
|
||||||
|
*/
|
||||||
Message.buildMessage = function(command, payload) {
|
Message.buildMessage = function(command, payload) {
|
||||||
try {
|
try {
|
||||||
var CommandClass = Message.COMMANDS[command];
|
var CommandClass = Message.COMMANDS[command];
|
||||||
|
@ -146,6 +160,7 @@ Message.prototype.serialize = function(network) {
|
||||||
/**
|
/**
|
||||||
* Version Message
|
* Version Message
|
||||||
*
|
*
|
||||||
|
* @name Transport.Message.Version
|
||||||
* @param{string} subversion - version of the client
|
* @param{string} subversion - version of the client
|
||||||
* @param{Buffer} nonce - a random 8 bytes buffer
|
* @param{Buffer} nonce - a random 8 bytes buffer
|
||||||
*/
|
*/
|
||||||
|
@ -191,6 +206,7 @@ module.exports.Version = Message.COMMANDS.version = Version;
|
||||||
/**
|
/**
|
||||||
* Inv Message
|
* Inv Message
|
||||||
*
|
*
|
||||||
|
* @name Transport.Message.Inventory
|
||||||
* @param{Array} inventory - reported elements
|
* @param{Array} inventory - reported elements
|
||||||
*/
|
*/
|
||||||
function Inventory(inventory) {
|
function Inventory(inventory) {
|
||||||
|
@ -229,6 +245,7 @@ module.exports.Inventory = Message.COMMANDS.inv = Inventory;
|
||||||
/**
|
/**
|
||||||
* Getdata Message
|
* Getdata Message
|
||||||
*
|
*
|
||||||
|
* @name Transport.Message.GetData
|
||||||
* @param{Array} inventory - requested elements
|
* @param{Array} inventory - requested elements
|
||||||
*/
|
*/
|
||||||
function GetData(inventory) {
|
function GetData(inventory) {
|
||||||
|
@ -242,6 +259,7 @@ module.exports.GetData = GetData;
|
||||||
/**
|
/**
|
||||||
* Ping Message
|
* Ping Message
|
||||||
*
|
*
|
||||||
|
* @name Transport.Message.Ping
|
||||||
* @param{Buffer} nonce - a random 8 bytes buffer
|
* @param{Buffer} nonce - a random 8 bytes buffer
|
||||||
*/
|
*/
|
||||||
function Ping(nonce) {
|
function Ping(nonce) {
|
||||||
|
@ -264,6 +282,7 @@ module.exports.Ping = Message.COMMANDS.ping = Ping;
|
||||||
/**
|
/**
|
||||||
* Pong Message
|
* Pong Message
|
||||||
*
|
*
|
||||||
|
* @name Transport.Message.Pong
|
||||||
* @param{Buffer} nonce - a random 8 bytes buffer
|
* @param{Buffer} nonce - a random 8 bytes buffer
|
||||||
*/
|
*/
|
||||||
function Pong(nonce) {
|
function Pong(nonce) {
|
||||||
|
@ -277,6 +296,7 @@ module.exports.Pong = Message.COMMANDS.pong = Pong;
|
||||||
/**
|
/**
|
||||||
* Addr Message
|
* Addr Message
|
||||||
*
|
*
|
||||||
|
* @name Transport.Message.Addressess
|
||||||
* @param{Array} addresses - array of know addresses
|
* @param{Array} addresses - array of know addresses
|
||||||
*/
|
*/
|
||||||
function Addresses(addresses) {
|
function Addresses(addresses) {
|
||||||
|
@ -342,6 +362,7 @@ module.exports.Addresses = Message.COMMANDS.addr = Addresses;
|
||||||
/**
|
/**
|
||||||
* GetAddr Message
|
* GetAddr Message
|
||||||
*
|
*
|
||||||
|
* @name Transport.Message.GetAddresses
|
||||||
*/
|
*/
|
||||||
function GetAddresses() {
|
function GetAddresses() {
|
||||||
this.command = 'getaddr';
|
this.command = 'getaddr';
|
||||||
|
@ -353,6 +374,7 @@ module.exports.GetAddresses = Message.COMMANDS.getaddr = GetAddresses;
|
||||||
/**
|
/**
|
||||||
* Verack Message
|
* Verack Message
|
||||||
*
|
*
|
||||||
|
* @name Transport.Message.VerAck
|
||||||
*/
|
*/
|
||||||
function VerAck() {
|
function VerAck() {
|
||||||
this.command = 'verack';
|
this.command = 'verack';
|
||||||
|
@ -364,6 +386,7 @@ module.exports.VerAck = Message.COMMANDS.verack = VerAck;
|
||||||
/**
|
/**
|
||||||
* Reject Message
|
* Reject Message
|
||||||
*
|
*
|
||||||
|
* @name Transport.Message.Reject
|
||||||
*/
|
*/
|
||||||
function Reject() {
|
function Reject() {
|
||||||
this.command = 'reject';
|
this.command = 'reject';
|
||||||
|
@ -377,6 +400,7 @@ module.exports.Reject = Message.COMMANDS.reject = Reject;
|
||||||
/**
|
/**
|
||||||
* Alert Message
|
* Alert Message
|
||||||
*
|
*
|
||||||
|
* @name Transport.Message.Alert
|
||||||
*/
|
*/
|
||||||
function Alert(payload, signature) {
|
function Alert(payload, signature) {
|
||||||
this.command = 'alert';
|
this.command = 'alert';
|
||||||
|
@ -408,6 +432,7 @@ module.exports.Alert = Message.COMMANDS.alert = Alert;
|
||||||
/**
|
/**
|
||||||
* Headers Message
|
* Headers Message
|
||||||
*
|
*
|
||||||
|
* @name Transport.Message.Headers
|
||||||
* @param{Array} blockheaders - array of block headers
|
* @param{Array} blockheaders - array of block headers
|
||||||
*/
|
*/
|
||||||
function Headers(blockheaders) {
|
function Headers(blockheaders) {
|
||||||
|
@ -446,6 +471,7 @@ module.exports.Headers = Message.COMMANDS.headers = Headers;
|
||||||
/**
|
/**
|
||||||
* Block Message
|
* Block Message
|
||||||
*
|
*
|
||||||
|
* @name Transport.Message.Block
|
||||||
* @param{Block} block
|
* @param{Block} block
|
||||||
*/
|
*/
|
||||||
function Block(block) {
|
function Block(block) {
|
||||||
|
@ -468,6 +494,7 @@ module.exports.Block = Message.COMMANDS.block = Block;
|
||||||
/**
|
/**
|
||||||
* Tx Message
|
* Tx Message
|
||||||
*
|
*
|
||||||
|
* @name Transport.Message.Transaction
|
||||||
* @param{Transaction} transaction
|
* @param{Transaction} transaction
|
||||||
*/
|
*/
|
||||||
function Transaction(transaction) {
|
function Transaction(transaction) {
|
||||||
|
@ -490,6 +517,7 @@ module.exports.Transaction = Message.COMMANDS.tx = Transaction;
|
||||||
/**
|
/**
|
||||||
* Getblocks Message
|
* Getblocks Message
|
||||||
*
|
*
|
||||||
|
* @name Transport.Message.GetBlocks
|
||||||
* @param{Array} starts - array of buffers with the starting block hashes
|
* @param{Array} starts - array of buffers with the starting block hashes
|
||||||
* @param{Buffer} [stop] - hash of the last block
|
* @param{Buffer} [stop] - hash of the last block
|
||||||
*/
|
*/
|
||||||
|
@ -540,6 +568,7 @@ module.exports.GetBlocks = Message.COMMANDS.getblocks = GetBlocks;
|
||||||
/**
|
/**
|
||||||
* Getheaders Message
|
* Getheaders Message
|
||||||
*
|
*
|
||||||
|
* @name Transport.Message.GetHeaders
|
||||||
* @param{Array} starts - array of buffers with the starting block hashes
|
* @param{Array} starts - array of buffers with the starting block hashes
|
||||||
* @param{Buffer} [stop] - hash of the last block
|
* @param{Buffer} [stop] - hash of the last block
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,8 +22,8 @@ var JSUtil = require('./util/js');
|
||||||
* @param {Number} amount - The amount to be represented
|
* @param {Number} amount - The amount to be represented
|
||||||
* @param {String} code - The unit of the amount
|
* @param {String} code - The unit of the amount
|
||||||
* @returns {Unit} A new instance of an Unit
|
* @returns {Unit} A new instance of an Unit
|
||||||
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function Unit(amount, code) {
|
function Unit(amount, code) {
|
||||||
if (!(this instanceof Unit)) {
|
if (!(this instanceof Unit)) {
|
||||||
return new Unit(amount, code);
|
return new Unit(amount, code);
|
||||||
|
|
|
@ -29,6 +29,7 @@ var JSUtil = require('./util/js');
|
||||||
* @throws {TypeError} Invalid amount
|
* @throws {TypeError} Invalid amount
|
||||||
* @throws {Error} Unknown required argument
|
* @throws {Error} Unknown required argument
|
||||||
* @returns {URI} A new valid and frozen instance of URI
|
* @returns {URI} A new valid and frozen instance of URI
|
||||||
|
* @constructor
|
||||||
*/
|
*/
|
||||||
var URI = function(data, knownParams) {
|
var URI = function(data, knownParams) {
|
||||||
this.extras = {};
|
this.extras = {};
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
/**
|
|
||||||
* @file util/bitcoin.js
|
|
||||||
* Contains utilities to handle magnitudes inside of bitcoin
|
|
||||||
*/
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var SATOSHIS_PER_BTC = 1e8;
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
/**
|
|
||||||
* @param number satoshis - amount of satoshis to convert
|
|
||||||
* @return string an exact representation of such amount, in form of a string
|
|
||||||
* (avoids duplicate representations in ieee756 of the same number)
|
|
||||||
*/
|
|
||||||
satoshisToBitcoin: function(satoshis) {
|
|
||||||
return satoshis / SATOSHIS_PER_BTC;
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -5,6 +5,7 @@ var _ = require('lodash');
|
||||||
/**
|
/**
|
||||||
* Determines whether a string contains only hexadecimal values
|
* Determines whether a string contains only hexadecimal values
|
||||||
*
|
*
|
||||||
|
* @name JSUtil.isHexa
|
||||||
* @param {string} value
|
* @param {string} value
|
||||||
* @return {boolean} true if the string is the hexa representation of a number
|
* @return {boolean} true if the string is the hexa representation of a number
|
||||||
*/
|
*/
|
||||||
|
@ -15,6 +16,9 @@ var isHexa = function isHexa(value) {
|
||||||
return /^[0-9a-fA-F]+$/.test(value);
|
return /^[0-9a-fA-F]+$/.test(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @namespace JSUtil
|
||||||
|
*/
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/**
|
/**
|
||||||
* Test if an argument is a valid JSON object. If it is, returns a truthy
|
* Test if an argument is a valid JSON object. If it is, returns a truthy
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "gulp lint",
|
"lint": "gulp lint",
|
||||||
"test": "gulp test-all",
|
"test": "gulp test",
|
||||||
"coverage": "gulp coverage",
|
"coverage": "gulp coverage",
|
||||||
"build": "gulp",
|
"build": "gulp",
|
||||||
"postinstall": "node ./lib/errors/build.js"
|
"postinstall": "node ./lib/errors/build.js"
|
||||||
|
@ -79,8 +79,11 @@
|
||||||
"elliptic": "=0.15.14",
|
"elliptic": "=0.15.14",
|
||||||
"hash.js": "=0.3.2",
|
"hash.js": "=0.3.2",
|
||||||
"inherits": "=2.0.1",
|
"inherits": "=2.0.1",
|
||||||
|
"ink-docstrap": "^0.4.12",
|
||||||
|
"jsdoc": "^3.3.0-alpha11",
|
||||||
"jsrsasign": "=0.0.3",
|
"jsrsasign": "=0.0.3",
|
||||||
"lodash": "=2.4.1",
|
"lodash": "=2.4.1",
|
||||||
|
"plato": "^1.3.0",
|
||||||
"protobufjs": "=3.0.0",
|
"protobufjs": "=3.0.0",
|
||||||
"sha512": "=0.0.1",
|
"sha512": "=0.0.1",
|
||||||
"socks5-client": "^0.3.6"
|
"socks5-client": "^0.3.6"
|
||||||
|
|
Loading…
Reference in New Issue