diff --git a/lib/node.js b/lib/node.js index 7853dc11..737cd307 100644 --- a/lib/node.js +++ b/lib/node.js @@ -71,19 +71,7 @@ Node.prototype._setNetwork = function(config) { if (config.network === 'testnet') { this.network = Networks.get('testnet'); } else if (config.network === 'regtest') { - Networks.remove(Networks.testnet); - Networks.add({ - name: 'regtest', - alias: 'regtest', - pubkeyhash: 0x6f, - privatekey: 0xef, - scripthash: 0xc4, - xpubkey: 0x043587cf, - xprivkey: 0x04358394, - networkMagic: 0xfabfb5da, - port: 18444, - dnsSeeds: [ ] - }); + Networks.enableRegtest(); this.network = Networks.get('regtest'); } else { this.network = Networks.defaultNetwork; diff --git a/lib/services/address/index.js b/lib/services/address/index.js index 61eed5ef..486ef0f4 100644 --- a/lib/services/address/index.js +++ b/lib/services/address/index.js @@ -121,13 +121,14 @@ AddressService.prototype._setMempoolIndexPath = function() { AddressService.prototype._getDBPathFor = function(dbname) { $.checkState(this.node.datadir, 'Node is expected to have a "datadir" property'); var path; - var regtest = Networks.get('regtest'); if (this.node.network === Networks.livenet) { path = this.node.datadir + '/' + dbname; } else if (this.node.network === Networks.testnet) { - path = this.node.datadir + '/testnet3/' + dbname; - } else if (this.node.network === regtest) { - path = this.node.datadir + '/regtest/' + dbname; + if (this.node.network.regtestEnabled) { + path = this.node.datadir + '/regtest/' + dbname; + } else { + path = this.node.datadir + '/testnet3/' + dbname; + } } else { throw new Error('Unknown network: ' + this.network); } diff --git a/lib/services/bitcoind.js b/lib/services/bitcoind.js index e7a67467..edc2dad6 100644 --- a/lib/services/bitcoind.js +++ b/lib/services/bitcoind.js @@ -154,9 +154,14 @@ Bitcoin.prototype.start = function(callback) { this._loadConfiguration(); + var networkName = this.node.network.name; + if (this.node.network.regtestEnabled) { + networkName = 'regtest'; + } + bindings.start({ datadir: this.node.datadir, - network: this.node.network.name + network: networkName }, function(err) { if(err) { return callback(err); diff --git a/lib/services/db.js b/lib/services/db.js index eca15bff..679935ca 100644 --- a/lib/services/db.js +++ b/lib/services/db.js @@ -89,13 +89,14 @@ DB.DEFAULT_MAX_OPEN_FILES = 200; */ DB.prototype._setDataPath = function() { $.checkState(this.node.datadir, 'Node is expected to have a "datadir" property'); - var regtest = Networks.get('regtest'); if (this.node.network === Networks.livenet) { this.dataPath = this.node.datadir + '/bitcore-node.db'; } else if (this.node.network === Networks.testnet) { - this.dataPath = this.node.datadir + '/testnet3/bitcore-node.db'; - } else if (this.node.network === regtest) { - this.dataPath = this.node.datadir + '/regtest/bitcore-node.db'; + if (this.node.network.regtestEnabled) { + this.dataPath = this.node.datadir + '/regtest/bitcore-node.db'; + } else { + this.dataPath = this.node.datadir + '/testnet3/bitcore-node.db'; + } } else { throw new Error('Unknown network: ' + this.network); }