diff --git a/.coveralls.yml b/.coveralls.yml index 07c493398..f00869bdb 100644 --- a/.coveralls.yml +++ b/.coveralls.yml @@ -1 +1 @@ -repo_token: DvrDb09a8vhPlVf6DT4cGBjcFOi6DfZN1 \ No newline at end of file +repo_token: cE3tYE6ZuuPHFa7OTGpb2wqoqaYJ3SLs3 \ No newline at end of file diff --git a/.jshintrc b/.jshintrc index 9d37e4924..9745de7d7 100644 --- a/.jshintrc +++ b/.jshintrc @@ -23,7 +23,7 @@ "undef": true, "unused": true, "maxparams": 4, - "maxstatements": 15, + "maxstatements": 16, "maxcomplexity": 10, "maxdepth": 3, "maxlen": 120, diff --git a/.travis.yml b/.travis.yml index fbc8be0eb..24e29efa0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,9 +12,8 @@ addons: - libzmq3-dev node_js: - "v0.10.25" - - "v0.12.7" - - "v4" script: + - ./scripts/download - npm run regtest - npm run test - npm run jshint diff --git a/README.md b/README.md index 0df35b5af..570cc2c3f 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,49 @@ -Bitcore Node +Bitcore Node Dash ============ -A Bitcoin full node for building applications and services with Node.js. A node is extensible and can be configured to run additional services. At the minimum a node has an interface to [Bitcoin Core with additional indexing](https://github.com/bitpay/bitcoin/tree/0.12.1-bitcore) for more advanced address queries. Additional services can be enabled to make a node more useful such as exposing new APIs, running a block explorer and wallet service. +A Dash full node for building applications and services with Node.js. A node is extensible and can be configured to run additional services. At the minimum a node has an interface to [Dash Core with additional indexing](https://github.com/snogcel/dash/tree/v0.12.1.x) for more advanced address queries. Additional services can be enabled to make a node more useful such as exposing new APIs, running a block explorer and wallet service. ## Install ```bash -npm install -g bitcore-node -bitcore-node start +npm install -g bitcore-node-dash ``` -Note: For your convenience, we distribute bitcoind binaries for x86_64 Linux and x86_64 Mac OS X. Upon npm install, the binaries for your platform will be downloaded. For more detailed installation instructions, or if you want to compile the project yourself, then please see the Bitcore branch of [Bitcoin Core with additional indexing](https://github.com/bitpay/bitcoin/tree/0.12.1-bitcore). +Installation of bitcore-node-dash can also be performed using a Dockerfile. Please note that this Dockerfile is still under development and should be considered an 'Alpha' version, see [docker-bitcore_insight_dash](https://github.com/moocowmoo/docker-bitcore_insight_dash) for more details. ## Prerequisites -- GNU/Linux x86_32/x86_64, or OSX 64bit *(for bitcoind distributed binaries)* -- Node.js v0.10, v0.12 or v4 +- Dash Core (v0.12.1.x) with support for additional indexing *(see above)* +- Node.js v0.10, v0.12, v4 or v5 - ZeroMQ *(libzmq3-dev for Ubuntu/Debian or zeromq on OSX)* -- ~200GB of disk storage -- ~8GB of RAM +- ~20GB of disk storage +- ~1GB of RAM ## Configuration Bitcore includes a Command Line Interface (CLI) for managing, configuring and interfacing with your Bitcore Node. ```bash -bitcore-node create -d mynode +bitcore-node-dash create -d mynode cd mynode -bitcore-node install -bitcore-node install https://github.com/yourname/helloworld +bitcore-node-dash install +bitcore-node-dash install https://github.com/yourname/helloworld +bitcore-node-dash start ``` -This will create a directory with configuration files for your node and install the necessary dependencies. For more information about (and developing) services, please see the [Service Documentation](docs/services.md). +This will create a directory with configuration files for your node and install the necessary dependencies. + +Please note that [Dash Core with additional indexing](https://github.com/snogcel/dash/tree/v0.12.1.x) must be compiled seperately. Once completed the dashd binary should be placed into the <dash-data-dir> folder specified during node creation. + +For more information about (and developing) services, please see the [Service Documentation](docs/services.md). ## Add-on Services There are several add-on services available to extend the functionality of Bitcore: -- [Insight API](https://github.com/bitpay/insight-api) -- [Insight UI](https://github.com/bitpay/insight-ui) -- [Bitcore Wallet Service](https://github.com/bitpay/bitcore-wallet-service) +- [Insight API Dash](https://github.com/dashpay/insight-api-dash/tree/master) +- [Insight UI Dash](https://github.com/dashpay/insight-ui-dash/tree/master) +- Bitcore Wallet Service (coming soon) ## Documentation @@ -58,7 +62,7 @@ Please send pull requests for bug fixes, code optimization, and ideas for improv ## License -Code released under [the MIT license](https://github.com/bitpay/bitcore-node/blob/master/LICENSE). +Code released under [the MIT license](https://github.com/bitpay/bitcore-node-dash/blob/master/LICENSE). Copyright 2013-2015 BitPay, Inc. diff --git a/bin/bitcore-node b/bin/bitcore-node-dash old mode 100755 new mode 100644 similarity index 100% rename from bin/bitcore-node rename to bin/bitcore-node-dash diff --git a/docs/development.md b/docs/development.md index 39683df6d..edfd3a1b3 100644 --- a/docs/development.md +++ b/docs/development.md @@ -10,11 +10,11 @@ nvm install v4 ## Fork and Download Repositories -To develop bitcore-node: +To develop bitcore-node-dash: ```bash cd ~ -git clone git@github.com:/bitcore-node.git +git clone git@github.com:/bitcore-node-dash.git git clone git@github.com:/bitcore-lib.git ``` @@ -48,13 +48,13 @@ brew install zeromq ```bash cd bitcore-lib npm install -cd ../bitcore-node +cd ../bitcore-node-dash npm install ``` **Note**: If you get a message about not being able to download bitcoin distribution, you'll need to compile bitcoind from source, and setup your configuration to use that version. -We now will setup symlinks in `bitcore-node` *(repeat this for any other modules you're planning on developing)*: +We now will setup symlinks in `bitcore-node-dash` *(repeat this for any other modules you're planning on developing)*: ```bash cd node_modules rm -rf bitcore-lib @@ -78,7 +78,7 @@ npm install mocha -g To run all test suites: ```bash -cd bitcore-node +cd bitcore-node-dash npm run regtest npm run test ``` @@ -102,11 +102,11 @@ cd ~ mkdir devnode cd devnode mkdir node_modules -touch bitcore-node.json +touch bitcore-node-dash.json touch package.json ``` -Edit `bitcore-node.json` with something similar to: +Edit `bitcore-node-dash.json` with something similar to: ```json { "network": "livenet", @@ -136,7 +136,7 @@ Setup symlinks for all of the services and dependencies: ```bash cd node_modules ln -s ~/bitcore-lib -ln -s ~/bitcore-node +ln -s ~/bitcore-node-dash ln -s ~/insight-api ln -s ~/insight-ui ``` @@ -158,5 +158,5 @@ rpcpassword=local321 From within the `devnode` directory with the configuration file, start the node: ```bash -../bitcore-node/bin/bitcore-node start +../bitcore-node-dash/bin/bitcore-node-dash start ``` \ No newline at end of file diff --git a/docs/node.md b/docs/node.md index 77e265bc5..2d002aeb8 100644 --- a/docs/node.md +++ b/docs/node.md @@ -14,7 +14,7 @@ A node represents a collection of services that are loaded together. For more in ```js -var index = require('bitcore-node'); +var index = require('bitcore-node-dash'); var Bitcoin = index.services.Bitcoin; var Node = index.Node; diff --git a/docs/release.md b/docs/release.md index b2aa0a30f..579ee1084 100644 --- a/docs/release.md +++ b/docs/release.md @@ -4,7 +4,7 @@ Binaries for bitcoind are distributed for convenience and built deterministicall ## How to Release -When publishing to npm, the .gitignore file is used to exclude files from the npm publishing process. Be sure that the bitcore-node directory has only the directories and files that you would like to publish to npm. You might need to run the commands below on each platform that you intend to publish (e.g. Mac and Linux). +When publishing to npm, the .gitignore file is used to exclude files from the npm publishing process. Be sure that the bitcore-node-dash directory has only the directories and files that you would like to publish to npm. You might need to run the commands below on each platform that you intend to publish (e.g. Mac and Linux). To make a release, bump the `version` of the `package.json`: diff --git a/docs/scaffold.md b/docs/scaffold.md index 3b0fa7ae2..3af634565 100644 --- a/docs/scaffold.md +++ b/docs/scaffold.md @@ -2,19 +2,19 @@ A collection of functions for creating, managing, starting, stopping and interacting with a Bitcore node. ## Install -This function will add a service to a node by installing the necessary dependencies and modifying the `bitcore-node.json` configuration. +This function will add a service to a node by installing the necessary dependencies and modifying the `bitcore-node-dash.json` configuration. ## Start -This function will load a configuration file `bitcore-node.json` and instantiate and start a node based on the configuration. +This function will load a configuration file `bitcore-node-dash.json` and instantiate and start a node based on the configuration. ## Find Config -This function will recursively find a configuration `bitcore-node.json` file in parent directories and return the result. +This function will recursively find a configuration `bitcore-node-dash.json` file in parent directories and return the result. ## Default Config This function will return a default configuration with the default services based on environment variables, and will default to using the standard `/home/user/.bitcoin` data directory. ## Uninstall -This function will remove a service from a node by uninstalling the necessary dependencies and modifying the `bitcore-node.json` configuration. +This function will remove a service from a node by uninstalling the necessary dependencies and modifying the `bitcore-node-dash.json` configuration. ## Call Method This function will call an API method on a node via the JSON-RPC interface. diff --git a/docs/services.md b/docs/services.md index 02eb1117a..6032e5743 100644 --- a/docs/services.md +++ b/docs/services.md @@ -5,7 +5,7 @@ Bitcore Node has a service module system that can start up additional services t - HTTP routes - Event types to publish and subscribe -The `bitcore-node.json` file describes which services will load for a node: +The `bitcore-node-dash.json` file describes which services will load for a node: ```json { @@ -21,20 +21,20 @@ Services correspond with a Node.js module as described in 'package.json', for ex { "dependencies": { "bitcore-lib": "^0.13.7", - "bitcore-node": "^0.2.0", + "bitcore-node-dash": "^0.2.0", "insight-api": "^3.0.0" } } ``` -_Note:_ If you already have a bitcore-node database, and you want to query data from previous blocks in the blockchain, you will need to reindex. Reindexing right now means deleting your bitcore-node database and resyncing. +_Note:_ If you already have a bitcore-node-dash database, and you want to query data from previous blocks in the blockchain, you will need to reindex. Reindexing right now means deleting your bitcore-node-dash database and resyncing. ## Using Services Programmatically If, instead, you would like to run a custom node, you can include services by including them in your configuration object when initializing a new node. ```js //Require bitcore -var bitcore = require('bitcore-node'); +var bitcore = require('bitcore-node-dash'); //Services var Bitcoin = bitcore.services.Bitcoin; @@ -82,7 +82,7 @@ A new service can be created by inheriting from `Node.Service` and implementing - `Service.prototype.getPublishEvents()` - Describes which events can be subscribed to for this service, useful to subscribe to events over the included web socket API. - `Service.prototype.setupRoutes()` - A service can extend HTTP routes on an express application by implementing this method. -The `package.json` for the service module can either export the `Node.Service` directly, or specify a specific module to load by including `"bitcoreNode": "lib/bitcore-node.js"`. +The `package.json` for the service module can either export the `Node.Service` directly, or specify a specific module to load by including `"bitcoreNode": "lib/bitcore-node-dash.js"`. Please take a look at some of the existing services for implementation specifics. diff --git a/docs/upgrade.md b/docs/upgrade.md index fcc2cba1e..a0578077d 100644 --- a/docs/upgrade.md +++ b/docs/upgrade.md @@ -2,7 +2,7 @@ ## From Bitcore 3.0.0 to 4.0.0 -`bitcore-node@2.1.1` to `bitcore-node@3.0.0` +`bitcore-node-dash@2.1.1` to `bitcore-node-dash@3.0.0` This major upgrade includes changes to indexes, API methods and services. Please review below details before upgrading. @@ -18,7 +18,7 @@ To start reindexing add `reindex=1` during the **first startup only**. ### Configuration Options - The `bitcoin.conf` file in will need to be updated to include additional indexes *(see below)*. -- The `datadir` option is now a part of `bitcoind` spawn configuration, and there is a new option to connect to multiple bitcoind processes (Please see [Bitcoin Service Docs](services/bitcoind.md) for more details). The services `db` and `address` are now a part of the `bitcoind` service. Here is how to update `bitcore-node.json` configuration options: +- The `datadir` option is now a part of `bitcoind` spawn configuration, and there is a new option to connect to multiple bitcoind processes (Please see [Bitcoin Service Docs](services/bitcoind.md) for more details). The services `db` and `address` are now a part of the `bitcoind` service. Here is how to update `bitcore-node-dash.json` configuration options: **Before**: ```json @@ -48,7 +48,7 @@ To start reindexing add `reindex=1` during the **first startup only**. "bitcoind": { "spawn": { "datadir": "/home//.bitcoin", - "exec": "/home//bitcore-node/bin/bitcoind" + "exec": "/home//bitcore-node-dash/bin/bitcoind" } } } @@ -70,7 +70,7 @@ rpcuser= rpcpassword= ``` -**Important**: Once changes have been made you'll also need to add the `reindex=1` option **only for the first startup** to regenerate the indexes. Once this is complete you should be able to remove the `bitcore-node.db` directory with the old indexes. +**Important**: Once changes have been made you'll also need to add the `reindex=1` option **only for the first startup** to regenerate the indexes. Once this is complete you should be able to remove the `bitcore-node-dash.db` directory with the old indexes. ### API and Service Changes - Many API methods that were a part of the `db` and `address` services are now a part of the `bitcoind` service. Please see [Bitcoin Service Docs](services/bitcoind.md) for more details. diff --git a/index.js b/index.js index 1b37813fc..fd459ac04 100644 --- a/index.js +++ b/index.js @@ -24,4 +24,4 @@ module.exports.cli.daemon = require('./lib/cli/daemon'); module.exports.cli.bitcore = require('./lib/cli/bitcore'); module.exports.cli.bitcored = require('./lib/cli/bitcored'); -module.exports.lib = require('bitcore-lib'); +module.exports.lib = require('bitcore-lib-dash'); diff --git a/lib/cli/bitcore.js b/lib/cli/bitcore.js index bcbaa5ee1..796debc66 100644 --- a/lib/cli/bitcore.js +++ b/lib/cli/bitcore.js @@ -6,8 +6,8 @@ function main(parentServicesPath, additionalServices) { var liftoff = new Liftoff({ name: 'bitcore', - moduleName: 'bitcore-node', - configName: 'bitcore-node', + moduleName: 'bitcore-node-dash', + configName: 'bitcore-node-dash', processTitle: 'bitcore' }).on('require', function (name) { console.log('Loading:', name); diff --git a/lib/cli/bitcored.js b/lib/cli/bitcored.js index 4462a8ea6..3671c68af 100644 --- a/lib/cli/bitcored.js +++ b/lib/cli/bitcored.js @@ -6,8 +6,8 @@ function main(parentServicesPath, additionalServices) { var liftoff = new Liftoff({ name: 'bitcored', - moduleName: 'bitcore-node', - configName: 'bitcore-node', + moduleName: 'bitcore-node-dash', + configName: 'bitcore-node-dash', processTitle: 'bitcored' }).on('require', function (name) { console.log('Loading:', name); diff --git a/lib/cli/main.js b/lib/cli/main.js index 5e0e13ccf..ad3788b22 100644 --- a/lib/cli/main.js +++ b/lib/cli/main.js @@ -50,7 +50,7 @@ function main(servicesPath, additionalServices) { .command('start') .description('Start the current node') .option('-c, --config ', 'Specify the directory with Bitcore Node configuration') - .option('-d, --daemon', 'Make bitcore-node a daemon (running in the background)') + .option('-d, --daemon', 'Make bitcore-node-dash a daemon (running in the background)') .action(function(cmd){ if (cmd.config) { cmd.config = path.resolve(process.cwd(), cmd.config); @@ -76,7 +76,7 @@ function main(servicesPath, additionalServices) { .action(function(services){ var configInfo = findConfig(process.cwd()); if (!configInfo) { - throw new Error('Could not find configuration, see `bitcore-node create --help`'); + throw new Error('Could not find configuration, see `bitcore-node-dash create --help`'); } var opts = { path: configInfo.path, @@ -91,8 +91,8 @@ function main(servicesPath, additionalServices) { }).on('--help', function() { console.log(' Examples:'); console.log(); - console.log(' $ bitcore-node add wallet-service'); - console.log(' $ bitcore-node add insight-api'); + console.log(' $ bitcore-node-dash add wallet-service'); + console.log(' $ bitcore-node-dash add insight-api'); console.log(); }); @@ -102,7 +102,7 @@ function main(servicesPath, additionalServices) { .action(function(services){ var configInfo = findConfig(process.cwd()); if (!configInfo) { - throw new Error('Could not find configuration, see `bitcore-node create --help`'); + throw new Error('Could not find configuration, see `bitcore-node-dash create --help`'); } var opts = { path: configInfo.path, @@ -117,8 +117,8 @@ function main(servicesPath, additionalServices) { }).on('--help', function() { console.log(' Examples:'); console.log(); - console.log(' $ bitcore-node remove wallet-service'); - console.log(' $ bitcore-node remove insight-api'); + console.log(' $ bitcore-node-dash remove wallet-service'); + console.log(' $ bitcore-node-dash remove insight-api'); console.log(); }); diff --git a/lib/logger.js b/lib/logger.js index 4084c2ccb..0d0b78f67 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -1,6 +1,6 @@ 'use strict'; -var bitcore = require('bitcore-lib'); +var bitcore = require('bitcore-lib-dash'); var _ = bitcore.deps._; var colors = require('colors/safe'); diff --git a/lib/node.js b/lib/node.js index d7e95c4f4..578bcd5a3 100644 --- a/lib/node.js +++ b/lib/node.js @@ -3,7 +3,7 @@ var util = require('util'); var EventEmitter = require('events').EventEmitter; var async = require('async'); -var bitcore = require('bitcore-lib'); +var bitcore = require('bitcore-lib-dash'); var Networks = bitcore.Networks; var $ = bitcore.util.preconditions; var _ = bitcore.deps._; @@ -183,7 +183,7 @@ Node.prototype.getServiceOrder = function() { Node.prototype._startService = function(serviceInfo, callback) { var self = this; - log.info('Starting ' + serviceInfo.name); + log.info('Starting ' + serviceInfo.name); // TODO: update service name in bitcore-node-dash.json var config; if (serviceInfo.config) { @@ -294,10 +294,10 @@ Node.prototype.stop = function(callback) { services, function(service, next) { if (self.services[service.name]) { - log.info('Stopping ' + service.name); + log.info('Stopping ' + service.name); // TODO: update service name in bitcore-node-dash.json self.services[service.name].stop(next); } else { - log.info('Stopping ' + service.name + ' (not started)'); + log.info('Stopping ' + service.name + ' (not started)'); // TODO: update service name in bitcore-node-dash.json setImmediate(next); } }, diff --git a/lib/scaffold/add.js b/lib/scaffold/add.js index 76f24bdbc..912a7980a 100644 --- a/lib/scaffold/add.js +++ b/lib/scaffold/add.js @@ -4,7 +4,7 @@ var async = require('async'); var fs = require('fs'); var path = require('path'); var spawn = require('child_process').spawn; -var bitcore = require('bitcore-lib'); +var bitcore = require('bitcore-lib-dash'); var utils = require('../utils'); var $ = bitcore.util.preconditions; var _ = bitcore.deps._; @@ -62,7 +62,7 @@ function addService(configDir, service, done) { /** * @param {String} options.cwd - The current working directory - * @param {String} options.dirname - The bitcore-node configuration directory + * @param {String} options.dirname - The bitcore-node-dash configuration directory * @param {Array} options.services - An array of strings of service names * @param {Function} done - A callback function called when finished */ @@ -78,12 +78,12 @@ function add(options, done) { var configPath = options.path; var services = options.services; - var bitcoreConfigPath = path.resolve(configPath, 'bitcore-node.json'); + var bitcoreConfigPath = path.resolve(configPath, 'bitcore-node-dash.json'); var packagePath = path.resolve(configPath, 'package.json'); if (!fs.existsSync(bitcoreConfigPath) || !fs.existsSync(packagePath)) { return done( - new Error('Directory does not have a bitcore-node.json and/or package.json file.') + new Error('Directory does not have a bitcore-node-dash.json and/or package.json file.') ); } @@ -108,7 +108,7 @@ function add(options, done) { oldPackage = updatedPackage; var serviceName = newDependencies[0]; - // add service to bitcore-node.json + // add service to bitcore-node-dash.json addConfig(bitcoreConfigPath, serviceName, next); }); }, done diff --git a/lib/scaffold/create.js b/lib/scaffold/create.js index c521602eb..16cba8764 100644 --- a/lib/scaffold/create.js +++ b/lib/scaffold/create.js @@ -1,7 +1,7 @@ 'use strict'; var spawn = require('child_process').spawn; -var bitcore = require('bitcore-lib'); +var bitcore = require('bitcore-lib-dash'); var async = require('async'); var $ = bitcore.util.preconditions; var _ = bitcore.deps._; @@ -19,8 +19,8 @@ var BASE_PACKAGE = { license: 'MIT', readme: 'README.md', dependencies: { - 'bitcore-lib': '^' + bitcore.version, - 'bitcore-node': version + 'bitcore-lib-dash': '^' + bitcore.version, + 'bitcore-node-dash': version } }; @@ -61,7 +61,7 @@ function createConfigDirectory(options, configDir, isGlobal, done) { var configJSON = JSON.stringify(config, null, 2); var packageJSON = JSON.stringify(BASE_PACKAGE, null, 2); try { - fs.writeFileSync(configDir + '/bitcore-node.json', configJSON); + fs.writeFileSync(configDir + '/bitcore-node-dash.json', configJSON); if (!isGlobal) { fs.writeFileSync(configDir + '/package.json', packageJSON); } @@ -103,7 +103,7 @@ function create(options, done) { async.series([ function(next) { - // Setup the the bitcore-node directory and configuration + // Setup the the bitcore-node-dash directory and configuration if (!fs.existsSync(absConfigDir)) { var createOptions = { network: options.network, diff --git a/lib/scaffold/default-base-config.js b/lib/scaffold/default-base-config.js index 1f584b55a..37fced3c9 100644 --- a/lib/scaffold/default-base-config.js +++ b/lib/scaffold/default-base-config.js @@ -3,7 +3,7 @@ var path = require('path'); /** - * Will return the path and default bitcore-node configuration on environment variables + * Will return the path and default bitcore-node-dash configuration on environment variables * or default locations. * @param {Object} options * @param {String} options.network - "testnet" or "livenet" @@ -13,6 +13,9 @@ function getDefaultBaseConfig(options) { if (!options) { options = {}; } + + var datadir = options.datadir || path.resolve(process.env.HOME, '.dash'); + return { path: process.cwd(), config: { @@ -22,8 +25,8 @@ function getDefaultBaseConfig(options) { servicesConfig: { bitcoind: { spawn: { - datadir: options.datadir || path.resolve(process.env.HOME, '.bitcoin'), - exec: path.resolve(__dirname, '../../bin/bitcoind') + datadir: datadir, + exec: path.resolve(__dirname, datadir, 'dashd') } } } diff --git a/lib/scaffold/default-config.js b/lib/scaffold/default-config.js index 7075a7fce..7241f5e98 100644 --- a/lib/scaffold/default-config.js +++ b/lib/scaffold/default-config.js @@ -5,7 +5,7 @@ var mkdirp = require('mkdirp'); var fs = require('fs'); /** - * Will return the path and default bitcore-node configuration. It will search for the + * Will return the path and default bitcore-node-dash configuration. It will search for the * configuration file in the "~/.bitcore" directory, and if it doesn't exist, it will create one * based on default settings. * @param {Object} [options] @@ -18,7 +18,7 @@ function getDefaultConfig(options) { } var defaultPath = path.resolve(process.env.HOME, './.bitcore'); - var defaultConfigFile = path.resolve(defaultPath, './bitcore-node.json'); + var defaultConfigFile = path.resolve(defaultPath, './bitcore-node-dash.json'); if (!fs.existsSync(defaultPath)) { mkdirp.sync(defaultPath); @@ -38,7 +38,7 @@ function getDefaultConfig(options) { bitcoind: { spawn: { datadir: path.resolve(defaultPath, './data'), - exec: path.resolve(__dirname, '../../bin/bitcoind') + exec: path.resolve(__dirname, defaultPath, './data/dashd') } } } diff --git a/lib/scaffold/find-config.js b/lib/scaffold/find-config.js index a4306e8b1..8c10e677b 100644 --- a/lib/scaffold/find-config.js +++ b/lib/scaffold/find-config.js @@ -1,6 +1,6 @@ 'use strict'; -var bitcore = require('bitcore-lib'); +var bitcore = require('bitcore-lib-dash'); var $ = bitcore.util.preconditions; var _ = bitcore.deps._; var path = require('path'); @@ -8,14 +8,14 @@ var fs = require('fs'); var utils = require('../utils'); /** - * Will return the path and bitcore-node configuration + * Will return the path and bitcore-node-dash configuration * @param {String} cwd - The absolute path to the current working directory */ function findConfig(cwd) { $.checkArgument(_.isString(cwd), 'Argument should be a string'); $.checkArgument(utils.isAbsolutePath(cwd), 'Argument should be an absolute path'); var directory = String(cwd); - while (!fs.existsSync(path.resolve(directory, 'bitcore-node.json'))) { + while (!fs.existsSync(path.resolve(directory, 'bitcore-node-dash.json'))) { directory = path.resolve(directory, '../'); if (directory === '/') { return false; @@ -23,7 +23,7 @@ function findConfig(cwd) { } return { path: directory, - config: require(path.resolve(directory, 'bitcore-node.json')) + config: require(path.resolve(directory, 'bitcore-node-dash.json')) }; } diff --git a/lib/scaffold/remove.js b/lib/scaffold/remove.js index 6d866d6ff..45624e8f7 100644 --- a/lib/scaffold/remove.js +++ b/lib/scaffold/remove.js @@ -5,13 +5,13 @@ var fs = require('fs'); var npm = require('npm'); var path = require('path'); var spawn = require('child_process').spawn; -var bitcore = require('bitcore-lib'); +var bitcore = require('bitcore-lib-dash'); var $ = bitcore.util.preconditions; var _ = bitcore.deps._; var utils = require('../utils'); /** - * Will remove a service from bitcore-node.json + * Will remove a service from bitcore-node-dash.json * @param {String} configFilePath - The absolute path to the configuration file * @param {String} service - The name of the module * @param {Function} done @@ -100,9 +100,9 @@ function removeService(configDir, service, done) { } /** - * Will remove the Node.js service and from the bitcore-node configuration. + * Will remove the Node.js service and from the bitcore-node-dash configuration. * @param {String} options.cwd - The current working directory - * @param {String} options.dirname - The bitcore-node configuration directory + * @param {String} options.dirname - The bitcore-node-dash configuration directory * @param {Array} options.services - An array of strings of service names * @param {Function} done - A callback function called when finished */ @@ -118,12 +118,12 @@ function remove(options, done) { var configPath = options.path; var services = options.services; - var bitcoreConfigPath = path.resolve(configPath, 'bitcore-node.json'); + var bitcoreConfigPath = path.resolve(configPath, 'bitcore-node-dash.json'); var packagePath = path.resolve(configPath, 'package.json'); if (!fs.existsSync(bitcoreConfigPath) || !fs.existsSync(packagePath)) { return done( - new Error('Directory does not have a bitcore-node.json and/or package.json file.') + new Error('Directory does not have a bitcore-node-dash.json and/or package.json file.') ); } @@ -135,7 +135,7 @@ function remove(options, done) { if (err) { return next(err); } - // remove service to bitcore-node.json + // remove service to bitcore-node-dash.json removeConfig(bitcoreConfigPath, service, next); }); }, done diff --git a/lib/scaffold/start.js b/lib/scaffold/start.js index e86545759..6f31afde6 100644 --- a/lib/scaffold/start.js +++ b/lib/scaffold/start.js @@ -3,7 +3,7 @@ var path = require('path'); var BitcoreNode = require('../node'); var index = require('../'); -var bitcore = require('bitcore-lib'); +var bitcore = require('bitcore-lib-dash'); var _ = bitcore.deps._; var log = index.log; var shuttingDown = false; @@ -23,9 +23,9 @@ function checkConfigVersion2(fullConfig) { console.warn('\nConfiguration file is not compatible with this version. \n' + 'A reindex for bitcoind is necessary for this upgrade with the "reindex=1" bitcoin.conf option. \n' + - 'There are changes necessary in both bitcoin.conf and bitcore-node.json. \n\n' + + 'There are changes necessary in both bitcoin.conf and bitcore-node-dash.json. \n\n' + 'To upgrade please see the details below and documentation at: \n' + - 'https://github.com/bitpay/bitcore-node/blob/bitcoind/docs/upgrade.md \n'); + 'https://github.com/bitpay/bitcore-node-dash/blob/bitcoind/docs/upgrade.md \n'); if (!datadirUndefined) { console.warn('Please remove "datadir" and add it to the config at ' + fullConfig.path + ' with:'); @@ -34,7 +34,7 @@ function checkConfigVersion2(fullConfig) { bitcoind: { spawn: { datadir: fullConfig.datadir, - exec: path.resolve(__dirname, '../../bin/bitcoind') + exec: path.resolve(__dirname, '../../bin/dashd') } } } @@ -58,7 +58,7 @@ function checkConfigVersion2(fullConfig) { * @param {Object} options * @param {Object} options.servicesPath - The path to the location of service modules * @param {String} options.path - The absolute path of the configuration file - * @param {Object} options.config - The parsed bitcore-node.json configuration file + * @param {Object} options.config - The parsed bitcore-node-dash.json configuration file * @param {Array} options.config.services - An array of services names. * @param {Object} options.config.servicesConfig - Parameters to pass to each service * @param {String} options.config.network - 'livenet', 'testnet' or 'regtest @@ -76,7 +76,7 @@ function start(options) { servicesPath = options.path; // defaults to the same directory } - fullConfig.path = path.resolve(options.path, './bitcore-node.json'); + fullConfig.path = path.resolve(options.path, './bitcore-node-dash.json'); if (checkConfigVersion2(fullConfig)) { process.exit(1); @@ -135,7 +135,7 @@ function checkService(service) { */ function loadModule(req, service) { try { - // first try in the built-in bitcore-node services directory + // first try in the built-in bitcore-node-dash services directory service.module = req(path.resolve(__dirname, '../services/' + service.name)); } catch(e) { diff --git a/lib/service.js b/lib/service.js index 08d0ef5a2..17243ebca 100644 --- a/lib/service.js +++ b/lib/service.js @@ -68,7 +68,7 @@ Service.prototype.start = function(done) { }; /** - * Function to be called when bitcore-node is stopped + * Function to be called when bitcore-node-dash is stopped */ Service.prototype.stop = function(done) { setImmediate(done); diff --git a/lib/services/bitcoind.js b/lib/services/bitcoind.js index 8774498e2..d97fcac87 100644 --- a/lib/services/bitcoind.js +++ b/lib/services/bitcoind.js @@ -5,7 +5,7 @@ var path = require('path'); var spawn = require('child_process').spawn; var util = require('util'); var mkdirp = require('mkdirp'); -var bitcore = require('bitcore-lib'); +var bitcore = require('bitcore-lib-dash'); var zmq = require('zmq'); var async = require('async'); var LRU = require('lru-cache'); @@ -21,9 +21,9 @@ var utils = require('../utils'); var Service = require('../service'); /** - * Provides a friendly event driven API to bitcoind in Node.js. Manages starting and - * stopping bitcoind as a child process for application support, as well as connecting - * to multiple bitcoind processes for server infrastructure. Results are cached in an + * Provides a friendly event driven API to dashd in Node.js. Manages starting and + * stopping dashd as a child process for application support, as well as connecting + * to multiple dashd processes for server infrastructure. Results are cached in an * LRU cache for improved performance and methods added for common queries. * * @param {Object} options @@ -45,13 +45,14 @@ function Bitcoin(options) { // event subscribers this.subscriptions = {}; this.subscriptions.rawtransaction = []; + this.subscriptions.transactionlock = []; this.subscriptions.hashblock = []; this.subscriptions.address = {}; // set initial settings this._initDefaults(options); - // available bitcoind nodes + // available dashd nodes this._initClients(); // for testing purposes @@ -85,9 +86,10 @@ Bitcoin.DEFAULT_CONFIG_SETTINGS = { timestampindex: 1, spentindex: 1, zmqpubrawtx: 'tcp://127.0.0.1:28332', + zmqpubrawtxlock: 'tcp://127.0.0.1:28332', zmqpubhashblock: 'tcp://127.0.0.1:28332', rpcallowip: '127.0.0.1', - rpcuser: 'bitcoin', + rpcuser: 'dash', rpcpassword: 'local321', uacomment: 'bitcore' }; @@ -132,6 +134,7 @@ Bitcoin.prototype._initCaches = function() { this.rawBlockCache = LRU(72); this.blockHeaderCache = LRU(288); this.zmqKnownTransactions = LRU(5000); + this.zmqKnownTransactionLocks = LRU(5000); this.zmqKnownBlocks = LRU(50); this.lastTip = 0; this.lastTipTimeout = false; @@ -193,6 +196,12 @@ Bitcoin.prototype.getPublishEvents = function() { subscribe: this.subscribe.bind(this, 'rawtransaction'), unsubscribe: this.unsubscribe.bind(this, 'rawtransaction') }, + { + name: 'bitcoind/transactionlock', + scope: this, + subscribe: this.subscribe.bind(this, 'transactionlock'), + unsubscribe: this.unsubscribe.bind(this, 'transactionlock') + }, { name: 'bitcoind/hashblock', scope: this, @@ -331,14 +340,14 @@ Bitcoin.prototype._expandRelativeDatadir = function() { Bitcoin.prototype._loadSpawnConfiguration = function(node) { /* jshint maxstatements: 25 */ - $.checkArgument(this.options.spawn, 'Please specify "spawn" in bitcoind config options'); - $.checkArgument(this.options.spawn.datadir, 'Please specify "spawn.datadir" in bitcoind config options'); - $.checkArgument(this.options.spawn.exec, 'Please specify "spawn.exec" in bitcoind config options'); + $.checkArgument(this.options.spawn, 'Please specify "spawn" in dashd config options'); + $.checkArgument(this.options.spawn.datadir, 'Please specify "spawn.datadir" in dashd config options'); + $.checkArgument(this.options.spawn.exec, 'Please specify "spawn.exec" in dashd config options'); this._expandRelativeDatadir(); var spawnOptions = this.options.spawn; - var configPath = path.resolve(spawnOptions.datadir, './bitcoin.conf'); + var configPath = path.resolve(spawnOptions.datadir, './dash.conf'); log.info('Using bitcoin config file:', configPath); @@ -374,40 +383,46 @@ Bitcoin.prototype._loadSpawnConfiguration = function(node) { Bitcoin.prototype._checkConfigIndexes = function(spawnConfig, node) { $.checkState( spawnConfig.txindex && spawnConfig.txindex === 1, - '"txindex" option is required in order to use transaction query features of bitcore-node. ' + + '"txindex" option is required in order to use transaction query features of bitcore-node-dash. ' + 'Please add "txindex=1" to your configuration and reindex an existing database if ' + 'necessary with reindex=1' ); $.checkState( spawnConfig.addressindex && spawnConfig.addressindex === 1, - '"addressindex" option is required in order to use address query features of bitcore-node. ' + + '"addressindex" option is required in order to use address query features of bitcore-node-dash. ' + 'Please add "addressindex=1" to your configuration and reindex an existing database if ' + 'necessary with reindex=1' ); $.checkState( spawnConfig.spentindex && spawnConfig.spentindex === 1, - '"spentindex" option is required in order to use spent info query features of bitcore-node. ' + + '"spentindex" option is required in order to use spent info query features of bitcore-node-dash. ' + 'Please add "spentindex=1" to your configuration and reindex an existing database if ' + 'necessary with reindex=1' ); $.checkState( spawnConfig.server && spawnConfig.server === 1, - '"server" option is required to communicate to bitcoind from bitcore. ' + + '"server" option is required to communicate to dashd from bitcore. ' + 'Please add "server=1" to your configuration and restart' ); $.checkState( spawnConfig.zmqpubrawtx, - '"zmqpubrawtx" option is required to get event updates from bitcoind. ' + + '"zmqpubrawtx" option is required to get event updates from dashd. ' + 'Please add "zmqpubrawtx=tcp://127.0.0.1:" to your configuration and restart' ); + $.checkState( + spawnConfig.zmqpubrawtxlock, + '"zmqpubrawtxlock" option is required to get transaction locks from dashd. ' + + 'Please add "zmqpubrawtxlock=tcp://127.0.0.1:" to your configuration and restart' + ); + $.checkState( spawnConfig.zmqpubhashblock, - '"zmqpubhashblock" option is required to get event updates from bitcoind. ' + + '"zmqpubhashblock" option is required to get event updates from dashd. ' + 'Please add "zmqpubhashblock=tcp://127.0.0.1:" to your configuration and restart' ); @@ -417,10 +432,10 @@ Bitcoin.prototype._checkConfigIndexes = function(spawnConfig, node) { ); if (spawnConfig.reindex && spawnConfig.reindex === 1) { - log.warn('Reindex option is currently enabled. This means that bitcoind is undergoing a reindex. ' + + log.warn('Reindex option is currently enabled. This means that dashd is undergoing a reindex. ' + 'The reindex flag will start the index from beginning every time the node is started, so it ' + 'should be removed after the reindex has been initiated. Once the reindex is complete, the rest ' + - 'of bitcore-node services will start.'); + 'of bitcore-node-dash services will start.'); node._reindex = true; } }; @@ -477,7 +492,7 @@ Bitcoin.prototype._initChain = function(callback) { } self.genesisBuffer = blockBuffer; self.emit('ready'); - log.info('Bitcoin Daemon Ready'); + log.info('Dash Daemon Ready'); callback(); }); }); @@ -488,10 +503,10 @@ Bitcoin.prototype._initChain = function(callback) { Bitcoin.prototype._getDefaultConf = function() { var networkOptions = { - rpcport: 8332 + rpcport: 9998 }; if (this.node.network === bitcore.Networks.testnet) { - networkOptions.rpcport = 18332; + networkOptions.rpcport = 19998; } return networkOptions; }; @@ -499,9 +514,9 @@ Bitcoin.prototype._getDefaultConf = function() { Bitcoin.prototype._getNetworkConfigPath = function() { var networkPath; if (this.node.network === bitcore.Networks.testnet) { - networkPath = 'testnet3/bitcoin.conf'; + networkPath = 'testnet3/dash.conf'; if (this.node.network.regtestEnabled) { - networkPath = 'regtest/bitcoin.conf'; + networkPath = 'regtest/dash.conf'; } } return networkPath; @@ -581,7 +596,7 @@ Bitcoin.prototype._updateTip = function(node, message) { if (Math.round(percentage) >= 100) { self.emit('synced', self.height); } - log.info('Bitcoin Height:', self.height, 'Percentage:', percentage.toFixed(2)); + log.info('Dash Height:', self.height, 'Percentage:', percentage.toFixed(2)); } }); } @@ -651,6 +666,22 @@ Bitcoin.prototype._zmqTransactionHandler = function(node, message) { } }; +Bitcoin.prototype._zmqTransactionLockHandler = function(node, message) { + var self = this; + var hash = bitcore.crypto.Hash.sha256sha256(message); + var id = hash.toString('binary'); + if (!self.zmqKnownTransactionLocks.get(id)) { + self.zmqKnownTransactionLocks.set(id, true); + self.emit('txlock', message); + + // Notify transaction lock subscribers + for (var i = 0; i < this.subscriptions.transactionlock.length; i++) { + this.subscriptions.transactionlock[i].emit('bitcoind/transactionlock', message.toString('hex')); + } + + } +}; + Bitcoin.prototype._checkSyncedAndSubscribeZmqEvents = function(node) { var self = this; var interval; @@ -707,9 +738,12 @@ Bitcoin.prototype._subscribeZmqEvents = function(node) { var self = this; node.zmqSubSocket.subscribe('hashblock'); node.zmqSubSocket.subscribe('rawtx'); + node.zmqSubSocket.subscribe('rawtxlock'); node.zmqSubSocket.on('message', function(topic, message) { var topicString = topic.toString('utf8'); - if (topicString === 'rawtx') { + if (topicString === 'rawtxlock') { + self._zmqTransactionLockHandler(node, message); + } else if (topicString === 'rawtx') { self._zmqTransactionHandler(node, message); } else if (topicString === 'hashblock') { self._zmqBlockHandler(node, message); @@ -759,7 +793,7 @@ Bitcoin.prototype._checkReindex = function(node, callback) { } var percentSynced = response.result.verificationprogress * 100; - log.info('Bitcoin Core Daemon Reindex Percentage: ' + percentSynced.toFixed(2)); + log.info('Dash Core Daemon Reindex Percentage: ' + percentSynced.toFixed(2)); if (Math.round(percentSynced) >= 100) { node._reindex = false; @@ -796,7 +830,7 @@ Bitcoin.prototype._loadTipFromNode = function(node, callback) { Bitcoin.prototype._stopSpawnedBitcoin = function(callback) { var self = this; var spawnOptions = this.options.spawn; - var pidPath = spawnOptions.datadir + '/bitcoind.pid'; + var pidPath = spawnOptions.datadir + '/dashd.pid'; function stopProcess() { fs.readFile(pidPath, 'utf8', function(err, pid) { @@ -812,11 +846,11 @@ Bitcoin.prototype._stopSpawnedBitcoin = function(callback) { return callback(null); } try { - log.warn('Stopping existing spawned bitcoin process with pid: ' + pid); + log.warn('Stopping existing spawned dash process with pid: ' + pid); self._process.kill(pid, 'SIGINT'); } catch(err) { if (err && err.code === 'ESRCH') { - log.warn('Unclean bitcoin process shutdown, process not found with pid: ' + pid); + log.warn('Unclean dash process shutdown, process not found with pid: ' + pid); return callback(null); } else if(err) { return callback(err); @@ -858,7 +892,7 @@ Bitcoin.prototype._spawnChildProcess = function(callback) { return callback(err); } - log.info('Starting bitcoin process'); + log.info('Starting dash process'); self.spawn.process = spawn(self.spawn.exec, options, {stdio: 'inherit'}); self.spawn.process.on('error', function(err) { @@ -867,14 +901,14 @@ Bitcoin.prototype._spawnChildProcess = function(callback) { self.spawn.process.once('exit', function(code) { if (!self.node.stopping) { - log.warn('Bitcoin process unexpectedly exited with code:', code); - log.warn('Restarting bitcoin child process in ' + self.spawnRestartTime + 'ms'); + log.warn('Dash process unexpectedly exited with code:', code); + log.warn('Restarting dash child process in ' + self.spawnRestartTime + 'ms'); setTimeout(function() { self._spawnChildProcess(function(err) { if (err) { return self.emit('error', err); } - log.warn('Bitcoin process restarted'); + log.warn('Dash process restarted'); }); }, self.spawnRestartTime); } @@ -903,7 +937,7 @@ Bitcoin.prototype._spawnChildProcess = function(callback) { return callback(err); } if (exitShutdown) { - return callback(new Error('Stopping while trying to spawn bitcoind.')); + return callback(new Error('Stopping while trying to spawn dashd.')); } self._initZmqSubSocket(node, self.spawn.config.zmqpubrawtx); @@ -949,7 +983,7 @@ Bitcoin.prototype._connectProcess = function(config, callback) { return callback(err); } if (exitShutdown) { - return callback(new Error('Stopping while trying to connect to bitcoind.')); + return callback(new Error('Stopping while trying to connect to dashd.')); } self._initZmqSubSocket(node, config.zmqpubrawtx); @@ -1338,7 +1372,7 @@ Bitcoin.prototype._getAddressDetailsForTransaction = function(transaction, addre /** * Will expand into a detailed transaction from a txid - * @param {Object} txid - A bitcoin transaction id + * @param {Object} txid - A dash transaction id * @param {Function} callback */ Bitcoin.prototype._getAddressDetailedTransaction = function(txid, options, next) { @@ -1471,7 +1505,7 @@ Bitcoin.prototype.getAddressSummary = function(addressArg, options, callback) { if ((toArg - fromArg) > self.maxTxids) { return callback(new Error( - '"from" (' + fromArg + ') and "to" (' + toArg + ') range should be less than or equal to ' + + '"from" (' + fromArg + ') and "to" (' + toArg + ') range should be less than or equal to ' + self.maxTxids )); } @@ -2080,7 +2114,7 @@ Bitcoin.prototype.stop = function(callback) { if (!exited) { exited = true; if (code !== 0) { - var error = new Error('bitcoind spawned process exited with status code: ' + code); + var error = new Error('dashd spawned process exited with status code: ' + code); error.code = code; return callback(error); } else { @@ -2092,7 +2126,7 @@ Bitcoin.prototype.stop = function(callback) { setTimeout(function() { if (!exited) { exited = true; - return callback(new Error('bitcoind process did not exit')); + return callback(new Error('dashd process did not exit')); } }, this.shutdownTimeout).unref(); } else { diff --git a/lib/services/web.js b/lib/services/web.js index 850accb0f..d5b616a1c 100644 --- a/lib/services/web.js +++ b/lib/services/web.js @@ -9,7 +9,7 @@ var socketio = require('socket.io'); var inherits = require('util').inherits; var BaseService = require('../service'); -var bitcore = require('bitcore-lib'); +var bitcore = require('bitcore-lib-dash'); var _ = bitcore.deps._; var index = require('../'); var log = index.log; diff --git a/package.json b/package.json index 3ca74ae62..0f9a7b592 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { - "name": "bitcore-node", + "name": "bitcore-node-dash", "description": "Full node with extended capabilities using Bitcore and Bitcoin Core", "author": "BitPay ", "version": "3.1.2", "main": "./index.js", - "repository": "git://github.com/bitpay/bitcore-node.git", - "homepage": "https://github.com/bitpay/bitcore-node", + "repository": "git://github.com/dashpay/bitcore-node-dash.git", + "homepage": "https://github.com/dashpay/bitcore-node-dash", "bugs": { - "url": "https://github.com/bitpay/bitcore-node/issues" + "url": "https://github.com/dashpay/bitcore-node-dash/issues" }, "contributors": [ { @@ -27,8 +27,7 @@ } ], "bin": { - "bitcore-node": "./bin/bitcore-node", - "bitcoind": "./bin/bitcoind" + "bitcore-node-dash": "./bin/bitcore-node-dash" }, "scripts": { "preinstall": "./scripts/download", @@ -46,7 +45,7 @@ "dependencies": { "async": "^1.3.0", "bitcoind-rpc": "^0.6.0", - "bitcore-lib": "^0.13.13", + "bitcore-lib-dash": "^0.13.19", "body-parser": "^1.13.3", "colors": "^1.1.2", "commander": "^2.8.1", @@ -68,7 +67,7 @@ }, "devDependencies": { "benchmark": "1.0.0", - "bitcore-p2p": "^1.1.0", + "bitcore-p2p-dash": "^1.1.2", "chai": "^3.5.0", "coveralls": "^2.11.9", "istanbul": "^0.4.3", diff --git a/regtest/bitcoind.js b/regtest/bitcoind.js index 13346416c..91fe0b74c 100644 --- a/regtest/bitcoind.js +++ b/regtest/bitcoind.js @@ -7,7 +7,7 @@ var index = require('..'); var log = index.log; var chai = require('chai'); -var bitcore = require('bitcore-lib'); +var bitcore = require('bitcore-lib-dash'); var BN = bitcore.crypto.BN; var async = require('async'); var rimraf = require('rimraf'); @@ -46,7 +46,7 @@ describe('Bitcoind Functionality', function() { bitcoind = require('../').services.Bitcoin({ spawn: { datadir: datadir, - exec: path.resolve(__dirname, '../bin/bitcoind') + exec: path.resolve(__dirname, process.env.HOME, './.bitcore/data/dashd') }, node: { network: regtestNetwork, @@ -439,7 +439,7 @@ describe('Bitcoind Functionality', function() { tx.hex.should.be.a('string'); tx.locktime.should.equal(0); tx.feeSatoshis.should.equal(0); - tx.outputSatoshis.should.equal(50 * 1e8); + tx.outputSatoshis.should.equal(500 * 1e8); tx.inputSatoshis.should.equal(0); tx.inputs.length.should.equal(1); tx.outputs.length.should.equal(1); @@ -449,7 +449,7 @@ describe('Bitcoind Functionality', function() { should.equal(tx.inputs[0].scriptAsm, null); should.equal(tx.inputs[0].address, null); should.equal(tx.inputs[0].satoshis, null); - tx.outputs[0].satoshis.should.equal(50 * 1e8); + tx.outputs[0].satoshis.should.equal(500 * 1e8); tx.outputs[0].script.should.be.a('string'); tx.outputs[0].scriptAsm.should.be.a('string'); tx.outputs[0].spentTxId.should.be.a('string'); diff --git a/regtest/cluster.js b/regtest/cluster.js index c8ab87549..37d0c37b4 100644 --- a/regtest/cluster.js +++ b/regtest/cluster.js @@ -6,7 +6,7 @@ var spawn = require('child_process').spawn; var BitcoinRPC = require('bitcoind-rpc'); var rimraf = require('rimraf'); -var bitcore = require('bitcore-lib'); +var bitcore = require('bitcore-lib-dash'); var chai = require('chai'); var should = chai.should(); @@ -19,11 +19,11 @@ var BitcoinService = index.services.Bitcoin; describe('Bitcoin Cluster', function() { var node; var daemons = []; - var execPath = path.resolve(__dirname, '../bin/bitcoind'); + var execPath = path.resolve(__dirname, process.env.HOME, './.bitcore/data/dashd') var nodesConf = [ { datadir: path.resolve(__dirname, './data/node1'), - conf: path.resolve(__dirname, './data/node1/bitcoin.conf'), + conf: path.resolve(__dirname, './data/node1/dash.conf'), rpcuser: 'bitcoin', rpcpassword: 'local321', rpcport: 30521, @@ -32,7 +32,7 @@ describe('Bitcoin Cluster', function() { }, { datadir: path.resolve(__dirname, './data/node2'), - conf: path.resolve(__dirname, './data/node2/bitcoin.conf'), + conf: path.resolve(__dirname, './data/node2/dash.conf'), rpcuser: 'bitcoin', rpcpassword: 'local321', rpcport: 30522, @@ -41,7 +41,7 @@ describe('Bitcoin Cluster', function() { }, { datadir: path.resolve(__dirname, './data/node3'), - conf: path.resolve(__dirname, './data/node3/bitcoin.conf'), + conf: path.resolve(__dirname, './data/node3/dash.conf'), rpcuser: 'bitcoin', rpcpassword: 'local321', rpcport: 30523, @@ -51,7 +51,7 @@ describe('Bitcoin Cluster', function() { ]; before(function(done) { - log.info('Starting 3 bitcoind daemons'); + log.info('Starting 3 dashd daemons'); this.timeout(60000); async.each(nodesConf, function(nodeConf, next) { var opts = [ diff --git a/regtest/data/bitcoin.conf b/regtest/data/dash.conf similarity index 85% rename from regtest/data/bitcoin.conf rename to regtest/data/dash.conf index 95cf0afb0..87b5653d5 100644 --- a/regtest/data/bitcoin.conf +++ b/regtest/data/dash.conf @@ -5,6 +5,7 @@ addressindex=1 timestampindex=1 spentindex=1 zmqpubrawtx=tcp://127.0.0.1:30332 +zmqpubrawtxlock=tcp://127.0.0.1:30332 zmqpubhashblock=tcp://127.0.0.1:30332 rpcallowip=127.0.0.1 rpcport=30331 diff --git a/regtest/data/node1/bitcoin.conf b/regtest/data/node1/dash.conf similarity index 88% rename from regtest/data/node1/bitcoin.conf rename to regtest/data/node1/dash.conf index 54ed2aecb..7d6dc2dba 100644 --- a/regtest/data/node1/bitcoin.conf +++ b/regtest/data/node1/dash.conf @@ -9,6 +9,7 @@ addnode=127.0.0.1:30433 port=30431 rpcport=30521 zmqpubrawtx=tcp://127.0.0.1:30611 +zmqpubrawtxlock=tcp://127.0.0.1:30611 zmqpubhashblock=tcp://127.0.0.1:30611 rpcallowip=127.0.0.1 rpcuser=bitcoin diff --git a/regtest/data/node2/bitcoin.conf b/regtest/data/node2/dash.conf similarity index 88% rename from regtest/data/node2/bitcoin.conf rename to regtest/data/node2/dash.conf index bcd09fe66..ee3b4c755 100644 --- a/regtest/data/node2/bitcoin.conf +++ b/regtest/data/node2/dash.conf @@ -9,6 +9,7 @@ addnode=127.0.0.1:30433 port=30432 rpcport=30522 zmqpubrawtx=tcp://127.0.0.1:30622 +zmqpubrawtxlock=tcp://127.0.0.1:30622 zmqpubhashblock=tcp://127.0.0.1:30622 rpcallowip=127.0.0.1 rpcuser=bitcoin diff --git a/regtest/data/node3/bitcoin.conf b/regtest/data/node3/dash.conf similarity index 88% rename from regtest/data/node3/bitcoin.conf rename to regtest/data/node3/dash.conf index 8be13ef30..0d868fa68 100644 --- a/regtest/data/node3/bitcoin.conf +++ b/regtest/data/node3/dash.conf @@ -9,6 +9,7 @@ addnode=127.0.0.1:30432 port=30433 rpcport=30523 zmqpubrawtx=tcp://127.0.0.1:30633 +zmqpubrawtxlock=tcp://127.0.0.1:30633 zmqpubhashblock=tcp://127.0.0.1:30633 rpcallowip=127.0.0.1 rpcuser=bitcoin diff --git a/regtest/node.js b/regtest/node.js index 2e8539abd..1585e2fbf 100644 --- a/regtest/node.js +++ b/regtest/node.js @@ -9,7 +9,7 @@ var log = index.log; log.debug = function() {}; var chai = require('chai'); -var bitcore = require('bitcore-lib'); +var bitcore = require('bitcore-lib-dash'); var rimraf = require('rimraf'); var node; @@ -32,7 +32,7 @@ describe('Node Functionality', function() { var regtest; before(function(done) { - this.timeout(20000); + this.timeout(200000); var datadir = __dirname + '/data'; @@ -53,7 +53,7 @@ describe('Node Functionality', function() { config: { spawn: { datadir: datadir, - exec: path.resolve(__dirname, '../bin/bitcoind') + exec: path.resolve(__dirname, process.env.HOME, './.bitcore/data/dashd') } } } @@ -105,7 +105,7 @@ describe('Node Functionality', function() { }); after(function(done) { - this.timeout(20000); + this.timeout(200000); node.stop(function(err, result) { if(err) { throw err; @@ -147,7 +147,7 @@ describe('Node Functionality', function() { var address; var unspentOutput; before(function(done) { - this.timeout(10000); + this.timeout(100000); address = testKey.toAddress(regtest).toString(); var startHeight = node.services.bitcoind.height; node.services.bitcoind.on('tip', function(height) { @@ -229,7 +229,7 @@ describe('Node Functionality', function() { }); describe('History', function() { - this.timeout(20000); + this.timeout(200000); var testKey2; var address2; @@ -663,8 +663,8 @@ describe('Node Functionality', function() { var memAddress = bitcore.PrivateKey().toAddress(node.network).toString(); var tx = new Transaction(); tx.from(unspentOutput); - tx.to(memAddress, unspentOutput.satoshis - 1000); - tx.fee(1000); + tx.to(memAddress, unspentOutput.satoshis - 2000); + tx.fee(2000); tx.sign(testKey); node.services.bitcoind.sendTransaction(tx.serialize(), function(err, hash) { @@ -684,7 +684,7 @@ describe('Node Functionality', function() { }); describe('Orphaned Transactions', function() { - this.timeout(8000); + this.timeout(80000); var orphanedTransaction; before(function(done) { diff --git a/regtest/p2p.js b/regtest/p2p.js index 4af160bd7..b91717869 100644 --- a/regtest/p2p.js +++ b/regtest/p2p.js @@ -6,11 +6,11 @@ var path = require('path'); var index = require('..'); var log = index.log; -var p2p = require('bitcore-p2p'); +var p2p = require('bitcore-p2p-dash'); var Peer = p2p.Peer; var Messages = p2p.Messages; var chai = require('chai'); -var bitcore = require('bitcore-lib'); +var bitcore = require('bitcore-lib-dash'); var Transaction = bitcore.Transaction; var BN = bitcore.crypto.BN; var async = require('async'); @@ -52,7 +52,7 @@ describe('P2P Functionality', function() { bitcoind = require('../').services.Bitcoin({ spawn: { datadir: datadir, - exec: path.resolve(__dirname, '../bin/bitcoind') + exec: path.resolve(__dirname, process.env.HOME, './.bitcore/data/dashd') }, node: { network: bitcore.Networks.testnet @@ -63,7 +63,7 @@ describe('P2P Functionality', function() { log.error('error="%s"', err.message); }); - log.info('Waiting for Bitcoin Core to initialize...'); + log.info('Waiting for Dash Core to initialize...'); bitcoind.start(function(err) { if (err) { @@ -82,7 +82,7 @@ describe('P2P Functionality', function() { peer = new Peer({ host: '127.0.0.1', - port: '18444', + port: '19994', network: regtestNetwork }); diff --git a/scripts/download b/scripts/download index 40bdfb480..ce3204d52 100755 --- a/scripts/download +++ b/scripts/download @@ -2,34 +2,36 @@ set -e -root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." +root_dir="${HOME}/.bitcore" platform=`uname -a | awk '{print tolower($1)}'` arch=`uname -m` version="0.12.1" -url="https://github.com/bitpay/bitcoin/releases/download" -tag="v0.12.1-bitcore-2" +url="https://dashpay.atlassian.net/builds/browse/DASHL-DEV-627/artifact/JOB1/gitian-linux-dash-dist/" if [ "${platform}" == "linux" ]; then if [ "${arch}" == "x86_64" ]; then - tarball_name="bitcoin-${version}-linux64.tar.gz" + tarball_name="dash-${version}-linux64.tar.gz" elif [ "${arch}" == "x86_32" ]; then - tarball_name="bitcoin-${version}-linux32.tar.gz" + tarball_name="dash-${version}-linux32.tar.gz" fi elif [ "${platform}" == "darwin" ]; then - tarball_name="bitcoin-${version}-osx64.tar.gz" + tarball_name="dash-${version}-osx64.tar.gz" else - echo "Bitcoin binary distribution not available for platform and architecture" + echo "Dash binary distribution not available for platform and architecture" exit -1 fi -binary_url="${url}/${tag}/${tarball_name}" -shasums_url="${url}/${tag}/SHA256SUMS.asc" +binary_url="${url}/${tarball_name}" +shasums_url="${url}/SHA256SUMS.asc" download_bitcoind() { - cd "${root_dir}/bin" + mkdir -p "${root_dir}" + mkdir -p "${root_dir}/data" - echo "Downloading bitcoin: ${binary_url}" + cd "${root_dir}/data" + + echo "Downloading dash: ${binary_url}" is_curl=true if hash curl 2>/dev/null; then @@ -48,20 +50,20 @@ download_bitcoind() { wget $shasums_url fi if test -e "${tarball_name}"; then - echo "Unpacking bitcoin distribution" + echo "Unpacking dash distribution" tar -xvzf $tarball_name if test $? -eq 0; then - ln -sf "bitcoin-${version}/bin/bitcoind" + ln -sf "dash-${version}/bin/dashd" return; fi fi fi - echo "Bitcoin binary distribution could not be downloaded" + echo "Dash binary distribution could not be downloaded" exit -1 } verify_download() { - echo "Verifying signatures of bitcoin download" + echo "Verifying signatures of dash download" gpg --verify "${root_dir}/bin/SHA256SUMS.asc" if hash shasum 2>/dev/null; then diff --git a/test/data/bitcoin.conf b/test/data/bitcoin.conf index 353387fac..b26a646e7 100644 --- a/test/data/bitcoin.conf +++ b/test/data/bitcoin.conf @@ -12,6 +12,7 @@ dbcache=8192 checkblocks=144 maxuploadtarget=1024 zmqpubrawtx=tcp://127.0.0.1:28332 +zmqpubrawtxlock=tcp://127.0.0.1:28332 zmqpubhashblock=tcp://127.0.0.1:28332 port=20000 diff --git a/test/data/default.bitcoin.conf b/test/data/default.bitcoin.conf index 3665db542..3ece4569b 100644 --- a/test/data/default.bitcoin.conf +++ b/test/data/default.bitcoin.conf @@ -5,8 +5,9 @@ addressindex=1 timestampindex=1 spentindex=1 zmqpubrawtx=tcp://127.0.0.1:28332 +zmqpubrawtxlock=tcp://127.0.0.1:28332 zmqpubhashblock=tcp://127.0.0.1:28332 rpcallowip=127.0.0.1 -rpcuser=bitcoin +rpcuser=dash rpcpassword=local321 uacomment=bitcore diff --git a/test/node.unit.js b/test/node.unit.js index 624ccaf80..83d5668fa 100644 --- a/test/node.unit.js +++ b/test/node.unit.js @@ -2,7 +2,7 @@ var should = require('chai').should(); var sinon = require('sinon'); -var bitcore = require('bitcore-lib'); +var bitcore = require('bitcore-lib-dash'); var Networks = bitcore.Networks; var proxyquire = require('proxyquire'); var util = require('util'); diff --git a/test/scaffold/add.integration.js b/test/scaffold/add.integration.js index 21ef4ad7a..687d0c489 100644 --- a/test/scaffold/add.integration.js +++ b/test/scaffold/add.integration.js @@ -25,7 +25,7 @@ describe('#add', function() { throw err; } fs.writeFile( - testDir + '/s0/s1/bitcore-node.json', + testDir + '/s0/s1/bitcore-node-dash.json', JSON.stringify(startConfig), function(err) { if (err) { @@ -90,12 +90,12 @@ describe('#add', function() { }); }); - it('will update bitcore-node.json services', function(done) { + it('will update bitcore-node-dash.json services', function(done) { var callCount = 0; var oldPackage = { dependencies: { - 'bitcore-lib': '^v0.13.7', - 'bitcore-node': '^v0.2.0' + 'bitcore-lib-dash': '^v0.13.17', + 'bitcore-node-dash': '^v0.2.0' } }; var spawn = sinon.stub().returns({ @@ -130,7 +130,7 @@ describe('#add', function() { services: ['a', 'b', 'c'] }, function(err) { should.not.exist(err); - var configPath = path.resolve(testDir, 's0/s1/bitcore-node.json'); + var configPath = path.resolve(testDir, 's0/s1/bitcore-node-dash.json'); var config = JSON.parse(fs.readFileSync(configPath)); config.services.should.deep.equal(['a','b','c']); done(); diff --git a/test/scaffold/create.integration.js b/test/scaffold/create.integration.js index f2c61523f..6f0635fc9 100644 --- a/test/scaffold/create.integration.js +++ b/test/scaffold/create.integration.js @@ -64,7 +64,7 @@ describe('#create', function() { throw err; } - var configPath = testDir + '/mynode/bitcore-node.json'; + var configPath = testDir + '/mynode/bitcore-node-dash.json'; var packagePath = testDir + '/mynode/package.json'; should.equal(fs.existsSync(configPath), true); diff --git a/test/scaffold/default-base-config.integration.js b/test/scaffold/default-base-config.integration.js index b622c742f..23a46b2a1 100644 --- a/test/scaffold/default-base-config.integration.js +++ b/test/scaffold/default-base-config.integration.js @@ -14,8 +14,8 @@ describe('#defaultBaseConfig', function() { info.config.port.should.equal(3001); info.config.services.should.deep.equal(['bitcoind', 'web']); var bitcoind = info.config.servicesConfig.bitcoind; - bitcoind.spawn.datadir.should.equal(home + '/.bitcoin'); - bitcoind.spawn.exec.should.equal(path.resolve(__dirname, '../../bin/bitcoind')); + bitcoind.spawn.datadir.should.equal(home + '/.dash'); + bitcoind.spawn.exec.should.equal(path.resolve(__dirname, process.env.HOME, './.dash/dashd')); }); it('be able to specify a network', function() { var info = defaultBaseConfig({network: 'testnet'}); diff --git a/test/scaffold/default-config.integration.js b/test/scaffold/default-config.integration.js index 83e674e5a..e2d2a920c 100644 --- a/test/scaffold/default-config.integration.js +++ b/test/scaffold/default-config.integration.js @@ -6,7 +6,7 @@ var sinon = require('sinon'); var proxyquire = require('proxyquire'); describe('#defaultConfig', function() { - var expectedExecPath = path.resolve(__dirname, '../../bin/bitcoind'); + var expectedExecPath = path.resolve(__dirname, process.env.HOME, './.bitcore/data/dashd'); it('will return expected configuration', function() { var config = JSON.stringify({ @@ -29,7 +29,7 @@ describe('#defaultConfig', function() { fs: { existsSync: sinon.stub().returns(false), writeFileSync: function(path, data) { - path.should.equal(process.env.HOME + '/.bitcore/bitcore-node.json'); + path.should.equal(process.env.HOME + '/.bitcore/bitcore-node-dash.json'); data.should.equal(config); }, readFileSync: function() { @@ -74,7 +74,7 @@ describe('#defaultConfig', function() { fs: { existsSync: sinon.stub().returns(false), writeFileSync: function(path, data) { - path.should.equal(process.env.HOME + '/.bitcore/bitcore-node.json'); + path.should.equal(process.env.HOME + '/.bitcore/bitcore-node-dash.json'); data.should.equal(config); }, readFileSync: function() { diff --git a/test/scaffold/find-config.integration.js b/test/scaffold/find-config.integration.js index c1032736b..afdb3b96d 100644 --- a/test/scaffold/find-config.integration.js +++ b/test/scaffold/find-config.integration.js @@ -23,7 +23,7 @@ describe('#findConfig', function() { throw err; } fs.writeFile( - testDir + '/p2/bitcore-node.json', + testDir + '/p2/bitcore-node-dash.json', JSON.stringify(expectedConfig), function() { mkdirp(testDir + '/e0', function(err) { diff --git a/test/scaffold/remove.integration.js b/test/scaffold/remove.integration.js index 1607ed64e..ba2acfc20 100644 --- a/test/scaffold/remove.integration.js +++ b/test/scaffold/remove.integration.js @@ -25,7 +25,7 @@ describe('#remove', function() { throw err; } fs.writeFile( - testDir + '/s0/s1/bitcore-node.json', + testDir + '/s0/s1/bitcore-node-dash.json', JSON.stringify(startConfig), function(err) { if (err) { @@ -64,7 +64,7 @@ describe('#remove', function() { }); }); - it('will update bitcore-node.json services', function(done) { + it('will update bitcore-node-dash.json services', function(done) { var spawn = sinon.stub().returns({ stdout: { on: sinon.stub() @@ -92,7 +92,7 @@ describe('#remove', function() { services: ['b'] }, function(err) { should.not.exist(err); - var configPath = path.resolve(testDir, 's0/s1/bitcore-node.json'); + var configPath = path.resolve(testDir, 's0/s1/bitcore-node-dash.json'); var config = JSON.parse(fs.readFileSync(configPath)); config.services.should.deep.equal(['a', 'c']); done(); diff --git a/test/scaffold/start.integration.js b/test/scaffold/start.integration.js index 887572b6e..7120b5b00 100644 --- a/test/scaffold/start.integration.js +++ b/test/scaffold/start.integration.js @@ -19,7 +19,7 @@ describe('#start', function() { describe('will dynamically create a node from a configuration', function() { - it('require each bitcore-node service with default config', function(done) { + it('require each bitcore-node-dash service with default config', function(done) { var node; var TestNode = function(options) { options.services[0].should.deep.equal({ @@ -87,7 +87,7 @@ describe('#start', function() { done(); }); }); - it('require each bitcore-node service with explicit config', function(done) { + it('require each bitcore-node-dash service with explicit config', function(done) { var node; var TestNode = function(options) { options.services[0].should.deep.equal({ diff --git a/test/services/bitcoind.unit.js b/test/services/bitcoind.unit.js index 57819d126..8a04fb88b 100644 --- a/test/services/bitcoind.unit.js +++ b/test/services/bitcoind.unit.js @@ -6,7 +6,7 @@ var path = require('path'); var EventEmitter = require('events').EventEmitter; var should = require('chai').should(); var crypto = require('crypto'); -var bitcore = require('bitcore-lib'); +var bitcore = require('bitcore-lib-dash'); var _ = bitcore.deps._; var sinon = require('sinon'); var proxyquire = require('proxyquire'); @@ -78,7 +78,8 @@ describe('Bitcoin Service', function() { bitcoind.subscriptions.should.deep.equal({ address: {}, rawtransaction: [], - hashblock: [] + hashblock: [], + transactionlock: [] }); }); }); @@ -113,19 +114,23 @@ describe('Bitcoin Service', function() { var bitcoind = new BitcoinService(baseConfig); var events = bitcoind.getPublishEvents(); should.exist(events); - events.length.should.equal(3); + events.length.should.equal(4); events[0].name.should.equal('bitcoind/rawtransaction'); events[0].scope.should.equal(bitcoind); events[0].subscribe.should.be.a('function'); events[0].unsubscribe.should.be.a('function'); - events[1].name.should.equal('bitcoind/hashblock'); + events[1].name.should.equal('bitcoind/transactionlock'); events[1].scope.should.equal(bitcoind); events[1].subscribe.should.be.a('function'); events[1].unsubscribe.should.be.a('function'); - events[2].name.should.equal('bitcoind/addresstxid'); + events[2].name.should.equal('bitcoind/hashblock'); events[2].scope.should.equal(bitcoind); events[2].subscribe.should.be.a('function'); events[2].unsubscribe.should.be.a('function'); + events[3].name.should.equal('bitcoind/addresstxid'); + events[3].scope.should.equal(bitcoind); + events[3].subscribe.should.be.a('function'); + events[3].unsubscribe.should.be.a('function'); }); it('will call subscribe/unsubscribe with correct args', function() { var bitcoind = new BitcoinService(baseConfig); @@ -142,12 +147,20 @@ describe('Bitcoin Service', function() { bitcoind.unsubscribe.args[0][1].should.equal('test'); events[1].subscribe('test'); - bitcoind.subscribe.args[1][0].should.equal('hashblock'); + bitcoind.subscribe.args[1][0].should.equal('transactionlock'); bitcoind.subscribe.args[1][1].should.equal('test'); events[1].unsubscribe('test'); - bitcoind.unsubscribe.args[1][0].should.equal('hashblock'); + bitcoind.unsubscribe.args[1][0].should.equal('transactionlock'); bitcoind.unsubscribe.args[1][1].should.equal('test'); + + events[2].subscribe('test'); + bitcoind.subscribe.args[2][0].should.equal('hashblock'); + bitcoind.subscribe.args[2][1].should.equal('test'); + + events[2].unsubscribe('test'); + bitcoind.unsubscribe.args[2][0].should.equal('hashblock'); + bitcoind.unsubscribe.args[2][1].should.equal('test'); }); }); @@ -228,25 +241,25 @@ describe('Bitcoin Service', function() { it('will add a valid address', function() { var bitcoind = new BitcoinService(baseConfig); var emitter = new EventEmitter(); - bitcoind.subscribeAddress(emitter, ['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br']); - should.exist(bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br']); + bitcoind.subscribeAddress(emitter, ['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi']); + should.exist(bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi']); }); it('will handle multiple address subscribers', function() { var bitcoind = new BitcoinService(baseConfig); var emitter1 = new EventEmitter(); var emitter2 = new EventEmitter(); - bitcoind.subscribeAddress(emitter1, ['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br']); - bitcoind.subscribeAddress(emitter2, ['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br']); - should.exist(bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br']); - bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'].length.should.equal(2); + bitcoind.subscribeAddress(emitter1, ['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi']); + bitcoind.subscribeAddress(emitter2, ['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi']); + should.exist(bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi']); + bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'].length.should.equal(2); }); it('will not add the same emitter twice', function() { var bitcoind = new BitcoinService(baseConfig); var emitter1 = new EventEmitter(); - bitcoind.subscribeAddress(emitter1, ['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br']); - bitcoind.subscribeAddress(emitter1, ['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br']); - should.exist(bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br']); - bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'].length.should.equal(1); + bitcoind.subscribeAddress(emitter1, ['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi']); + bitcoind.subscribeAddress(emitter1, ['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi']); + should.exist(bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi']); + bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'].length.should.equal(1); }); }); @@ -262,58 +275,58 @@ describe('Bitcoin Service', function() { var bitcoind = new BitcoinService(baseConfig); var emitter1 = new EventEmitter(); var emitter2 = new EventEmitter(); - bitcoind.subscribeAddress(emitter1, ['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br']); - bitcoind.subscribeAddress(emitter2, ['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br']); - should.exist(bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br']); - bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'].length.should.equal(2); - bitcoind.unsubscribeAddress(emitter1, ['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br']); - bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'].length.should.equal(1); + bitcoind.subscribeAddress(emitter1, ['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi']); + bitcoind.subscribeAddress(emitter2, ['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi']); + should.exist(bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi']); + bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'].length.should.equal(2); + bitcoind.unsubscribeAddress(emitter1, ['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi']); + bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'].length.should.equal(1); }); it('will unsubscribe subscriptions for an emitter', function() { var bitcoind = new BitcoinService(baseConfig); var emitter1 = new EventEmitter(); var emitter2 = new EventEmitter(); - bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'] = [emitter1, emitter2]; + bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'] = [emitter1, emitter2]; bitcoind.unsubscribeAddress(emitter1); - bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'].length.should.equal(1); + bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'].length.should.equal(1); }); it('will NOT unsubscribe subscription with missing address', function() { var bitcoind = new BitcoinService(baseConfig); var emitter1 = new EventEmitter(); var emitter2 = new EventEmitter(); - bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'] = [emitter1, emitter2]; - bitcoind.unsubscribeAddress(emitter1, ['1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo']); - bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'].length.should.equal(2); + bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'] = [emitter1, emitter2]; + bitcoind.unsubscribeAddress(emitter1, ['XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs']); + bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'].length.should.equal(2); }); it('will NOT unsubscribe subscription with missing emitter', function() { var bitcoind = new BitcoinService(baseConfig); var emitter1 = new EventEmitter(); var emitter2 = new EventEmitter(); - bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'] = [emitter2]; - bitcoind.unsubscribeAddress(emitter1, ['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br']); - bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'].length.should.equal(1); - bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'][0].should.equal(emitter2); + bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'] = [emitter2]; + bitcoind.unsubscribeAddress(emitter1, ['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi']); + bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'].length.should.equal(1); + bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'][0].should.equal(emitter2); }); it('will remove empty addresses', function() { var bitcoind = new BitcoinService(baseConfig); var emitter1 = new EventEmitter(); var emitter2 = new EventEmitter(); - bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'] = [emitter1, emitter2]; - bitcoind.unsubscribeAddress(emitter1, ['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br']); - bitcoind.unsubscribeAddress(emitter2, ['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br']); - should.not.exist(bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br']); + bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'] = [emitter1, emitter2]; + bitcoind.unsubscribeAddress(emitter1, ['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi']); + bitcoind.unsubscribeAddress(emitter2, ['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi']); + should.not.exist(bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi']); }); it('will unsubscribe emitter for all addresses', function() { var bitcoind = new BitcoinService(baseConfig); var emitter1 = new EventEmitter(); var emitter2 = new EventEmitter(); - bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'] = [emitter1, emitter2]; - bitcoind.subscriptions.address['1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'] = [emitter1, emitter2]; + bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'] = [emitter1, emitter2]; + bitcoind.subscriptions.address['XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'] = [emitter1, emitter2]; sinon.spy(bitcoind, 'unsubscribeAddressAll'); bitcoind.unsubscribeAddress(emitter1); bitcoind.unsubscribeAddressAll.callCount.should.equal(1); - bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'].length.should.equal(1); - bitcoind.subscriptions.address['1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'].length.should.equal(1); + bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'].length.should.equal(1); + bitcoind.subscriptions.address['XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'].length.should.equal(1); }); }); @@ -329,15 +342,15 @@ describe('Bitcoin Service', function() { var bitcoind = new BitcoinService(baseConfig); var emitter1 = new EventEmitter(); var emitter2 = new EventEmitter(); - bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'] = [emitter1, emitter2]; - bitcoind.subscriptions.address['1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'] = [emitter1, emitter2]; + bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'] = [emitter1, emitter2]; + bitcoind.subscriptions.address['XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'] = [emitter1, emitter2]; bitcoind.subscriptions.address['mgY65WSfEmsyYaYPQaXhmXMeBhwp4EcsQW'] = [emitter2]; - bitcoind.subscriptions.address['3CMNFxN1oHBc4R1EpboAL5yzHGgE611Xou'] = [emitter1]; + bitcoind.subscriptions.address['7d5169eBcGHF4BYC6DTffTyeCpWbrZnNgz'] = [emitter1]; bitcoind.unsubscribeAddress(emitter1); - bitcoind.subscriptions.address['2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'].length.should.equal(1); - bitcoind.subscriptions.address['1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'].length.should.equal(1); + bitcoind.subscriptions.address['8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'].length.should.equal(1); + bitcoind.subscriptions.address['XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'].length.should.equal(1); bitcoind.subscriptions.address['mgY65WSfEmsyYaYPQaXhmXMeBhwp4EcsQW'].length.should.equal(1); - should.not.exist(bitcoind.subscriptions.address['3CMNFxN1oHBc4R1EpboAL5yzHGgE611Xou']); + should.not.exist(bitcoind.subscriptions.address['7d5169eBcGHF4BYC6DTffTyeCpWbrZnNgz']); }); }); @@ -390,7 +403,8 @@ describe('Bitcoin Service', function() { upnp: 0, whitelist: '127.0.0.1', zmqpubhashblock: 'tcp://127.0.0.1:28332', - zmqpubrawtx: 'tcp://127.0.0.1:28332' + zmqpubrawtx: 'tcp://127.0.0.1:28332', + zmqpubrawtxlock: 'tcp://127.0.0.1:28332' }); }); it('will expand relative datadir to absolute path', function() { @@ -489,6 +503,7 @@ describe('Bitcoin Service', function() { server: 1, zmqpubrawtx: 1, zmqpubhashblock: 1, + zmqpubrawtxlock: 1, reindex: 1 }; var node = {}; @@ -505,6 +520,7 @@ describe('Bitcoin Service', function() { server: 1, zmqpubrawtx: 'tcp://127.0.0.1:28332', zmqpubhashblock: 'tcp://127.0.0.1:28331', + zmqpubrawtxlock: 'tcp://127.0.0.1:28332', reindex: 1 }; var node = {}; @@ -769,7 +785,7 @@ describe('Bitcoin Service', function() { } }; var bitcoind = new BitcoinService(config); - bitcoind._getDefaultConf().rpcport.should.equal(8332); + bitcoind._getDefaultConf().rpcport.should.equal(9998); }); it('will get default rpc port for testnet', function() { var config = { @@ -782,7 +798,7 @@ describe('Bitcoin Service', function() { } }; var bitcoind = new BitcoinService(config); - bitcoind._getDefaultConf().rpcport.should.equal(18332); + bitcoind._getDefaultConf().rpcport.should.equal(19998); }); it('will get default rpc port for regtest', function() { bitcore.Networks.enableRegtest(); @@ -796,7 +812,7 @@ describe('Bitcoin Service', function() { } }; var bitcoind = new BitcoinService(config); - bitcoind._getDefaultConf().rpcport.should.equal(18332); + bitcoind._getDefaultConf().rpcport.should.equal(19998); }); }); @@ -829,7 +845,7 @@ describe('Bitcoin Service', function() { } }; var bitcoind = new BitcoinService(config); - bitcoind._getNetworkConfigPath().should.equal('testnet3/bitcoin.conf'); + bitcoind._getNetworkConfigPath().should.equal('testnet3/dash.conf'); }); it('will get default rpc port for regtest', function() { bitcore.Networks.enableRegtest(); @@ -843,7 +859,7 @@ describe('Bitcoin Service', function() { } }; var bitcoind = new BitcoinService(config); - bitcoind._getNetworkConfigPath().should.equal('regtest/bitcoin.conf'); + bitcoind._getNetworkConfigPath().should.equal('regtest/dash.conf'); }); }); @@ -1088,10 +1104,10 @@ describe('Bitcoin Service', function() { describe('#_getAddressesFromTransaction', function() { it('will get results using bitcore.Transaction', function() { var bitcoind = new BitcoinService(baseConfig); - var wif = 'L2Gkw3kKJ6N24QcDuH4XDqt9cTqsKTVNDGz1CRZhk9cq4auDUbJy'; + var wif = 'XGLgPK8gbmzU7jcbw34Pj55AXV7SmG6carKuiwtu4WtvTjyTbpwX'; var privkey = bitcore.PrivateKey.fromWIF(wif); var inputAddress = privkey.toAddress(bitcore.Networks.testnet); - var outputAddress = bitcore.Address('2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'); + var outputAddress = bitcore.Address('8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'); var tx = bitcore.Transaction(); tx.from({ txid: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b', @@ -1139,7 +1155,7 @@ describe('Bitcoin Service', function() { it('will return unique values', function() { var bitcoind = new BitcoinService(baseConfig); var tx = bitcore.Transaction(); - var address = bitcore.Address('2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'); + var address = bitcore.Address('8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'); tx.addOutput(bitcore.Transaction.Output({ script: bitcore.Script(address), satoshis: 5000000000 @@ -1156,7 +1172,7 @@ describe('Bitcoin Service', function() { describe('#_notifyAddressTxidSubscribers', function() { it('will emit event if matching addresses', function(done) { var bitcoind = new BitcoinService(baseConfig); - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind._getAddressesFromTransaction = sinon.stub().returns([address]); var emitter = new EventEmitter(); bitcoind.subscriptions.address[address] = [emitter]; @@ -1173,7 +1189,7 @@ describe('Bitcoin Service', function() { }); it('will NOT emit event without matching addresses', function() { var bitcoind = new BitcoinService(baseConfig); - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind._getAddressesFromTransaction = sinon.stub().returns([address]); var emitter = new EventEmitter(); var txid = '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0'; @@ -1353,9 +1369,10 @@ describe('Bitcoin Service', function() { } }; bitcoind._subscribeZmqEvents(node); - node.zmqSubSocket.subscribe.callCount.should.equal(2); + node.zmqSubSocket.subscribe.callCount.should.equal(3); node.zmqSubSocket.subscribe.args[0][0].should.equal('hashblock'); node.zmqSubSocket.subscribe.args[1][0].should.equal('rawtx'); + node.zmqSubSocket.subscribe.args[2][0].should.equal('rawtxlock'); }); it('will call relevant handler for rawtx topics', function(done) { var bitcoind = new BitcoinService(baseConfig); @@ -1756,6 +1773,7 @@ describe('Bitcoin Service', function() { bitcoind.spawn.config.rpcuser = 'bitcoin'; bitcoind.spawn.config.rpcpassword = 'password'; bitcoind.spawn.config.zmqpubrawtx = 'tcp://127.0.0.1:30001'; + bitcoind.spawn.config.zmqpubrawtxlock = 'tcp://127.0.0.1:30001'; bitcoind._loadTipFromNode = sinon.stub().callsArgWith(1, null); bitcoind._initZmqSubSocket = sinon.stub(); @@ -1931,6 +1949,7 @@ describe('Bitcoin Service', function() { bitcoind.spawn.config.rpcuser = 'bitcoin'; bitcoind.spawn.config.rpcpassword = 'password'; bitcoind.spawn.config.zmqpubrawtx = 'tcp://127.0.0.1:30001'; + bitcoind.spawn.config.zmqpubrawtxlock = 'tcp://127.0.0.1:30001'; bitcoind._loadTipFromNode = sinon.stub().callsArgWith(1, new Error('test')); bitcoind._spawnChildProcess(function(err) { bitcoind._loadTipFromNode.callCount.should.equal(60); @@ -1961,6 +1980,7 @@ describe('Bitcoin Service', function() { bitcoind.spawn.config.rpcuser = 'bitcoin'; bitcoind.spawn.config.rpcpassword = 'password'; bitcoind.spawn.config.zmqpubrawtx = 'tcp://127.0.0.1:30001'; + bitcoind.spawn.config.zmqpubrawtxlock = 'tcp://127.0.0.1:30001'; bitcoind._loadTipFromNode = sinon.stub().callsArgWith(1, null); bitcoind._initZmqSubSocket = sinon.stub(); @@ -2216,7 +2236,7 @@ describe('Bitcoin Service', function() { getAddressBalance: sinon.stub().callsArgWith(1, {code: -1, message: 'Test error'}) } }); - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; var options = {}; bitcoind.getAddressBalance(address, options, function(err) { err.should.be.instanceof(Error); @@ -2236,7 +2256,7 @@ describe('Bitcoin Service', function() { getAddressBalance: getAddressBalance } }); - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; var options = {}; bitcoind.getAddressBalance(address, options, function(err, data) { if (err) { @@ -2268,7 +2288,7 @@ describe('Bitcoin Service', function() { var options = { queryMempool: false }; - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressUnspentOutputs(address, options, function(err) { should.exist(err); err.should.be.instanceof(errors.RPCError); @@ -2279,7 +2299,7 @@ describe('Bitcoin Service', function() { var bitcoind = new BitcoinService(baseConfig); var expectedUtxos = [ { - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', txid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', outputIndex: 1, script: '76a914f399b4b8894f1153b96fce29f05e6e116eb4c21788ac', @@ -2297,7 +2317,7 @@ describe('Bitcoin Service', function() { var options = { queryMempool: false }; - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressUnspentOutputs(address, options, function(err, utxos) { if (err) { return done(err); @@ -2311,7 +2331,7 @@ describe('Bitcoin Service', function() { var bitcoind = new BitcoinService(baseConfig); var expectedUtxos = [ { - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', txid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', outputIndex: 1, script: '76a914f399b4b8894f1153b96fce29f05e6e116eb4c21788ac', @@ -2330,7 +2350,7 @@ describe('Bitcoin Service', function() { var options = { queryMempool: false }; - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressUnspentOutputs(address, options, function(err, utxos) { if (err) { return done(err); @@ -2354,7 +2374,7 @@ describe('Bitcoin Service', function() { { txid: 'e9dcf22807db77ac0276b03cc2d3a8b03c4837db8ac6650501ef45af1c807cce', satoshis: -7679241, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 0, timestamp: 1461342707725, prevtxid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', @@ -2363,14 +2383,14 @@ describe('Bitcoin Service', function() { { txid: 'f637384e9f81f18767ea50e00bce58fc9848b6588a1130529eebba22a410155f', satoshis: 100000, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 0, timestamp: 1461342833133 }, { txid: 'f71bccef3a8f5609c7f016154922adbfe0194a96fb17a798c24077c18d0a9345', satoshis: 400000, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 1, timestamp: 1461342954813 } @@ -2378,7 +2398,7 @@ describe('Bitcoin Service', function() { var bitcoind = new BitcoinService(baseConfig); var confirmedUtxos = [ { - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', txid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', outputIndex: 1, script: '76a914f399b4b8894f1153b96fce29f05e6e116eb4c21788ac', @@ -2388,7 +2408,7 @@ describe('Bitcoin Service', function() { ]; var expectedUtxos = [ { - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', outputIndex: 1, satoshis: 400000, script: '76a914809dc14496f99b6deb722cf46d89d22f4beb8efd88ac', @@ -2396,7 +2416,7 @@ describe('Bitcoin Service', function() { txid: 'f71bccef3a8f5609c7f016154922adbfe0194a96fb17a798c24077c18d0a9345' }, { - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', outputIndex: 0, satoshis: 100000, script: '76a914809dc14496f99b6deb722cf46d89d22f4beb8efd88ac', @@ -2417,7 +2437,7 @@ describe('Bitcoin Service', function() { var options = { queryMempool: true }; - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressUnspentOutputs(address, options, function(err, utxos) { if (err) { return done(err); @@ -2432,7 +2452,7 @@ describe('Bitcoin Service', function() { { txid: 'e9dcf22807db77ac0276b03cc2d3a8b03c4837db8ac6650501ef45af1c807cce', satoshis: -7679241, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 0, timestamp: 1461342707725, prevtxid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', @@ -2441,7 +2461,7 @@ describe('Bitcoin Service', function() { { txid: 'e9dcf22807db77ac0276b03cc2d3a8b03c4837db8ac6650501ef45af1c807cce', satoshis: -7679241, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 1, timestamp: 1461342707725, prevtxid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', @@ -2451,7 +2471,7 @@ describe('Bitcoin Service', function() { var bitcoind = new BitcoinService(baseConfig); var confirmedUtxos = [ { - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', txid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', outputIndex: 1, script: '76a914f399b4b8894f1153b96fce29f05e6e116eb4c21788ac', @@ -2459,7 +2479,7 @@ describe('Bitcoin Service', function() { height: 207111 }, { - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', txid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', outputIndex: 2, script: '76a914f399b4b8894f1153b96fce29f05e6e116eb4c21788ac', @@ -2480,7 +2500,7 @@ describe('Bitcoin Service', function() { var options = { queryMempool: true }; - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressUnspentOutputs(address, options, function(err, utxos) { if (err) { return done(err); @@ -2494,7 +2514,7 @@ describe('Bitcoin Service', function() { { txid: 'e9dcf22807db77ac0276b03cc2d3a8b03c4837db8ac6650501ef45af1c807cce', satoshis: -7679241, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 0, timestamp: 1461342707725, prevtxid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', @@ -2503,7 +2523,7 @@ describe('Bitcoin Service', function() { { txid: 'e9dcf22807db77ac0276b03cc2d3a8b03c4837db8ac6650501ef45af1c807cce', satoshis: -7679241, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 0, timestamp: 1461342707725, prevtxid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', @@ -2512,7 +2532,7 @@ describe('Bitcoin Service', function() { { txid: 'e9dcf22807db77ac0276b03cc2d3a8b03c4837db8ac6650501ef45af1c807cce', satoshis: -7679241, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 1, timestamp: 1461342707725, prevtxid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', @@ -2521,7 +2541,7 @@ describe('Bitcoin Service', function() { { txid: 'e9dcf22807db77ac0276b03cc2d3a8b03c4837db8ac6650501ef45af1c807cce', satoshis: 100000, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 1, script: '76a914809dc14496f99b6deb722cf46d89d22f4beb8efd88ac', timestamp: 1461342833133 @@ -2530,7 +2550,7 @@ describe('Bitcoin Service', function() { var bitcoind = new BitcoinService(baseConfig); var confirmedUtxos = [ { - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', txid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', outputIndex: 0, script: '76a914f399b4b8894f1153b96fce29f05e6e116eb4c21788ac', @@ -2538,7 +2558,7 @@ describe('Bitcoin Service', function() { height: 207111 }, { - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', txid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', outputIndex: 1, script: '76a914f399b4b8894f1153b96fce29f05e6e116eb4c21788ac', @@ -2546,7 +2566,7 @@ describe('Bitcoin Service', function() { height: 207111 }, { - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', txid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', outputIndex: 2, script: '76a914f399b4b8894f1153b96fce29f05e6e116eb4c21788ac', @@ -2567,7 +2587,7 @@ describe('Bitcoin Service', function() { var options = { queryMempool: true }; - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressUnspentOutputs(address, options, function(err, utxos) { if (err) { return done(err); @@ -2581,28 +2601,28 @@ describe('Bitcoin Service', function() { { txid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', satoshis: 7679241, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 0, timestamp: 1461342707724 }, { txid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', satoshis: 7679241, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 1, timestamp: 1461342707724 }, { txid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', satoshis: 7679241, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', timestamp: 1461342707724, index: 2, }, { txid: 'e9dcf22807db77ac0276b03cc2d3a8b03c4837db8ac6650501ef45af1c807cce', satoshis: -7679241, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 0, timestamp: 1461342707725, prevtxid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', @@ -2611,7 +2631,7 @@ describe('Bitcoin Service', function() { { txid: 'e9dcf22807db77ac0276b03cc2d3a8b03c4837db8ac6650501ef45af1c807cce', satoshis: -7679241, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 0, timestamp: 1461342707725, prevtxid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', @@ -2620,7 +2640,7 @@ describe('Bitcoin Service', function() { { txid: 'e9dcf22807db77ac0276b03cc2d3a8b03c4837db8ac6650501ef45af1c807cce', satoshis: -7679241, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 1, timestamp: 1461342707725, prevtxid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', @@ -2629,7 +2649,7 @@ describe('Bitcoin Service', function() { { txid: 'e9dcf22807db77ac0276b03cc2d3a8b03c4837db8ac6650501ef45af1c807cce', satoshis: 100000, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 1, timestamp: 1461342833133 } @@ -2649,7 +2669,7 @@ describe('Bitcoin Service', function() { var options = { queryMempool: true }; - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressUnspentOutputs(address, options, function(err, utxos) { if (err) { return done(err); @@ -2668,7 +2688,7 @@ describe('Bitcoin Service', function() { { txid: 'e9dcf22807db77ac0276b03cc2d3a8b03c4837db8ac6650501ef45af1c807cce', satoshis: 0, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 0, timestamp: 1461342707725, prevtxid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', @@ -2678,7 +2698,7 @@ describe('Bitcoin Service', function() { var bitcoind = new BitcoinService(baseConfig); var confirmedUtxos = [ { - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', txid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', outputIndex: 1, script: '76a914f399b4b8894f1153b96fce29f05e6e116eb4c21788ac', @@ -2699,7 +2719,7 @@ describe('Bitcoin Service', function() { var options = { queryMempool: true }; - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressUnspentOutputs(address, options, function(err, utxos) { if (err) { return done(err); @@ -2713,7 +2733,7 @@ describe('Bitcoin Service', function() { { txid: 'e9dcf22807db77ac0276b03cc2d3a8b03c4837db8ac6650501ef45af1c807cce', satoshis: 10000, - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', index: 0, timestamp: 1461342707725 } @@ -2721,7 +2741,7 @@ describe('Bitcoin Service', function() { var bitcoind = new BitcoinService(baseConfig); var confirmedUtxos = [ { - address: '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo', + address: 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs', txid: '46f24e0c274fc07708b781963576c4c5d5625d926dbb0a17fa865dcd9fe58ea0', outputIndex: 1, script: '76a914f399b4b8894f1153b96fce29f05e6e116eb4c21788ac', @@ -2742,7 +2762,7 @@ describe('Bitcoin Service', function() { var options = { queryMempool: true }; - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressUnspentOutputs(address, options, function(err, utxos) { if (err) { return done(err); @@ -2761,7 +2781,7 @@ describe('Bitcoin Service', function() { var options = { queryMempool: true }; - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressUnspentOutputs(address, options, function(err) { err.should.be.instanceOf(Error); done(); @@ -2776,7 +2796,7 @@ describe('Bitcoin Service', function() { } }); var options = {}; - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressUnspentOutputs(address, options, function(err) { getAddressMempool.callCount.should.equal(1); done(); @@ -2894,7 +2914,7 @@ describe('Bitcoin Service', function() { } }); var options = {}; - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressTxids(address, options, function(err) { should.exist(err); err.should.be.instanceof(errors.RPCError); @@ -2910,7 +2930,7 @@ describe('Bitcoin Service', function() { var options = { queryMempool: false }; - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressTxids(address, options, function(err) { should.exist(err); err.should.be.instanceof(errors.RPCError); @@ -2940,7 +2960,7 @@ describe('Bitcoin Service', function() { var options = { queryMempool: false }; - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressTxids(address, options, function(err, txids) { if (err) { return done(err); @@ -2966,7 +2986,7 @@ describe('Bitcoin Service', function() { var options = { queryMempool: false }; - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressTxids(address, options, function(err, txids) { if (err) { return done(err); @@ -3004,7 +3024,7 @@ describe('Bitcoin Service', function() { start: 4, end: 2 }; - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressTxids(address, options, function(err, txids) { if (err) { return done(err); @@ -3051,7 +3071,7 @@ describe('Bitcoin Service', function() { getAddressMempool: getAddressMempool } }); - var address = '1Cj4UZWnGWAJH1CweTMgPLQMn26WRMfXmo'; + var address = 'XnQuJpAgEDNtRwoXWLfuEs69cMgCYS8rgs'; bitcoind.getAddressTxids(address, {queryMempool: false}, function(err, txids) { if (err) { return done(err); @@ -3305,37 +3325,37 @@ describe('Bitcoin Service', function() { describe('#_getAddressStrings', function() { it('will get address strings from bitcore addresses', function() { var addresses = [ - bitcore.Address('1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i'), - bitcore.Address('3CMNFxN1oHBc4R1EpboAL5yzHGgE611Xou'), + bitcore.Address('XjxDQFjTNEP9dcrJhBLvy5i1Dobz4x1LJN'), + bitcore.Address('7d5169eBcGHF4BYC6DTffTyeCpWbrZnNgz'), ]; var bitcoind = new BitcoinService(baseConfig); var strings = bitcoind._getAddressStrings(addresses); - strings[0].should.equal('1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i'); - strings[1].should.equal('3CMNFxN1oHBc4R1EpboAL5yzHGgE611Xou'); + strings[0].should.equal('XjxDQFjTNEP9dcrJhBLvy5i1Dobz4x1LJN'); + strings[1].should.equal('7d5169eBcGHF4BYC6DTffTyeCpWbrZnNgz'); }); it('will get address strings from strings', function() { var addresses = [ - '1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i', - '3CMNFxN1oHBc4R1EpboAL5yzHGgE611Xou', + 'XjxDQFjTNEP9dcrJhBLvy5i1Dobz4x1LJN', + '7d5169eBcGHF4BYC6DTffTyeCpWbrZnNgz', ]; var bitcoind = new BitcoinService(baseConfig); var strings = bitcoind._getAddressStrings(addresses); - strings[0].should.equal('1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i'); - strings[1].should.equal('3CMNFxN1oHBc4R1EpboAL5yzHGgE611Xou'); + strings[0].should.equal('XjxDQFjTNEP9dcrJhBLvy5i1Dobz4x1LJN'); + strings[1].should.equal('7d5169eBcGHF4BYC6DTffTyeCpWbrZnNgz'); }); it('will get address strings from mixture of types', function() { var addresses = [ - bitcore.Address('1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i'), - '3CMNFxN1oHBc4R1EpboAL5yzHGgE611Xou', + bitcore.Address('XjxDQFjTNEP9dcrJhBLvy5i1Dobz4x1LJN'), + '7d5169eBcGHF4BYC6DTffTyeCpWbrZnNgz', ]; var bitcoind = new BitcoinService(baseConfig); var strings = bitcoind._getAddressStrings(addresses); - strings[0].should.equal('1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i'); - strings[1].should.equal('3CMNFxN1oHBc4R1EpboAL5yzHGgE611Xou'); + strings[0].should.equal('XjxDQFjTNEP9dcrJhBLvy5i1Dobz4x1LJN'); + strings[1].should.equal('7d5169eBcGHF4BYC6DTffTyeCpWbrZnNgz'); }); it('will give error with unknown', function() { var addresses = [ - bitcore.Address('1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i'), + bitcore.Address('XjxDQFjTNEP9dcrJhBLvy5i1Dobz4x1LJN'), 0, ]; var bitcoind = new BitcoinService(baseConfig); @@ -3380,7 +3400,7 @@ describe('Bitcoin Service', function() { }); describe('#getAddressHistory', function() { - var address = '12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX'; + var address = 'XcHw3hNN293dY1AYrbeBrP1sB6vsugTQTz'; it('will give error with "from" and "to" range that exceeds max size', function(done) { var bitcoind = new BitcoinService(baseConfig); bitcoind.getAddressHistory(address, {from: 0, to: 51}, function(err) { @@ -3545,7 +3565,7 @@ describe('Bitcoin Service', function() { received: 30 * 1e8, balance: 20 * 1e8 }); - var address = '3NbU8XzUgKyuCgYgZEKsBtUvkTm2r7Xgwj'; + var address = '7oK6xjGeVK5YCT5dpqzNXGUag1bQadPAyT'; var options = {}; bitcoind.getAddressSummary(address, options, function(err, summary) { bitcoind._paginateTxids.callCount.should.equal(1); @@ -3590,7 +3610,7 @@ describe('Bitcoin Service', function() { received: 30 * 1e8, balance: 20 * 1e8 }); - var address = '3NbU8XzUgKyuCgYgZEKsBtUvkTm2r7Xgwj'; + var address = '7oK6xjGeVK5YCT5dpqzNXGUag1bQadPAyT'; var options = { from: 0, to: 1001 @@ -3624,7 +3644,7 @@ describe('Bitcoin Service', function() { received: 30 * 1e8, balance: 20 * 1e8 }); - var address = '3NbU8XzUgKyuCgYgZEKsBtUvkTm2r7Xgwj'; + var address = '7oK6xjGeVK5YCT5dpqzNXGUag1bQadPAyT'; var options = { noTxList: true }; @@ -3663,7 +3683,7 @@ describe('Bitcoin Service', function() { received: 30 * 1e8, balance: 20 * 1e8 }); - var address = '3NbU8XzUgKyuCgYgZEKsBtUvkTm2r7Xgwj'; + var address = '7oK6xjGeVK5YCT5dpqzNXGUag1bQadPAyT'; var options = { queryMempool: false }; @@ -3687,7 +3707,7 @@ describe('Bitcoin Service', function() { balance: 20 * 1e8 }); bitcoind._paginateTxids = sinon.stub().throws(new Error('test')); - var address = '3NbU8XzUgKyuCgYgZEKsBtUvkTm2r7Xgwj'; + var address = '7oK6xjGeVK5YCT5dpqzNXGUag1bQadPAyT'; var options = { queryMempool: false }; @@ -4123,12 +4143,12 @@ describe('Bitcoin Service', function() { getBlockHash: getBlockHash } }); - bitcoind._maybeGetBlockHash('2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br', function(err, hash) { + bitcoind._maybeGetBlockHash('8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi', function(err, hash) { if (err) { return done(err); } getBlockHash.callCount.should.equal(0); - hash.should.equal('2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br'); + hash.should.equal('8oUSpiq5REeEKAzS1qSXoJbZ9TRfH1L6mi'); done(); }); });