Compare commits
19 Commits
Author | SHA1 | Date |
---|---|---|
Simon | 53a3a2845b | |
Simon | 1803cb983e | |
Ian Munoz | 1ab4e2fd55 | |
Ian Munoz | d85bd7404f | |
Ian Munoz | f2e287d901 | |
Simon | 34a0a90e1d | |
Simon | 4f0edd4bd6 | |
Simon | 0fe30a61f8 | |
Ian Munoz | 3405d2edeb | |
Jack Grigg | 9212ef3c9e | |
Jack Grigg | f5b864f29e | |
Jack Grigg | 433a08d070 | |
Jack Grigg | 3ecbe21697 | |
Jack Grigg | 112c6d896d | |
Jack Grigg | 10b44b6392 | |
Jack Grigg | 0a9d654ca7 | |
Braydon Fuller | 639fdc941e | |
Chris Kleeschulte | b5401b0269 | |
Braydon Fuller | 75d41acdd6 |
|
@ -5,7 +5,7 @@ var bitcoin = require('bitcoin');
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
var maxTime = 20;
|
var maxTime = 20;
|
||||||
|
|
||||||
console.log('Bitcoin Service native interface vs. Bitcoin JSON RPC interface');
|
console.log('Zcash Service native interface vs. Zcash JSON RPC interface');
|
||||||
console.log('----------------------------------------------------------------------');
|
console.log('----------------------------------------------------------------------');
|
||||||
|
|
||||||
// To run the benchmarks a fully synced Bitcore Core directory is needed. The RPC comands
|
// To run the benchmarks a fully synced Bitcore Core directory is needed. The RPC comands
|
||||||
|
@ -28,7 +28,7 @@ var fixtureData = {
|
||||||
|
|
||||||
var bitcoind = require('../').services.Bitcoin({
|
var bitcoind = require('../').services.Bitcoin({
|
||||||
node: {
|
node: {
|
||||||
datadir: process.env.HOME + '/.bitcoin',
|
datadir: process.env.HOME + '/.zcash',
|
||||||
network: {
|
network: {
|
||||||
name: 'testnet'
|
name: 'testnet'
|
||||||
}
|
}
|
||||||
|
@ -43,12 +43,12 @@ bitcoind.start(function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
console.log('Bitcoin Core started');
|
console.log('Zcash started');
|
||||||
});
|
});
|
||||||
|
|
||||||
bitcoind.on('ready', function() {
|
bitcoind.on('ready', function() {
|
||||||
|
|
||||||
console.log('Bitcoin Core ready');
|
console.log('Zcash ready');
|
||||||
|
|
||||||
var client = new bitcoin.Client({
|
var client = new bitcoin.Client({
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
|
|
|
@ -49,7 +49,7 @@ var myNode = new bitcore.Node({
|
||||||
config: {
|
config: {
|
||||||
spawn: {
|
spawn: {
|
||||||
datadir: '/home/<username>/.bitcoin',
|
datadir: '/home/<username>/.bitcoin',
|
||||||
exec: '/home/<username>/bitcore-node/bin/bitcoind'
|
exec: '/home/<username>/bitcore-node/bin/zcashd'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -48,7 +48,7 @@ To start reindexing add `reindex=1` during the **first startup only**.
|
||||||
"bitcoind": {
|
"bitcoind": {
|
||||||
"spawn": {
|
"spawn": {
|
||||||
"datadir": "/home/<username>/.bitcoin",
|
"datadir": "/home/<username>/.bitcoin",
|
||||||
"exec": "/home/<username>/bitcore-node/bin/bitcoind"
|
"exec": "/home/<username>/bitcore-node/bin/zcashd"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
index.js
2
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.bitcore = require('./lib/cli/bitcore');
|
||||||
module.exports.cli.bitcored = require('./lib/cli/bitcored');
|
module.exports.cli.bitcored = require('./lib/cli/bitcored');
|
||||||
|
|
||||||
module.exports.lib = require('bitcore-lib');
|
module.exports.lib = require('bitcore-lib-zcash');
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var bitcore = require('bitcore-lib');
|
var bitcore = require('bitcore-lib-zcash');
|
||||||
var _ = bitcore.deps._;
|
var _ = bitcore.deps._;
|
||||||
var colors = require('colors/safe');
|
var colors = require('colors/safe');
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
var EventEmitter = require('events').EventEmitter;
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
var bitcore = require('bitcore-lib');
|
var bitcore = require('bitcore-lib-zcash');
|
||||||
var Networks = bitcore.Networks;
|
var Networks = bitcore.Networks;
|
||||||
var $ = bitcore.util.preconditions;
|
var $ = bitcore.util.preconditions;
|
||||||
var _ = bitcore.deps._;
|
var _ = bitcore.deps._;
|
||||||
|
|
|
@ -4,7 +4,7 @@ var async = require('async');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var spawn = require('child_process').spawn;
|
var spawn = require('child_process').spawn;
|
||||||
var bitcore = require('bitcore-lib');
|
var bitcore = require('bitcore-lib-zcash');
|
||||||
var utils = require('../utils');
|
var utils = require('../utils');
|
||||||
var $ = bitcore.util.preconditions;
|
var $ = bitcore.util.preconditions;
|
||||||
var _ = bitcore.deps._;
|
var _ = bitcore.deps._;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var spawn = require('child_process').spawn;
|
var spawn = require('child_process').spawn;
|
||||||
var bitcore = require('bitcore-lib');
|
var bitcore = require('bitcore-lib-zcash');
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
var $ = bitcore.util.preconditions;
|
var $ = bitcore.util.preconditions;
|
||||||
var _ = bitcore.deps._;
|
var _ = bitcore.deps._;
|
||||||
|
@ -14,13 +14,13 @@ var defaultBaseConfig = require('./default-base-config');
|
||||||
var version = '^' + packageFile.version;
|
var version = '^' + packageFile.version;
|
||||||
|
|
||||||
var BASE_PACKAGE = {
|
var BASE_PACKAGE = {
|
||||||
description: 'A full Bitcoin node build with Bitcore',
|
description: 'A full Zcash node build with Bitcore',
|
||||||
repository: 'https://github.com/user/project',
|
repository: 'https://github.com/user/project',
|
||||||
license: 'MIT',
|
license: 'MIT',
|
||||||
readme: 'README.md',
|
readme: 'README.md',
|
||||||
dependencies: {
|
dependencies: {
|
||||||
'bitcore-lib': '^' + bitcore.version,
|
'bitcore-lib-zcash': 'zcash-hackworks/bitcore-lib-zcash',
|
||||||
'bitcore-node': version
|
'bitcore-node-zcash': 'zcash-hackworks/bitcore-node-zcash'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,8 @@ function getDefaultBaseConfig(options) {
|
||||||
servicesConfig: {
|
servicesConfig: {
|
||||||
bitcoind: {
|
bitcoind: {
|
||||||
spawn: {
|
spawn: {
|
||||||
datadir: options.datadir || path.resolve(process.env.HOME, '.bitcoin'),
|
datadir: options.datadir || path.resolve(process.env.HOME, '.zcash'),
|
||||||
exec: path.resolve(__dirname, '../../bin/bitcoind')
|
exec: path.resolve(__dirname, '../../bin/zcashd')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ function getDefaultConfig(options) {
|
||||||
bitcoind: {
|
bitcoind: {
|
||||||
spawn: {
|
spawn: {
|
||||||
datadir: path.resolve(defaultPath, './data'),
|
datadir: path.resolve(defaultPath, './data'),
|
||||||
exec: path.resolve(__dirname, '../../bin/bitcoind')
|
exec: path.resolve(__dirname, '../../bin/zcashd')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var bitcore = require('bitcore-lib');
|
var bitcore = require('bitcore-lib-zcash');
|
||||||
var $ = bitcore.util.preconditions;
|
var $ = bitcore.util.preconditions;
|
||||||
var _ = bitcore.deps._;
|
var _ = bitcore.deps._;
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
|
@ -5,7 +5,7 @@ var fs = require('fs');
|
||||||
var npm = require('npm');
|
var npm = require('npm');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var spawn = require('child_process').spawn;
|
var spawn = require('child_process').spawn;
|
||||||
var bitcore = require('bitcore-lib');
|
var bitcore = require('bitcore-lib-zcash');
|
||||||
var $ = bitcore.util.preconditions;
|
var $ = bitcore.util.preconditions;
|
||||||
var _ = bitcore.deps._;
|
var _ = bitcore.deps._;
|
||||||
var utils = require('../utils');
|
var utils = require('../utils');
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var BitcoreNode = require('../node');
|
var BitcoreNode = require('../node');
|
||||||
var index = require('../');
|
var index = require('../');
|
||||||
var bitcore = require('bitcore-lib');
|
var bitcore = require('bitcore-lib-zcash');
|
||||||
var _ = bitcore.deps._;
|
var _ = bitcore.deps._;
|
||||||
var log = index.log;
|
var log = index.log;
|
||||||
var shuttingDown = false;
|
var shuttingDown = false;
|
||||||
|
@ -22,8 +22,8 @@ function checkConfigVersion2(fullConfig) {
|
||||||
if (!datadirUndefined || addressDefined || dbDefined) {
|
if (!datadirUndefined || addressDefined || dbDefined) {
|
||||||
|
|
||||||
console.warn('\nConfiguration file is not compatible with this version. \n' +
|
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' +
|
'A reindex for zcashd is necessary for this upgrade with the "reindex=1" zcash.conf option. \n' +
|
||||||
'There are changes necessary in both bitcoin.conf and bitcore-node.json. \n\n' +
|
'There are changes necessary in both zcash.conf and bitcore-node.json. \n\n' +
|
||||||
'To upgrade please see the details below and documentation at: \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/blob/bitcoind/docs/upgrade.md \n');
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ function checkConfigVersion2(fullConfig) {
|
||||||
bitcoind: {
|
bitcoind: {
|
||||||
spawn: {
|
spawn: {
|
||||||
datadir: fullConfig.datadir,
|
datadir: fullConfig.datadir,
|
||||||
exec: path.resolve(__dirname, '../../bin/bitcoind')
|
exec: path.resolve(__dirname, '../../bin/zcashd')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ var path = require('path');
|
||||||
var spawn = require('child_process').spawn;
|
var spawn = require('child_process').spawn;
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var mkdirp = require('mkdirp');
|
var mkdirp = require('mkdirp');
|
||||||
var bitcore = require('bitcore-lib');
|
var bitcore = require('bitcore-lib-zcash');
|
||||||
var zmq = require('zmq');
|
var zmq = require('zmq');
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
var LRU = require('lru-cache');
|
var LRU = require('lru-cache');
|
||||||
|
@ -331,16 +331,16 @@ Bitcoin.prototype._expandRelativeDatadir = function() {
|
||||||
Bitcoin.prototype._loadSpawnConfiguration = function(node) {
|
Bitcoin.prototype._loadSpawnConfiguration = function(node) {
|
||||||
/* jshint maxstatements: 25 */
|
/* jshint maxstatements: 25 */
|
||||||
|
|
||||||
$.checkArgument(this.options.spawn, 'Please specify "spawn" in bitcoind config options');
|
$.checkArgument(this.options.spawn, 'Please specify "spawn" in zcashd config options');
|
||||||
$.checkArgument(this.options.spawn.datadir, 'Please specify "spawn.datadir" in bitcoind config options');
|
$.checkArgument(this.options.spawn.datadir, 'Please specify "spawn.datadir" in zcashd config options');
|
||||||
$.checkArgument(this.options.spawn.exec, 'Please specify "spawn.exec" in bitcoind config options');
|
$.checkArgument(this.options.spawn.exec, 'Please specify "spawn.exec" in zcashd config options');
|
||||||
|
|
||||||
this._expandRelativeDatadir();
|
this._expandRelativeDatadir();
|
||||||
|
|
||||||
var spawnOptions = this.options.spawn;
|
var spawnOptions = this.options.spawn;
|
||||||
var configPath = path.resolve(spawnOptions.datadir, './bitcoin.conf');
|
var configPath = path.resolve(spawnOptions.datadir, './zcash.conf');
|
||||||
|
|
||||||
log.info('Using bitcoin config file:', configPath);
|
log.info('Using zcash config file:', configPath);
|
||||||
|
|
||||||
this.spawn = {};
|
this.spawn = {};
|
||||||
this.spawn.datadir = this.options.spawn.datadir;
|
this.spawn.datadir = this.options.spawn.datadir;
|
||||||
|
@ -395,29 +395,29 @@ Bitcoin.prototype._checkConfigIndexes = function(spawnConfig, node) {
|
||||||
|
|
||||||
$.checkState(
|
$.checkState(
|
||||||
spawnConfig.server && spawnConfig.server === 1,
|
spawnConfig.server && spawnConfig.server === 1,
|
||||||
'"server" option is required to communicate to bitcoind from bitcore. ' +
|
'"server" option is required to communicate to zcashd from bitcore. ' +
|
||||||
'Please add "server=1" to your configuration and restart'
|
'Please add "server=1" to your configuration and restart'
|
||||||
);
|
);
|
||||||
|
|
||||||
$.checkState(
|
$.checkState(
|
||||||
spawnConfig.zmqpubrawtx,
|
spawnConfig.zmqpubrawtx,
|
||||||
'"zmqpubrawtx" option is required to get event updates from bitcoind. ' +
|
'"zmqpubrawtx" option is required to get event updates from zcashd. ' +
|
||||||
'Please add "zmqpubrawtx=tcp://127.0.0.1:<port>" to your configuration and restart'
|
'Please add "zmqpubrawtx=tcp://127.0.0.1:<port>" to your configuration and restart'
|
||||||
);
|
);
|
||||||
|
|
||||||
$.checkState(
|
$.checkState(
|
||||||
spawnConfig.zmqpubhashblock,
|
spawnConfig.zmqpubhashblock,
|
||||||
'"zmqpubhashblock" option is required to get event updates from bitcoind. ' +
|
'"zmqpubhashblock" option is required to get event updates from zcashd. ' +
|
||||||
'Please add "zmqpubhashblock=tcp://127.0.0.1:<port>" to your configuration and restart'
|
'Please add "zmqpubhashblock=tcp://127.0.0.1:<port>" to your configuration and restart'
|
||||||
);
|
);
|
||||||
|
|
||||||
$.checkState(
|
$.checkState(
|
||||||
(spawnConfig.zmqpubhashblock === spawnConfig.zmqpubrawtx),
|
(spawnConfig.zmqpubhashblock === spawnConfig.zmqpubrawtx),
|
||||||
'"zmqpubrawtx" and "zmqpubhashblock" are expected to the same host and port in bitcoin.conf'
|
'"zmqpubrawtx" and "zmqpubhashblock" are expected to the same host and port in zcash.conf'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (spawnConfig.reindex && spawnConfig.reindex === 1) {
|
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 zcashd is undergoing a reindex. ' +
|
||||||
'The reindex flag will start the index from beginning every time the node is started, so it ' +
|
'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 ' +
|
'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 services will start.');
|
||||||
|
@ -477,7 +477,7 @@ Bitcoin.prototype._initChain = function(callback) {
|
||||||
}
|
}
|
||||||
self.genesisBuffer = blockBuffer;
|
self.genesisBuffer = blockBuffer;
|
||||||
self.emit('ready');
|
self.emit('ready');
|
||||||
log.info('Bitcoin Daemon Ready');
|
log.info('Zcash Daemon Ready');
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -488,10 +488,10 @@ Bitcoin.prototype._initChain = function(callback) {
|
||||||
|
|
||||||
Bitcoin.prototype._getDefaultConf = function() {
|
Bitcoin.prototype._getDefaultConf = function() {
|
||||||
var networkOptions = {
|
var networkOptions = {
|
||||||
rpcport: 8332
|
rpcport: 8232
|
||||||
};
|
};
|
||||||
if (this.node.network === bitcore.Networks.testnet) {
|
if (this.node.network === bitcore.Networks.testnet) {
|
||||||
networkOptions.rpcport = 18332;
|
networkOptions.rpcport = 18232;
|
||||||
}
|
}
|
||||||
return networkOptions;
|
return networkOptions;
|
||||||
};
|
};
|
||||||
|
@ -499,9 +499,9 @@ Bitcoin.prototype._getDefaultConf = function() {
|
||||||
Bitcoin.prototype._getNetworkConfigPath = function() {
|
Bitcoin.prototype._getNetworkConfigPath = function() {
|
||||||
var networkPath;
|
var networkPath;
|
||||||
if (this.node.network === bitcore.Networks.testnet) {
|
if (this.node.network === bitcore.Networks.testnet) {
|
||||||
networkPath = 'testnet3/bitcoin.conf';
|
networkPath = 'testnet3/zcash.conf';
|
||||||
if (this.node.network.regtestEnabled) {
|
if (this.node.network.regtestEnabled) {
|
||||||
networkPath = 'regtest/bitcoin.conf';
|
networkPath = 'regtest/zcash.conf';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return networkPath;
|
return networkPath;
|
||||||
|
@ -581,7 +581,7 @@ Bitcoin.prototype._updateTip = function(node, message) {
|
||||||
if (Math.round(percentage) >= 100) {
|
if (Math.round(percentage) >= 100) {
|
||||||
self.emit('synced', self.height);
|
self.emit('synced', self.height);
|
||||||
}
|
}
|
||||||
log.info('Bitcoin Height:', self.height, 'Percentage:', percentage.toFixed(2));
|
log.info('Zcash Height:', self.height, 'Percentage:', percentage.toFixed(2));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -759,7 +759,7 @@ Bitcoin.prototype._checkReindex = function(node, callback) {
|
||||||
}
|
}
|
||||||
var percentSynced = response.result.verificationprogress * 100;
|
var percentSynced = response.result.verificationprogress * 100;
|
||||||
|
|
||||||
log.info('Bitcoin Core Daemon Reindex Percentage: ' + percentSynced.toFixed(2));
|
log.info('Zcash Daemon Reindex Percentage: ' + percentSynced.toFixed(2));
|
||||||
|
|
||||||
if (Math.round(percentSynced) >= 100) {
|
if (Math.round(percentSynced) >= 100) {
|
||||||
node._reindex = false;
|
node._reindex = false;
|
||||||
|
@ -796,7 +796,7 @@ Bitcoin.prototype._loadTipFromNode = function(node, callback) {
|
||||||
Bitcoin.prototype._stopSpawnedBitcoin = function(callback) {
|
Bitcoin.prototype._stopSpawnedBitcoin = function(callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var spawnOptions = this.options.spawn;
|
var spawnOptions = this.options.spawn;
|
||||||
var pidPath = spawnOptions.datadir + '/bitcoind.pid';
|
var pidPath = spawnOptions.datadir + '/zcashd.pid';
|
||||||
|
|
||||||
function stopProcess() {
|
function stopProcess() {
|
||||||
fs.readFile(pidPath, 'utf8', function(err, pid) {
|
fs.readFile(pidPath, 'utf8', function(err, pid) {
|
||||||
|
@ -812,11 +812,11 @@ Bitcoin.prototype._stopSpawnedBitcoin = function(callback) {
|
||||||
return callback(null);
|
return callback(null);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
log.warn('Stopping existing spawned bitcoin process with pid: ' + pid);
|
log.warn('Stopping existing spawned zcash process with pid: ' + pid);
|
||||||
self._process.kill(pid, 'SIGINT');
|
self._process.kill(pid, 'SIGINT');
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
if (err && err.code === 'ESRCH') {
|
if (err && err.code === 'ESRCH') {
|
||||||
log.warn('Unclean bitcoin process shutdown, process not found with pid: ' + pid);
|
log.warn('Unclean zcash process shutdown, process not found with pid: ' + pid);
|
||||||
return callback(null);
|
return callback(null);
|
||||||
} else if(err) {
|
} else if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
@ -858,7 +858,7 @@ Bitcoin.prototype._spawnChildProcess = function(callback) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info('Starting bitcoin process');
|
log.info('Starting zcash process');
|
||||||
self.spawn.process = spawn(self.spawn.exec, options, {stdio: 'inherit'});
|
self.spawn.process = spawn(self.spawn.exec, options, {stdio: 'inherit'});
|
||||||
|
|
||||||
self.spawn.process.on('error', function(err) {
|
self.spawn.process.on('error', function(err) {
|
||||||
|
@ -867,14 +867,14 @@ Bitcoin.prototype._spawnChildProcess = function(callback) {
|
||||||
|
|
||||||
self.spawn.process.once('exit', function(code) {
|
self.spawn.process.once('exit', function(code) {
|
||||||
if (!self.node.stopping) {
|
if (!self.node.stopping) {
|
||||||
log.warn('Bitcoin process unexpectedly exited with code:', code);
|
log.warn('Zcash process unexpectedly exited with code:', code);
|
||||||
log.warn('Restarting bitcoin child process in ' + self.spawnRestartTime + 'ms');
|
log.warn('Restarting zcash child process in ' + self.spawnRestartTime + 'ms');
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
self._spawnChildProcess(function(err) {
|
self._spawnChildProcess(function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return self.emit('error', err);
|
return self.emit('error', err);
|
||||||
}
|
}
|
||||||
log.warn('Bitcoin process restarted');
|
log.warn('Zcash process restarted');
|
||||||
});
|
});
|
||||||
}, self.spawnRestartTime);
|
}, self.spawnRestartTime);
|
||||||
}
|
}
|
||||||
|
@ -903,7 +903,7 @@ Bitcoin.prototype._spawnChildProcess = function(callback) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
if (exitShutdown) {
|
if (exitShutdown) {
|
||||||
return callback(new Error('Stopping while trying to spawn bitcoind.'));
|
return callback(new Error('Stopping while trying to spawn zcashd.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
self._initZmqSubSocket(node, self.spawn.config.zmqpubrawtx);
|
self._initZmqSubSocket(node, self.spawn.config.zmqpubrawtx);
|
||||||
|
@ -949,7 +949,7 @@ Bitcoin.prototype._connectProcess = function(config, callback) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
if (exitShutdown) {
|
if (exitShutdown) {
|
||||||
return callback(new Error('Stopping while trying to connect to bitcoind.'));
|
return callback(new Error('Stopping while trying to connect to zcashd.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
self._initZmqSubSocket(node, config.zmqpubrawtx);
|
self._initZmqSubSocket(node, config.zmqpubrawtx);
|
||||||
|
@ -1000,7 +1000,7 @@ Bitcoin.prototype.start = function(callback) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
if (self.nodes.length === 0) {
|
if (self.nodes.length === 0) {
|
||||||
return callback(new Error('Bitcoin configuration options "spawn" or "connect" are expected'));
|
return callback(new Error('Zcash configuration options "spawn" or "connect" are expected'));
|
||||||
}
|
}
|
||||||
self._initChain(callback);
|
self._initChain(callback);
|
||||||
});
|
});
|
||||||
|
@ -1947,6 +1947,20 @@ Bitcoin.prototype.getDetailedTransaction = function(txid, callback) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addJoinSplitsToTx(tx, result) {
|
||||||
|
tx.joinSplits = [];
|
||||||
|
var netJoinSplitZatoshis = 0;
|
||||||
|
for (var jsIndex = 0; jsIndex < result.vjoinsplit.length; jsIndex++) {
|
||||||
|
var jsdesc = result.vjoinsplit[jsIndex];
|
||||||
|
netJoinSplitZatoshis += jsdesc.vpub_newZat - jsdesc.vpub_oldZat;
|
||||||
|
tx.joinSplits.push({
|
||||||
|
oldZatoshis: jsdesc.vpub_oldZat,
|
||||||
|
newZatoshis: jsdesc.vpub_newZat,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return netJoinSplitZatoshis;
|
||||||
|
}
|
||||||
|
|
||||||
if (tx) {
|
if (tx) {
|
||||||
return setImmediate(function() {
|
return setImmediate(function() {
|
||||||
callback(null, tx);
|
callback(null, tx);
|
||||||
|
@ -1966,6 +1980,7 @@ Bitcoin.prototype.getDetailedTransaction = function(txid, callback) {
|
||||||
version: result.version,
|
version: result.version,
|
||||||
hash: txid,
|
hash: txid,
|
||||||
locktime: result.locktime,
|
locktime: result.locktime,
|
||||||
|
fOverwintered: result.overwintered,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (result.vin[0] && result.vin[0].coinbase) {
|
if (result.vin[0] && result.vin[0].coinbase) {
|
||||||
|
@ -1975,14 +1990,36 @@ Bitcoin.prototype.getDetailedTransaction = function(txid, callback) {
|
||||||
addInputsToTx(tx, result);
|
addInputsToTx(tx, result);
|
||||||
addOutputsToTx(tx, result);
|
addOutputsToTx(tx, result);
|
||||||
|
|
||||||
|
var netJoinSplitZatoshis = 0;
|
||||||
|
if (tx.version >= 2) {
|
||||||
|
netJoinSplitZatoshis = addJoinSplitsToTx(tx, result);
|
||||||
|
}
|
||||||
|
|
||||||
if (!tx.coinbase) {
|
if (!tx.coinbase) {
|
||||||
tx.feeSatoshis = tx.inputSatoshis - tx.outputSatoshis;
|
tx.feeSatoshis = tx.inputSatoshis - tx.outputSatoshis + netJoinSplitZatoshis;
|
||||||
} else {
|
} else {
|
||||||
tx.feeSatoshis = 0;
|
tx.feeSatoshis = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.transactionDetailedCache.set(txid, tx);
|
if (tx.fOverwintered) {
|
||||||
|
tx.nVersionGroupId = parseInt(result.versiongroupid, 16);
|
||||||
|
tx.nExpiryHeight = result.expiryheight;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sapling START
|
||||||
|
if (tx.fOverwintered && tx.version >= 4) {
|
||||||
|
tx.valueBalance = result.valueBalance;
|
||||||
|
tx.spendDescs = result.vShieldedSpend;
|
||||||
|
tx.outputDescs = result.vShieldedOutput;
|
||||||
|
if (result.bindingSig) {
|
||||||
|
tx.bindingSig = result.bindingSig;
|
||||||
|
}
|
||||||
|
// Update tx.feeSatoshis with custom explorer JSON field 'valueBalanceZat'
|
||||||
|
tx.feeSatoshis = tx.feeSatoshis + result.valueBalanceZat;
|
||||||
|
}
|
||||||
|
// Sapling END
|
||||||
|
|
||||||
|
self.transactionDetailedCache.set(txid, tx);
|
||||||
done(null, tx);
|
done(null, tx);
|
||||||
});
|
});
|
||||||
}, callback);
|
}, callback);
|
||||||
|
@ -2080,7 +2117,7 @@ Bitcoin.prototype.stop = function(callback) {
|
||||||
if (!exited) {
|
if (!exited) {
|
||||||
exited = true;
|
exited = true;
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
var error = new Error('bitcoind spawned process exited with status code: ' + code);
|
var error = new Error('zcashd spawned process exited with status code: ' + code);
|
||||||
error.code = code;
|
error.code = code;
|
||||||
return callback(error);
|
return callback(error);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2092,7 +2129,7 @@ Bitcoin.prototype.stop = function(callback) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if (!exited) {
|
if (!exited) {
|
||||||
exited = true;
|
exited = true;
|
||||||
return callback(new Error('bitcoind process did not exit'));
|
return callback(new Error('zcashd process did not exit'));
|
||||||
}
|
}
|
||||||
}, this.shutdownTimeout).unref();
|
}, this.shutdownTimeout).unref();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -9,7 +9,7 @@ var socketio = require('socket.io');
|
||||||
var inherits = require('util').inherits;
|
var inherits = require('util').inherits;
|
||||||
|
|
||||||
var BaseService = require('../service');
|
var BaseService = require('../service');
|
||||||
var bitcore = require('bitcore-lib');
|
var bitcore = require('bitcore-lib-zcash');
|
||||||
var _ = bitcore.deps._;
|
var _ = bitcore.deps._;
|
||||||
var index = require('../');
|
var index = require('../');
|
||||||
var log = index.log;
|
var log = index.log;
|
||||||
|
|
35
package.json
35
package.json
|
@ -1,13 +1,13 @@
|
||||||
{
|
{
|
||||||
"name": "bitcore-node",
|
"name": "bitcore-node-zcash",
|
||||||
"description": "Full node with extended capabilities using Bitcore and Bitcoin Core",
|
"description": "Full node with extended capabilities using Bitcore and Zcash",
|
||||||
"author": "BitPay <dev@bitpay.com>",
|
"author": "BitPay <dev@bitpay.com>",
|
||||||
"version": "3.1.1",
|
"version": "3.1.2",
|
||||||
"main": "./index.js",
|
"main": "./index.js",
|
||||||
"repository": "git://github.com/bitpay/bitcore-node.git",
|
"repository": "git://github.com/zcash-hackworks/bitcore-node-zcash.git",
|
||||||
"homepage": "https://github.com/bitpay/bitcore-node",
|
"homepage": "https://github.com/zcash-hackworks/bitcore-node-zcash",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/bitpay/bitcore-node/issues"
|
"url": "https://github.com/zcash-hackworks/bitcore-node-zcash/issues"
|
||||||
},
|
},
|
||||||
"contributors": [
|
"contributors": [
|
||||||
{
|
{
|
||||||
|
@ -24,15 +24,24 @@
|
||||||
{
|
{
|
||||||
"name": "Patrick Nagurny",
|
"name": "Patrick Nagurny",
|
||||||
"email": "patrick@bitpay.com"
|
"email": "patrick@bitpay.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jack Grigg",
|
||||||
|
"email": "jack@z.cash"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Simon Liu",
|
||||||
|
"email": "simon@z.cash"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Ian Munoz",
|
||||||
|
"email": "ian.org@gmail.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bin": {
|
"bin": {
|
||||||
"bitcore-node": "./bin/bitcore-node",
|
"bitcore-node": "./bin/bitcore-node"
|
||||||
"bitcoind": "./bin/bitcoind"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"preinstall": "./scripts/download",
|
|
||||||
"verify": "./scripts/download --skip-bitcoin-download --verify-bitcoin-download",
|
|
||||||
"test": "mocha -R spec --recursive",
|
"test": "mocha -R spec --recursive",
|
||||||
"regtest": "./scripts/regtest",
|
"regtest": "./scripts/regtest",
|
||||||
"jshint": "jshint --reporter=node_modules/jshint-stylish ./lib",
|
"jshint": "jshint --reporter=node_modules/jshint-stylish ./lib",
|
||||||
|
@ -40,13 +49,13 @@
|
||||||
"coveralls": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- --recursive -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
|
"coveralls": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- --recursive -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
|
||||||
},
|
},
|
||||||
"tags": [
|
"tags": [
|
||||||
"bitcoin",
|
"zcash",
|
||||||
"bitcoind"
|
"zcashd"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "^1.3.0",
|
"async": "^1.3.0",
|
||||||
"bitcoind-rpc": "^0.6.0",
|
"bitcoind-rpc": "^0.6.0",
|
||||||
"bitcore-lib": "^0.13.13",
|
"bitcore-lib-zcash": "zcash-hackworks/bitcore-lib-zcash",
|
||||||
"body-parser": "^1.13.3",
|
"body-parser": "^1.13.3",
|
||||||
"colors": "^1.1.2",
|
"colors": "^1.1.2",
|
||||||
"commander": "^2.8.1",
|
"commander": "^2.8.1",
|
||||||
|
|
|
@ -7,7 +7,7 @@ var index = require('..');
|
||||||
var log = index.log;
|
var log = index.log;
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = require('chai');
|
||||||
var bitcore = require('bitcore-lib');
|
var bitcore = require('bitcore-lib-zcash');
|
||||||
var BN = bitcore.crypto.BN;
|
var BN = bitcore.crypto.BN;
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
var rimraf = require('rimraf');
|
var rimraf = require('rimraf');
|
||||||
|
@ -26,7 +26,7 @@ var coinbasePrivateKey;
|
||||||
var privateKey = bitcore.PrivateKey();
|
var privateKey = bitcore.PrivateKey();
|
||||||
var destKey = bitcore.PrivateKey();
|
var destKey = bitcore.PrivateKey();
|
||||||
|
|
||||||
describe('Bitcoind Functionality', function() {
|
describe('Zcashd Functionality', function() {
|
||||||
|
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
@ -46,7 +46,7 @@ describe('Bitcoind Functionality', function() {
|
||||||
bitcoind = require('../').services.Bitcoin({
|
bitcoind = require('../').services.Bitcoin({
|
||||||
spawn: {
|
spawn: {
|
||||||
datadir: datadir,
|
datadir: datadir,
|
||||||
exec: path.resolve(__dirname, '../bin/bitcoind')
|
exec: path.resolve(__dirname, '../bin/zcashd')
|
||||||
},
|
},
|
||||||
node: {
|
node: {
|
||||||
network: regtestNetwork,
|
network: regtestNetwork,
|
||||||
|
@ -60,10 +60,10 @@ describe('Bitcoind Functionality', function() {
|
||||||
log.error('error="%s"', err.message);
|
log.error('error="%s"', err.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info('Waiting for Bitcoin Core to initialize...');
|
log.info('Waiting for Zcash to initialize...');
|
||||||
|
|
||||||
bitcoind.start(function() {
|
bitcoind.start(function() {
|
||||||
log.info('Bitcoind started');
|
log.info('Zcashd started');
|
||||||
|
|
||||||
client = new BitcoinRPC({
|
client = new BitcoinRPC({
|
||||||
protocol: 'http',
|
protocol: 'http',
|
||||||
|
|
|
@ -6,7 +6,7 @@ var spawn = require('child_process').spawn;
|
||||||
|
|
||||||
var BitcoinRPC = require('bitcoind-rpc');
|
var BitcoinRPC = require('bitcoind-rpc');
|
||||||
var rimraf = require('rimraf');
|
var rimraf = require('rimraf');
|
||||||
var bitcore = require('bitcore-lib');
|
var bitcore = require('bitcore-lib-zcash');
|
||||||
var chai = require('chai');
|
var chai = require('chai');
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
|
@ -19,11 +19,11 @@ var BitcoinService = index.services.Bitcoin;
|
||||||
describe('Bitcoin Cluster', function() {
|
describe('Bitcoin Cluster', function() {
|
||||||
var node;
|
var node;
|
||||||
var daemons = [];
|
var daemons = [];
|
||||||
var execPath = path.resolve(__dirname, '../bin/bitcoind');
|
var execPath = path.resolve(__dirname, '../bin/zcashd');
|
||||||
var nodesConf = [
|
var nodesConf = [
|
||||||
{
|
{
|
||||||
datadir: path.resolve(__dirname, './data/node1'),
|
datadir: path.resolve(__dirname, './data/node1'),
|
||||||
conf: path.resolve(__dirname, './data/node1/bitcoin.conf'),
|
conf: path.resolve(__dirname, './data/node1/zcash.conf'),
|
||||||
rpcuser: 'bitcoin',
|
rpcuser: 'bitcoin',
|
||||||
rpcpassword: 'local321',
|
rpcpassword: 'local321',
|
||||||
rpcport: 30521,
|
rpcport: 30521,
|
||||||
|
@ -32,7 +32,7 @@ describe('Bitcoin Cluster', function() {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
datadir: path.resolve(__dirname, './data/node2'),
|
datadir: path.resolve(__dirname, './data/node2'),
|
||||||
conf: path.resolve(__dirname, './data/node2/bitcoin.conf'),
|
conf: path.resolve(__dirname, './data/node2/zcash.conf'),
|
||||||
rpcuser: 'bitcoin',
|
rpcuser: 'bitcoin',
|
||||||
rpcpassword: 'local321',
|
rpcpassword: 'local321',
|
||||||
rpcport: 30522,
|
rpcport: 30522,
|
||||||
|
@ -41,7 +41,7 @@ describe('Bitcoin Cluster', function() {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
datadir: path.resolve(__dirname, './data/node3'),
|
datadir: path.resolve(__dirname, './data/node3'),
|
||||||
conf: path.resolve(__dirname, './data/node3/bitcoin.conf'),
|
conf: path.resolve(__dirname, './data/node3/zcash.conf'),
|
||||||
rpcuser: 'bitcoin',
|
rpcuser: 'bitcoin',
|
||||||
rpcpassword: 'local321',
|
rpcpassword: 'local321',
|
||||||
rpcport: 30523,
|
rpcport: 30523,
|
||||||
|
|
|
@ -9,7 +9,7 @@ var log = index.log;
|
||||||
log.debug = function() {};
|
log.debug = function() {};
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = require('chai');
|
||||||
var bitcore = require('bitcore-lib');
|
var bitcore = require('bitcore-lib-zcash');
|
||||||
var rimraf = require('rimraf');
|
var rimraf = require('rimraf');
|
||||||
var node;
|
var node;
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ describe('Node Functionality', function() {
|
||||||
config: {
|
config: {
|
||||||
spawn: {
|
spawn: {
|
||||||
datadir: datadir,
|
datadir: datadir,
|
||||||
exec: path.resolve(__dirname, '../bin/bitcoind')
|
exec: path.resolve(__dirname, '../bin/zcashd')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ var p2p = require('bitcore-p2p');
|
||||||
var Peer = p2p.Peer;
|
var Peer = p2p.Peer;
|
||||||
var Messages = p2p.Messages;
|
var Messages = p2p.Messages;
|
||||||
var chai = require('chai');
|
var chai = require('chai');
|
||||||
var bitcore = require('bitcore-lib');
|
var bitcore = require('bitcore-lib-zcash');
|
||||||
var Transaction = bitcore.Transaction;
|
var Transaction = bitcore.Transaction;
|
||||||
var BN = bitcore.crypto.BN;
|
var BN = bitcore.crypto.BN;
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
|
@ -52,7 +52,7 @@ describe('P2P Functionality', function() {
|
||||||
bitcoind = require('../').services.Bitcoin({
|
bitcoind = require('../').services.Bitcoin({
|
||||||
spawn: {
|
spawn: {
|
||||||
datadir: datadir,
|
datadir: datadir,
|
||||||
exec: path.resolve(__dirname, '../bin/bitcoind')
|
exec: path.resolve(__dirname, '../bin/zcashd')
|
||||||
},
|
},
|
||||||
node: {
|
node: {
|
||||||
network: bitcore.Networks.testnet
|
network: bitcore.Networks.testnet
|
||||||
|
@ -63,13 +63,13 @@ describe('P2P Functionality', function() {
|
||||||
log.error('error="%s"', err.message);
|
log.error('error="%s"', err.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info('Waiting for Bitcoin Core to initialize...');
|
log.info('Waiting for Zcash to initialize...');
|
||||||
|
|
||||||
bitcoind.start(function(err) {
|
bitcoind.start(function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
log.info('Bitcoind started');
|
log.info('Zcashd started');
|
||||||
|
|
||||||
client = new BitcoinRPC({
|
client = new BitcoinRPC({
|
||||||
protocol: 'http',
|
protocol: 'http',
|
||||||
|
|
|
@ -7,7 +7,7 @@ platform=`uname -a | awk '{print tolower($1)}'`
|
||||||
arch=`uname -m`
|
arch=`uname -m`
|
||||||
version="0.12.1"
|
version="0.12.1"
|
||||||
url="https://github.com/bitpay/bitcoin/releases/download"
|
url="https://github.com/bitpay/bitcoin/releases/download"
|
||||||
tag="v0.12.1-bitcore"
|
tag="v0.12.1-bitcore-2"
|
||||||
|
|
||||||
if [ "${platform}" == "linux" ]; then
|
if [ "${platform}" == "linux" ]; then
|
||||||
if [ "${arch}" == "x86_64" ]; then
|
if [ "${arch}" == "x86_64" ]; then
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
var should = require('chai').should();
|
var should = require('chai').should();
|
||||||
var sinon = require('sinon');
|
var sinon = require('sinon');
|
||||||
var bitcore = require('bitcore-lib');
|
var bitcore = require('bitcore-lib-zcash');
|
||||||
var Networks = bitcore.Networks;
|
var Networks = bitcore.Networks;
|
||||||
var proxyquire = require('proxyquire');
|
var proxyquire = require('proxyquire');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
|
|
|
@ -94,7 +94,7 @@ describe('#add', function() {
|
||||||
var callCount = 0;
|
var callCount = 0;
|
||||||
var oldPackage = {
|
var oldPackage = {
|
||||||
dependencies: {
|
dependencies: {
|
||||||
'bitcore-lib': '^v0.13.7',
|
'bitcore-lib-zcash': '^v0.13.7',
|
||||||
'bitcore-node': '^v0.2.0'
|
'bitcore-node': '^v0.2.0'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,7 +33,7 @@ describe('#create', function() {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
mkdirp(testDir + '/.bitcoin', function(err) {
|
mkdirp(testDir + '/.zcash', function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ describe('#create', function() {
|
||||||
dirname: 'mynode3',
|
dirname: 'mynode3',
|
||||||
name: 'My Node 3',
|
name: 'My Node 3',
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
datadir: '../.bitcoin'
|
datadir: '../.zcash'
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -139,7 +139,7 @@ describe('#create', function() {
|
||||||
dirname: 'mynode4',
|
dirname: 'mynode4',
|
||||||
name: 'My Node 4',
|
name: 'My Node 4',
|
||||||
isGlobal: false,
|
isGlobal: false,
|
||||||
datadir: '../.bitcoin'
|
datadir: '../.zcash'
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
should.exist(err);
|
should.exist(err);
|
||||||
err.message.should.equal('There was an error installing dependencies.');
|
err.message.should.equal('There was an error installing dependencies.');
|
||||||
|
|
|
@ -14,8 +14,8 @@ describe('#defaultBaseConfig', function() {
|
||||||
info.config.port.should.equal(3001);
|
info.config.port.should.equal(3001);
|
||||||
info.config.services.should.deep.equal(['bitcoind', 'web']);
|
info.config.services.should.deep.equal(['bitcoind', 'web']);
|
||||||
var bitcoind = info.config.servicesConfig.bitcoind;
|
var bitcoind = info.config.servicesConfig.bitcoind;
|
||||||
bitcoind.spawn.datadir.should.equal(home + '/.bitcoin');
|
bitcoind.spawn.datadir.should.equal(home + '/.zcash');
|
||||||
bitcoind.spawn.exec.should.equal(path.resolve(__dirname, '../../bin/bitcoind'));
|
bitcoind.spawn.exec.should.equal(path.resolve(__dirname, '../../bin/zcashd'));
|
||||||
});
|
});
|
||||||
it('be able to specify a network', function() {
|
it('be able to specify a network', function() {
|
||||||
var info = defaultBaseConfig({network: 'testnet'});
|
var info = defaultBaseConfig({network: 'testnet'});
|
||||||
|
|
|
@ -6,7 +6,7 @@ var sinon = require('sinon');
|
||||||
var proxyquire = require('proxyquire');
|
var proxyquire = require('proxyquire');
|
||||||
|
|
||||||
describe('#defaultConfig', function() {
|
describe('#defaultConfig', function() {
|
||||||
var expectedExecPath = path.resolve(__dirname, '../../bin/bitcoind');
|
var expectedExecPath = path.resolve(__dirname, '../../bin/zcashd');
|
||||||
|
|
||||||
it('will return expected configuration', function() {
|
it('will return expected configuration', function() {
|
||||||
var config = JSON.stringify({
|
var config = JSON.stringify({
|
||||||
|
|
|
@ -6,7 +6,7 @@ var path = require('path');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
var EventEmitter = require('events').EventEmitter;
|
||||||
var should = require('chai').should();
|
var should = require('chai').should();
|
||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
var bitcore = require('bitcore-lib');
|
var bitcore = require('bitcore-lib-zcash');
|
||||||
var _ = bitcore.deps._;
|
var _ = bitcore.deps._;
|
||||||
var sinon = require('sinon');
|
var sinon = require('sinon');
|
||||||
var proxyquire = require('proxyquire');
|
var proxyquire = require('proxyquire');
|
||||||
|
@ -18,13 +18,13 @@ var log = index.log;
|
||||||
var errors = index.errors;
|
var errors = index.errors;
|
||||||
|
|
||||||
var Transaction = bitcore.Transaction;
|
var Transaction = bitcore.Transaction;
|
||||||
var readFileSync = sinon.stub().returns(fs.readFileSync(path.resolve(__dirname, '../data/bitcoin.conf')));
|
var readFileSync = sinon.stub().returns(fs.readFileSync(path.resolve(__dirname, '../data/zcash.conf')));
|
||||||
var BitcoinService = proxyquire('../../lib/services/bitcoind', {
|
var BitcoinService = proxyquire('../../lib/services/bitcoind', {
|
||||||
fs: {
|
fs: {
|
||||||
readFileSync: readFileSync
|
readFileSync: readFileSync
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var defaultBitcoinConf = fs.readFileSync(path.resolve(__dirname, '../data/default.bitcoin.conf'), 'utf8');
|
var defaultBitcoinConf = fs.readFileSync(path.resolve(__dirname, '../data/default.zcash.conf'), 'utf8');
|
||||||
|
|
||||||
describe('Bitcoin Service', function() {
|
describe('Bitcoin Service', function() {
|
||||||
var txhex = '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000';
|
var txhex = '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000';
|
||||||
|
@ -357,7 +357,7 @@ describe('Bitcoin Service', function() {
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
sandbox.restore();
|
sandbox.restore();
|
||||||
});
|
});
|
||||||
it('will parse a bitcoin.conf file', function() {
|
it('will parse a zcash.conf file', function() {
|
||||||
var TestBitcoin = proxyquire('../../lib/services/bitcoind', {
|
var TestBitcoin = proxyquire('../../lib/services/bitcoind', {
|
||||||
fs: {
|
fs: {
|
||||||
readFileSync: readFileSync,
|
readFileSync: readFileSync,
|
||||||
|
@ -369,7 +369,7 @@ describe('Bitcoin Service', function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var bitcoind = new TestBitcoin(baseConfig);
|
var bitcoind = new TestBitcoin(baseConfig);
|
||||||
bitcoind.options.spawn.datadir = '/tmp/.bitcoin';
|
bitcoind.options.spawn.datadir = '/tmp/.zcash';
|
||||||
var node = {};
|
var node = {};
|
||||||
bitcoind._loadSpawnConfiguration(node);
|
bitcoind._loadSpawnConfiguration(node);
|
||||||
should.exist(bitcoind.spawn.config);
|
should.exist(bitcoind.spawn.config);
|
||||||
|
@ -423,7 +423,7 @@ describe('Bitcoin Service', function() {
|
||||||
it('should throw an exception if txindex isn\'t enabled in the configuration', function() {
|
it('should throw an exception if txindex isn\'t enabled in the configuration', function() {
|
||||||
var TestBitcoin = proxyquire('../../lib/services/bitcoind', {
|
var TestBitcoin = proxyquire('../../lib/services/bitcoind', {
|
||||||
fs: {
|
fs: {
|
||||||
readFileSync: sinon.stub().returns(fs.readFileSync(__dirname + '/../data/badbitcoin.conf')),
|
readFileSync: sinon.stub().returns(fs.readFileSync(__dirname + '/../data/badzcash.conf')),
|
||||||
existsSync: sinon.stub().returns(true),
|
existsSync: sinon.stub().returns(true),
|
||||||
},
|
},
|
||||||
mkdirp: {
|
mkdirp: {
|
||||||
|
@ -466,7 +466,7 @@ describe('Bitcoin Service', function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var bitcoind = new TestBitcoin(config);
|
var bitcoind = new TestBitcoin(config);
|
||||||
bitcoind.options.spawn.datadir = '/tmp/.bitcoin';
|
bitcoind.options.spawn.datadir = '/tmp/.zcash';
|
||||||
var node = {};
|
var node = {};
|
||||||
bitcoind._loadSpawnConfiguration(node);
|
bitcoind._loadSpawnConfiguration(node);
|
||||||
});
|
});
|
||||||
|
@ -480,7 +480,7 @@ describe('Bitcoin Service', function() {
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
sandbox.restore();
|
sandbox.restore();
|
||||||
});
|
});
|
||||||
it('should warn the user if reindex is set to 1 in the bitcoin.conf file', function() {
|
it('should warn the user if reindex is set to 1 in the zcash.conf file', function() {
|
||||||
var bitcoind = new BitcoinService(baseConfig);
|
var bitcoind = new BitcoinService(baseConfig);
|
||||||
var config = {
|
var config = {
|
||||||
txindex: 1,
|
txindex: 1,
|
||||||
|
@ -829,7 +829,7 @@ describe('Bitcoin Service', function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var bitcoind = new BitcoinService(config);
|
var bitcoind = new BitcoinService(config);
|
||||||
bitcoind._getNetworkConfigPath().should.equal('testnet3/bitcoin.conf');
|
bitcoind._getNetworkConfigPath().should.equal('testnet3/zcash.conf');
|
||||||
});
|
});
|
||||||
it('will get default rpc port for regtest', function() {
|
it('will get default rpc port for regtest', function() {
|
||||||
bitcore.Networks.enableRegtest();
|
bitcore.Networks.enableRegtest();
|
||||||
|
@ -843,7 +843,7 @@ describe('Bitcoin Service', function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var bitcoind = new BitcoinService(config);
|
var bitcoind = new BitcoinService(config);
|
||||||
bitcoind._getNetworkConfigPath().should.equal('regtest/bitcoin.conf');
|
bitcoind._getNetworkConfigPath().should.equal('regtest/zcash.conf');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1749,7 +1749,7 @@ describe('Bitcoin Service', function() {
|
||||||
bitcoind._loadSpawnConfiguration = sinon.stub();
|
bitcoind._loadSpawnConfiguration = sinon.stub();
|
||||||
bitcoind.spawn = {};
|
bitcoind.spawn = {};
|
||||||
bitcoind.spawn.exec = 'testexec';
|
bitcoind.spawn.exec = 'testexec';
|
||||||
bitcoind.spawn.configPath = 'testdir/bitcoin.conf';
|
bitcoind.spawn.configPath = 'testdir/zcash.conf';
|
||||||
bitcoind.spawn.datadir = 'testdir';
|
bitcoind.spawn.datadir = 'testdir';
|
||||||
bitcoind.spawn.config = {};
|
bitcoind.spawn.config = {};
|
||||||
bitcoind.spawn.config.rpcport = 20001;
|
bitcoind.spawn.config.rpcport = 20001;
|
||||||
|
@ -1766,7 +1766,7 @@ describe('Bitcoin Service', function() {
|
||||||
spawn.callCount.should.equal(1);
|
spawn.callCount.should.equal(1);
|
||||||
spawn.args[0][0].should.equal('testexec');
|
spawn.args[0][0].should.equal('testexec');
|
||||||
spawn.args[0][1].should.deep.equal([
|
spawn.args[0][1].should.deep.equal([
|
||||||
'--conf=testdir/bitcoin.conf',
|
'--conf=testdir/zcash.conf',
|
||||||
'--datadir=testdir',
|
'--datadir=testdir',
|
||||||
'--testnet'
|
'--testnet'
|
||||||
]);
|
]);
|
||||||
|
@ -1800,7 +1800,7 @@ describe('Bitcoin Service', function() {
|
||||||
bitcoind.spawn = {};
|
bitcoind.spawn = {};
|
||||||
bitcoind.spawn.exec = 'bitcoind';
|
bitcoind.spawn.exec = 'bitcoind';
|
||||||
bitcoind.spawn.datadir = '/tmp/bitcoin';
|
bitcoind.spawn.datadir = '/tmp/bitcoin';
|
||||||
bitcoind.spawn.configPath = '/tmp/bitcoin/bitcoin.conf';
|
bitcoind.spawn.configPath = '/tmp/bitcoin/zcash.conf';
|
||||||
bitcoind.spawn.config = {};
|
bitcoind.spawn.config = {};
|
||||||
bitcoind.spawnRestartTime = 1;
|
bitcoind.spawnRestartTime = 1;
|
||||||
bitcoind._loadTipFromNode = sinon.stub().callsArg(1);
|
bitcoind._loadTipFromNode = sinon.stub().callsArg(1);
|
||||||
|
@ -1838,7 +1838,7 @@ describe('Bitcoin Service', function() {
|
||||||
bitcoind.spawn = {};
|
bitcoind.spawn = {};
|
||||||
bitcoind.spawn.exec = 'bitcoind';
|
bitcoind.spawn.exec = 'bitcoind';
|
||||||
bitcoind.spawn.datadir = '/tmp/bitcoin';
|
bitcoind.spawn.datadir = '/tmp/bitcoin';
|
||||||
bitcoind.spawn.configPath = '/tmp/bitcoin/bitcoin.conf';
|
bitcoind.spawn.configPath = '/tmp/bitcoin/zcash.conf';
|
||||||
bitcoind.spawn.config = {};
|
bitcoind.spawn.config = {};
|
||||||
bitcoind.spawnRestartTime = 1;
|
bitcoind.spawnRestartTime = 1;
|
||||||
bitcoind._loadTipFromNode = sinon.stub().callsArg(1);
|
bitcoind._loadTipFromNode = sinon.stub().callsArg(1);
|
||||||
|
@ -1885,7 +1885,7 @@ describe('Bitcoin Service', function() {
|
||||||
bitcoind.spawn = {};
|
bitcoind.spawn = {};
|
||||||
bitcoind.spawn.exec = 'bitcoind';
|
bitcoind.spawn.exec = 'bitcoind';
|
||||||
bitcoind.spawn.datadir = '/tmp/bitcoin';
|
bitcoind.spawn.datadir = '/tmp/bitcoin';
|
||||||
bitcoind.spawn.configPath = '/tmp/bitcoin/bitcoin.conf';
|
bitcoind.spawn.configPath = '/tmp/bitcoin/zcash.conf';
|
||||||
bitcoind.spawn.config = {};
|
bitcoind.spawn.config = {};
|
||||||
bitcoind.spawnRestartTime = 1;
|
bitcoind.spawnRestartTime = 1;
|
||||||
bitcoind._loadTipFromNode = sinon.stub().callsArg(1);
|
bitcoind._loadTipFromNode = sinon.stub().callsArg(1);
|
||||||
|
@ -1924,7 +1924,7 @@ describe('Bitcoin Service', function() {
|
||||||
bitcoind._loadSpawnConfiguration = sinon.stub();
|
bitcoind._loadSpawnConfiguration = sinon.stub();
|
||||||
bitcoind.spawn = {};
|
bitcoind.spawn = {};
|
||||||
bitcoind.spawn.exec = 'testexec';
|
bitcoind.spawn.exec = 'testexec';
|
||||||
bitcoind.spawn.configPath = 'testdir/bitcoin.conf';
|
bitcoind.spawn.configPath = 'testdir/zcash.conf';
|
||||||
bitcoind.spawn.datadir = 'testdir';
|
bitcoind.spawn.datadir = 'testdir';
|
||||||
bitcoind.spawn.config = {};
|
bitcoind.spawn.config = {};
|
||||||
bitcoind.spawn.config.rpcport = 20001;
|
bitcoind.spawn.config.rpcport = 20001;
|
||||||
|
@ -1954,7 +1954,7 @@ describe('Bitcoin Service', function() {
|
||||||
bitcoind._loadSpawnConfiguration = sinon.stub();
|
bitcoind._loadSpawnConfiguration = sinon.stub();
|
||||||
bitcoind.spawn = {};
|
bitcoind.spawn = {};
|
||||||
bitcoind.spawn.exec = 'testexec';
|
bitcoind.spawn.exec = 'testexec';
|
||||||
bitcoind.spawn.configPath = 'testdir/bitcoin.conf';
|
bitcoind.spawn.configPath = 'testdir/zcash.conf';
|
||||||
bitcoind.spawn.datadir = 'testdir';
|
bitcoind.spawn.datadir = 'testdir';
|
||||||
bitcoind.spawn.config = {};
|
bitcoind.spawn.config = {};
|
||||||
bitcoind.spawn.config.rpcport = 20001;
|
bitcoind.spawn.config.rpcport = 20001;
|
||||||
|
|
Loading…
Reference in New Issue