Add regtest from bitcore-lib
This commit is contained in:
parent
8afb2b8669
commit
6e8f3ee917
14
lib/node.js
14
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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue