diff --git a/bitcore-lib.js b/bitcore-lib.js index 04120c68d..aba9798db 100644 --- a/bitcore-lib.js +++ b/bitcore-lib.js @@ -40,7 +40,7 @@ var PublicKey = require('./publickey'); * ``` * * @param {*} data - The encoded data in various formats - * @param {Network|String|number=} network - The network: 'livenet' or 'testnet' + * @param {Network|String|number=} network - The network: Constants.LIVENET or Constants.TESTNET * @param {string=} type - The type of address: 'script' or 'pubkey' * @returns {Address} A new valid and frozen instance of an Address * @constructor @@ -65,7 +65,7 @@ function Address(data, network, type) { $.checkArgument(data, 'First argument is required, please include address data.', 'guide/address.html'); if (network && !Networks.get(network)) { - throw new TypeError('Second argument must be "livenet" or "testnet".'); + throw new TypeError('Second argument must be "livenet/btc" or "testnet/btc".'); } if (type && (type !== Address.PayToPublicKeyHash && type !== Address.PayToScriptHash)) { @@ -90,7 +90,7 @@ function Address(data, network, type) { /** * Internal function used to split different kinds of arguments of the constructor * @param {*} data - The encoded data in various formats - * @param {Network|String|number=} network - The network: 'livenet' or 'testnet' + * @param {Network|String|number=} network - The network: Constants.LIVENET or Constants.TESTNET * @param {string=} type - The type of address: 'script' or 'pubkey' * @returns {Object} An "info" object with "type", "network", and "hashBuffer" */ @@ -182,7 +182,7 @@ Address._classifyFromVersion = function(buffer) { * Internal function to transform a bitcoin address buffer * * @param {Buffer} buffer - An instance of a hex encoded address Buffer - * @param {string=} network - The network: 'livenet' or 'testnet' + * @param {string=} network - The network: Constants.LIVENET or Constants.TESTNET * @param {string=} type - The type: 'pubkeyhash' or 'scripthash' * @returns {Object} An object with keys: hashBuffer, network and type * @private @@ -256,7 +256,7 @@ Address._transformScript = function(script, network) { * * @param {Array} publicKeys - a set of public keys to create an address * @param {number} threshold - the number of signatures needed to release the funds - * @param {String|Network} network - either a Network instance, 'livenet', or 'testnet' + * @param {String|Network} network - either a Network instance, Constants.LIVENET, or Constants.TESTNET * @return {Address} */ Address.createMultisig = function(publicKeys, threshold, network) { @@ -268,7 +268,7 @@ Address.createMultisig = function(publicKeys, threshold, network) { * Internal function to transform a bitcoin address string * * @param {string} data - * @param {String|Network=} network - either a Network instance, 'livenet', or 'testnet' + * @param {String|Network=} network - either a Network instance, Constants.LIVENET, or Constants.TESTNET * @param {string=} type - The type: 'pubkeyhash' or 'scripthash' * @returns {Object} An object with keys: hashBuffer, network and type * @private @@ -287,7 +287,7 @@ Address._transformString = function(data, network, type) { * Instantiate an address from a PublicKey instance * * @param {PublicKey} data - * @param {String|Network} network - either a Network instance, 'livenet', or 'testnet' + * @param {String|Network} network - either a Network instance, Constants.LIVENET, or Constants.TESTNET * @returns {Address} A new valid and frozen instance of an Address */ Address.fromPublicKey = function(data, network) { @@ -300,7 +300,7 @@ Address.fromPublicKey = function(data, network) { * Instantiate an address from a ripemd160 public key hash * * @param {Buffer} hash - An instance of buffer of the hash - * @param {String|Network} network - either a Network instance, 'livenet', or 'testnet' + * @param {String|Network} network - either a Network instance, Constants.LIVENET, or Constants.TESTNET * @returns {Address} A new valid and frozen instance of an Address */ Address.fromPublicKeyHash = function(hash, network) { @@ -312,7 +312,7 @@ Address.fromPublicKeyHash = function(hash, network) { * Instantiate an address from a ripemd160 script hash * * @param {Buffer} hash - An instance of buffer of the hash - * @param {String|Network} network - either a Network instance, 'livenet', or 'testnet' + * @param {String|Network} network - either a Network instance, Constants.LIVENET, or Constants.TESTNET * @returns {Address} A new valid and frozen instance of an Address */ Address.fromScriptHash = function(hash, network) { @@ -328,7 +328,7 @@ Address.fromScriptHash = function(hash, network) { * see {{Address#fromScript}} * * @param {Script} script - An instance of Script - * @param {String|Network} network - either a Network instance, 'livenet', or 'testnet' + * @param {String|Network} network - either a Network instance, Constants.LIVENET, or Constants.TESTNET * @returns {Address} A new valid and frozen instance of an Address */ Address.payingTo = function(script, network) { @@ -347,7 +347,7 @@ Address.payingTo = function(script, network) { * to that script's hash instead, use {{Address#payingTo}} * * @param {Script} script - An instance of Script - * @param {String|Network} network - either a Network instance, 'livenet', or 'testnet' + * @param {String|Network} network - either a Network instance, Constants.LIVENET, or Constants.TESTNET * @returns {Address} A new valid and frozen instance of an Address */ Address.fromScript = function(script, network) { @@ -360,7 +360,7 @@ Address.fromScript = function(script, network) { * Instantiate an address from a buffer of the address * * @param {Buffer} buffer - An instance of buffer of the address - * @param {String|Network=} network - either a Network instance, 'livenet', or 'testnet' + * @param {String|Network=} network - either a Network instance, Constants.LIVENET, or Constants.TESTNET * @param {string=} type - The type of address: 'script' or 'pubkey' * @returns {Address} A new valid and frozen instance of an Address */ @@ -373,7 +373,7 @@ Address.fromBuffer = function(buffer, network, type) { * Instantiate an address from an address string * * @param {string} str - An string of the bitcoin address - * @param {String|Network=} network - either a Network instance, 'livenet', or 'testnet' + * @param {String|Network=} network - either a Network instance, Constants.LIVENET, or Constants.TESTNET * @param {string=} type - The type of address: 'script' or 'pubkey' * @returns {Address} A new valid and frozen instance of an Address */ @@ -407,7 +407,7 @@ Address.fromObject = function fromObject(obj) { * ``` * * @param {string} data - The encoded data - * @param {String|Network} network - either a Network instance, 'livenet', or 'testnet' + * @param {String|Network} network - either a Network instance, Constants.LIVENET, or Constants.TESTNET * @param {string} type - The type of address: 'script' or 'pubkey' * @returns {null|Error} The corresponding error message */ @@ -427,11 +427,11 @@ Address.getValidationError = function(data, network, type) { * * @example * ```javascript - * assert(Address.isValid('15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2', 'livenet')); + * assert(Address.isValid('15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2', Constants.LIVENET)); * ``` * * @param {string} data - The encoded data - * @param {String|Network} network - either a Network instance, 'livenet', or 'testnet' + * @param {String|Network} network - either a Network instance, Constants.LIVENET, or Constants.TESTNET * @param {string} type - The type of address: 'script' or 'pubkey' * @returns {boolean} The corresponding error message */ @@ -500,7 +500,7 @@ module.exports = Address; var Script = require('./script'); }).call(this,require("buffer").Buffer) -},{"./crypto/hash":8,"./encoding/base58check":13,"./errors":17,"./networks":21,"./publickey":24,"./script":25,"./util/js":43,"./util/preconditions":44,"buffer":47,"lodash":298}],2:[function(require,module,exports){ +},{"./crypto/hash":9,"./encoding/base58check":14,"./errors":18,"./networks":22,"./publickey":25,"./script":26,"./util/js":44,"./util/preconditions":45,"buffer":113,"lodash":194}],2:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -785,7 +785,7 @@ Block.Values = { module.exports = Block; }).call(this,require("buffer").Buffer) -},{"../crypto/bn":6,"../crypto/hash":8,"../encoding/bufferreader":14,"../encoding/bufferwriter":15,"../transaction":28,"../util/buffer":42,"../util/preconditions":44,"./blockheader":3,"buffer":47,"lodash":298}],3:[function(require,module,exports){ +},{"../crypto/bn":7,"../crypto/hash":9,"../encoding/bufferreader":15,"../encoding/bufferwriter":16,"../transaction":29,"../util/buffer":43,"../util/preconditions":45,"./blockheader":3,"buffer":113,"lodash":194}],3:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -1085,7 +1085,7 @@ BlockHeader.Constants = { module.exports = BlockHeader; }).call(this,require("buffer").Buffer) -},{"../crypto/bn":6,"../crypto/hash":8,"../encoding/bufferreader":14,"../encoding/bufferwriter":15,"../util/buffer":42,"../util/js":43,"../util/preconditions":44,"buffer":47,"lodash":298}],4:[function(require,module,exports){ +},{"../crypto/bn":7,"../crypto/hash":9,"../encoding/bufferreader":15,"../encoding/bufferwriter":16,"../util/buffer":43,"../util/js":44,"../util/preconditions":45,"buffer":113,"lodash":194}],4:[function(require,module,exports){ module.exports = require('./block'); module.exports.BlockHeader = require('./blockheader'); @@ -1367,7 +1367,19 @@ MerkleBlock.fromObject = function fromObject(obj) { module.exports = MerkleBlock; }).call(this,require("buffer").Buffer) -},{"../crypto/hash":8,"../encoding/bufferreader":14,"../encoding/bufferwriter":15,"../transaction":28,"../util/buffer":42,"../util/js":43,"../util/preconditions":44,"./blockheader":3,"buffer":47,"lodash":298}],6:[function(require,module,exports){ +},{"../crypto/hash":9,"../encoding/bufferreader":15,"../encoding/bufferwriter":16,"../transaction":29,"../util/buffer":43,"../util/js":44,"../util/preconditions":45,"./blockheader":3,"buffer":113,"lodash":194}],6:[function(require,module,exports){ +'use strict'; + +var Constants = {}; + +Constants.LIVENET = 'livenet/btc'; +Constants.LIVENET_ALIAS = 'mainnet/btc'; +Constants.TESTNET = 'testnet/btc'; +Constants.TESTNET_ALIAS = 'regtest/btc'; + +module.exports = Constants; + +},{}],7:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -1573,7 +1585,7 @@ BN.pad = function(buf, natlen, size) { module.exports = BN; }).call(this,require("buffer").Buffer) -},{"../util/preconditions":44,"bn.js":273,"buffer":47,"lodash":298}],7:[function(require,module,exports){ +},{"../util/preconditions":45,"bn.js":63,"buffer":113,"lodash":194}],8:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -1873,7 +1885,7 @@ ECDSA.verify = function(hashbuf, sig, pubkey, endian) { module.exports = ECDSA; }).call(this,require("buffer").Buffer) -},{"../publickey":24,"../util/buffer":42,"../util/preconditions":44,"./bn":6,"./hash":8,"./point":9,"./random":10,"./signature":11,"buffer":47,"lodash":298}],8:[function(require,module,exports){ +},{"../publickey":25,"../util/buffer":43,"../util/preconditions":45,"./bn":7,"./hash":9,"./point":10,"./random":11,"./signature":12,"buffer":113,"lodash":194}],9:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -1962,7 +1974,7 @@ Hash.sha512hmac = function(data, key) { }; }).call(this,require("buffer").Buffer) -},{"../util/buffer":42,"../util/preconditions":44,"buffer":47,"crypto":51}],9:[function(require,module,exports){ +},{"../util/buffer":43,"../util/preconditions":45,"buffer":113,"crypto":139}],10:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -2111,7 +2123,7 @@ Point.pointToCompressed = function pointToCompressed(point) { module.exports = Point; }).call(this,require("buffer").Buffer) -},{"../util/buffer":42,"./bn":6,"buffer":47,"elliptic":276}],10:[function(require,module,exports){ +},{"../util/buffer":43,"./bn":7,"buffer":113,"elliptic":151}],11:[function(require,module,exports){ (function (process,Buffer){ 'use strict'; @@ -2172,7 +2184,7 @@ Random.getPseudoRandomBuffer = function(size) { module.exports = Random; }).call(this,require('_process'),require("buffer").Buffer) -},{"_process":245,"buffer":47,"crypto":51}],11:[function(require,module,exports){ +},{"_process":210,"buffer":113,"crypto":139}],12:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -2488,7 +2500,7 @@ Signature.SIGHASH_ANYONECANPAY = 0x80; module.exports = Signature; }).call(this,require("buffer").Buffer) -},{"../util/buffer":42,"../util/js":43,"../util/preconditions":44,"./bn":6,"buffer":47,"lodash":298}],12:[function(require,module,exports){ +},{"../util/buffer":43,"../util/js":44,"../util/preconditions":45,"./bn":7,"buffer":113,"lodash":194}],13:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -2562,7 +2574,7 @@ Base58.prototype.toString = function() { module.exports = Base58; }).call(this,require("buffer").Buffer) -},{"bs58":274,"buffer":47,"lodash":298}],13:[function(require,module,exports){ +},{"bs58":110,"buffer":113,"lodash":194}],14:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -2661,7 +2673,7 @@ Base58Check.prototype.toString = function() { module.exports = Base58Check; }).call(this,require("buffer").Buffer) -},{"../crypto/hash":8,"./base58":12,"buffer":47,"lodash":298}],14:[function(require,module,exports){ +},{"../crypto/hash":9,"./base58":13,"buffer":113,"lodash":194}],15:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -2863,7 +2875,7 @@ BufferReader.prototype.readReverse = function(len) { module.exports = BufferReader; }).call(this,require("buffer").Buffer) -},{"../crypto/bn":6,"../util/buffer":42,"../util/preconditions":44,"buffer":47,"lodash":298}],15:[function(require,module,exports){ +},{"../crypto/bn":7,"../util/buffer":43,"../util/preconditions":45,"buffer":113,"lodash":194}],16:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -3018,7 +3030,7 @@ BufferWriter.varintBufBN = function(bn) { module.exports = BufferWriter; }).call(this,require("buffer").Buffer) -},{"../util/buffer":42,"assert":45,"buffer":47}],16:[function(require,module,exports){ +},{"../util/buffer":43,"assert":61,"buffer":113}],17:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -3094,7 +3106,7 @@ Varint.prototype.toNumber = function() { module.exports = Varint; }).call(this,require("buffer").Buffer) -},{"../crypto/bn":6,"./bufferreader":14,"./bufferwriter":15,"buffer":47}],17:[function(require,module,exports){ +},{"../crypto/bn":7,"./bufferreader":15,"./bufferwriter":16,"buffer":113}],18:[function(require,module,exports){ 'use strict'; var _ = require('lodash'); @@ -3157,7 +3169,7 @@ module.exports.extend = function(spec) { return traverseNode(bitcore.Error, spec); }; -},{"./spec":18,"lodash":298}],18:[function(require,module,exports){ +},{"./spec":19,"lodash":194}],19:[function(require,module,exports){ 'use strict'; var docsURL = 'http://bitcore.io/'; @@ -3336,7 +3348,7 @@ module.exports = [{ }] }]; -},{}],19:[function(require,module,exports){ +},{}],20:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -3899,7 +3911,7 @@ HDPrivateKey.prototype.inspect = function() { * Returns a plain object with a representation of this private key. * * Fields include: