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') {
|
if (config.network === 'testnet') {
|
||||||
this.network = Networks.get('testnet');
|
this.network = Networks.get('testnet');
|
||||||
} else if (config.network === 'regtest') {
|
} else if (config.network === 'regtest') {
|
||||||
Networks.remove(Networks.testnet);
|
Networks.enableRegtest();
|
||||||
Networks.add({
|
|
||||||
name: 'regtest',
|
|
||||||
alias: 'regtest',
|
|
||||||
pubkeyhash: 0x6f,
|
|
||||||
privatekey: 0xef,
|
|
||||||
scripthash: 0xc4,
|
|
||||||
xpubkey: 0x043587cf,
|
|
||||||
xprivkey: 0x04358394,
|
|
||||||
networkMagic: 0xfabfb5da,
|
|
||||||
port: 18444,
|
|
||||||
dnsSeeds: [ ]
|
|
||||||
});
|
|
||||||
this.network = Networks.get('regtest');
|
this.network = Networks.get('regtest');
|
||||||
} else {
|
} else {
|
||||||
this.network = Networks.defaultNetwork;
|
this.network = Networks.defaultNetwork;
|
||||||
|
|||||||
@ -121,13 +121,14 @@ AddressService.prototype._setMempoolIndexPath = function() {
|
|||||||
AddressService.prototype._getDBPathFor = function(dbname) {
|
AddressService.prototype._getDBPathFor = function(dbname) {
|
||||||
$.checkState(this.node.datadir, 'Node is expected to have a "datadir" property');
|
$.checkState(this.node.datadir, 'Node is expected to have a "datadir" property');
|
||||||
var path;
|
var path;
|
||||||
var regtest = Networks.get('regtest');
|
|
||||||
if (this.node.network === Networks.livenet) {
|
if (this.node.network === Networks.livenet) {
|
||||||
path = this.node.datadir + '/' + dbname;
|
path = this.node.datadir + '/' + dbname;
|
||||||
} else if (this.node.network === Networks.testnet) {
|
} else if (this.node.network === Networks.testnet) {
|
||||||
path = this.node.datadir + '/testnet3/' + dbname;
|
if (this.node.network.regtestEnabled) {
|
||||||
} else if (this.node.network === regtest) {
|
path = this.node.datadir + '/regtest/' + dbname;
|
||||||
path = this.node.datadir + '/regtest/' + dbname;
|
} else {
|
||||||
|
path = this.node.datadir + '/testnet3/' + dbname;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Unknown network: ' + this.network);
|
throw new Error('Unknown network: ' + this.network);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -154,9 +154,14 @@ Bitcoin.prototype.start = function(callback) {
|
|||||||
|
|
||||||
this._loadConfiguration();
|
this._loadConfiguration();
|
||||||
|
|
||||||
|
var networkName = this.node.network.name;
|
||||||
|
if (this.node.network.regtestEnabled) {
|
||||||
|
networkName = 'regtest';
|
||||||
|
}
|
||||||
|
|
||||||
bindings.start({
|
bindings.start({
|
||||||
datadir: this.node.datadir,
|
datadir: this.node.datadir,
|
||||||
network: this.node.network.name
|
network: networkName
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
|||||||
@ -89,13 +89,14 @@ DB.DEFAULT_MAX_OPEN_FILES = 200;
|
|||||||
*/
|
*/
|
||||||
DB.prototype._setDataPath = function() {
|
DB.prototype._setDataPath = function() {
|
||||||
$.checkState(this.node.datadir, 'Node is expected to have a "datadir" property');
|
$.checkState(this.node.datadir, 'Node is expected to have a "datadir" property');
|
||||||
var regtest = Networks.get('regtest');
|
|
||||||
if (this.node.network === Networks.livenet) {
|
if (this.node.network === Networks.livenet) {
|
||||||
this.dataPath = this.node.datadir + '/bitcore-node.db';
|
this.dataPath = this.node.datadir + '/bitcore-node.db';
|
||||||
} else if (this.node.network === Networks.testnet) {
|
} else if (this.node.network === Networks.testnet) {
|
||||||
this.dataPath = this.node.datadir + '/testnet3/bitcore-node.db';
|
if (this.node.network.regtestEnabled) {
|
||||||
} else if (this.node.network === regtest) {
|
this.dataPath = this.node.datadir + '/regtest/bitcore-node.db';
|
||||||
this.dataPath = this.node.datadir + '/regtest/bitcore-node.db';
|
} else {
|
||||||
|
this.dataPath = this.node.datadir + '/testnet3/bitcore-node.db';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Unknown network: ' + this.network);
|
throw new Error('Unknown network: ' + this.network);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user