Skip to content

Commit

Permalink
Merge pull request #41 from ajp8164/master
Browse files Browse the repository at this point in the history
Rename cleanup
  • Loading branch information
Andy Phillipson committed Sep 29, 2017
2 parents 9277b46 + f2a5f74 commit 46b46e0
Show file tree
Hide file tree
Showing 23 changed files with 166 additions and 166 deletions.
4 changes: 2 additions & 2 deletions bin/btcnode
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node

var btc = require('../lib/cli/btc');
btc();
var btcnode = require('../lib/cli/btcnode');
btcnode();
8 changes: 4 additions & 4 deletions docs/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ _Note:_ If you already have a btc-node database, and you want to query data from
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 btc
var btc = require('btc-node');
//Require btcNode
var btcNode = require('btc-node');

//Services
var Bitcoin = btc.services.Bitcoin;
var Web = btc.services.Web;
var Bitcoin = btcNode.services.Bitcoin;
var Web = btcNode.services.Web;

var myNode = new btc.Node({
network: 'regtest'
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports.scaffold.defaultConfig = require('./lib/scaffold/default-config')
module.exports.cli = {};
module.exports.cli.main = require('./lib/cli/main');
module.exports.cli.daemon = require('./lib/cli/daemon');
module.exports.cli.btc = require('./lib/cli/btc');
module.exports.cli.btcd = require('./lib/cli/btcd');
module.exports.cli.btcnode = require('./lib/cli/btcnode');
module.exports.cli.btcnoded = require('./lib/cli/btcnoded');

module.exports.lib = require('btc-lib');
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/cli/btcd.js → lib/cli/btcnoded.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ var Liftoff = require('liftoff');
function main(parentServicesPath, additionalServices) {

var liftoff = new Liftoff({
name: 'btcd',
name: 'btcnoded',
moduleName: 'btc-node',
configName: 'btc-node',
processTitle: 'btcd'
processTitle: 'btcnoded'
}).on('require', function (name) {
console.log('Loading:', name);
}).on('requireFail', function (name, err) {
Expand Down
10 changes: 5 additions & 5 deletions lib/cli/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

var program = require('commander');
var path = require('path');
var btc = require('..');
var btcNode = require('..');

function main(servicesPath, additionalServices) {
/* jshint maxstatements: 100 */

var version = btc.version;
var start = btc.scaffold.start;
var findConfig = btc.scaffold.findConfig;
var defaultConfig = btc.scaffold.defaultConfig;
var version = btcNode.version;
var start = btcNode.scaffold.start;
var findConfig = btcNode.scaffold.findConfig;
var defaultConfig = btcNode.scaffold.defaultConfig;

program
.version(version)
Expand Down
4 changes: 2 additions & 2 deletions lib/logger.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var btc = require('btc-lib');
var _ = btc.deps._;
var btcLib = require('btc-lib');
var _ = btcLib.deps._;
var colors = require('colors/safe');

/**
Expand Down
8 changes: 4 additions & 4 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
var util = require('util');
var EventEmitter = require('events').EventEmitter;
var async = require('async');
var btc = require('btc-lib');
var Networks = btc.Networks;
var $ = btc.util.preconditions;
var _ = btc.deps._;
var btcLib = require('btc-lib');
var Networks = btcLib.Networks;
var $ = btcLib.util.preconditions;
var _ = btcLib.deps._;
var index = require('./');
var log = index.log;
var Bus = require('./bus');
Expand Down
12 changes: 6 additions & 6 deletions lib/scaffold/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ var async = require('async');
var fs = require('fs');
var path = require('path');
var spawn = require('child_process').spawn;
var btc = require('btc-lib');
var btcLib = require('btc-lib');
var utils = require('../utils');
var $ = btc.util.preconditions;
var _ = btc.deps._;
var $ = btcLib.util.preconditions;
var _ = btcLib.deps._;

/**
* @param {String} configFilePath - The absolute path to the configuration file
Expand Down Expand Up @@ -78,10 +78,10 @@ function add(options, done) {
var configPath = options.path;
var services = options.services;

var btcConfigPath = path.resolve(configPath, 'btc-node.json');
var btcNodeConfigPath = path.resolve(configPath, 'btc-node.json');
var packagePath = path.resolve(configPath, 'package.json');

if (!fs.existsSync(btcConfigPath) || !fs.existsSync(packagePath)) {
if (!fs.existsSync(btcNodeConfigPath) || !fs.existsSync(packagePath)) {
return done(
new Error('Directory does not have a btc-node.json and/or package.json file.')
);
Expand Down Expand Up @@ -109,7 +109,7 @@ function add(options, done) {
var serviceName = newDependencies[0];

// add service to btc-node.json
addConfig(btcConfigPath, serviceName, next);
addConfig(btcNodeConfigPath, serviceName, next);
});
}, done
);
Expand Down
6 changes: 3 additions & 3 deletions lib/scaffold/create.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

var spawn = require('child_process').spawn;
var btc = require('btc-lib');
var btcLib = require('btc-lib');
var async = require('async');
var $ = btc.util.preconditions;
var _ = btc.deps._;
var $ = btcLib.util.preconditions;
var _ = btcLib.deps._;
var path = require('path');
// var packageFile = require('../../package.json');
var mkdirp = require('mkdirp');
Expand Down
6 changes: 3 additions & 3 deletions lib/scaffold/find-config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

var btc = require('btc-lib');
var $ = btc.util.preconditions;
var _ = btc.deps._;
var btcLib = require('btc-lib');
var $ = btcLib.util.preconditions;
var _ = btcLib.deps._;
var path = require('path');
var fs = require('fs');
var utils = require('../utils');
Expand Down
12 changes: 6 additions & 6 deletions lib/scaffold/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ var async = require('async');
var fs = require('fs');
var path = require('path');
var spawn = require('child_process').spawn;
var btc = require('btc-lib');
var $ = btc.util.preconditions;
var _ = btc.deps._;
var btcLib = require('btc-lib');
var $ = btcLib.util.preconditions;
var _ = btcLib.deps._;
var utils = require('../utils');

/**
Expand Down Expand Up @@ -100,10 +100,10 @@ function remove(options, done) {
var configPath = options.path;
var services = options.services;

var btcConfigPath = path.resolve(configPath, 'btc-node.json');
var btcNodeConfigPath = path.resolve(configPath, 'btc-node.json');
var packagePath = path.resolve(configPath, 'package.json');

if (!fs.existsSync(btcConfigPath) || !fs.existsSync(packagePath)) {
if (!fs.existsSync(btcNodeConfigPath) || !fs.existsSync(packagePath)) {
return done(
new Error('Directory does not have a btc-node.json and/or package.json file.')
);
Expand All @@ -118,7 +118,7 @@ function remove(options, done) {
return next(err);
}
// remove service to btc-node.json
removeConfig(btcConfigPath, service, next);
removeConfig(btcNodeConfigPath, service, next);
});
}, done
);
Expand Down
4 changes: 2 additions & 2 deletions lib/scaffold/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
var path = require('path');
var BtcNode = require('../node');
var index = require('../');
var btc = require('btc-lib');
var _ = btc.deps._;
var btcLib = require('btc-lib');
var _ = btcLib.deps._;
var log = index.log;
var shuttingDown = false;

Expand Down
28 changes: 14 additions & 14 deletions lib/services/bitcoind.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ var fs = require('fs');
var path = require('path');
var util = require('util');
var mkdirp = require('mkdirp');
var btc = require('btc-lib');
var btcLib = require('btc-lib');
var zmq = require('zeromq');
var async = require('async');
var LRU = require('lru-cache');
var BitcoinRPC = require('bitcoind-rpc');
var $ = btc.util.preconditions;
var _ = btc.deps._;
var Transaction = btc.Transaction;
var $ = btcLib.util.preconditions;
var _ = btcLib.deps._;
var Transaction = btcLib.Transaction;

var index = require('../');
var errors = index.errors;
Expand Down Expand Up @@ -236,7 +236,7 @@ Bitcoin.prototype.subscribeAddress = function(emitter, addresses) {
}

for(var i = 0; i < addresses.length; i++) {
if (btc.Address.isValid(addresses[i], this.node.network)) {
if (btcLib.Address.isValid(addresses[i], this.node.network)) {
addAddress(addresses[i]);
}
}
Expand Down Expand Up @@ -394,7 +394,7 @@ Bitcoin.prototype._checkConfigIndexes = function(spawnConfig, node) {

$.checkState(
spawnConfig.server && spawnConfig.server === 1,
'"server" option is required to communicate to bitcoind from btc. ' +
'"server" option is required to communicate to bitcoind from btc-node. ' +
'Please add "server=1" to your configuration and restart'
);

Expand Down Expand Up @@ -489,15 +489,15 @@ Bitcoin.prototype._getDefaultConf = function() {
var networkOptions = {
rpcport: 8332
};
if (this.node.network === btc.Networks.testnet) {
if (this.node.network === btcLib.Networks.testnet) {
networkOptions.rpcport = 18332;
}
return networkOptions;
};

Bitcoin.prototype._getNetworkConfigPath = function() {
var networkPath;
if (this.node.network === btc.Networks.testnet) {
if (this.node.network === btcLib.Networks.testnet) {
networkPath = 'testnet3/bitcoin.conf';
if (this.node.network.regtestEnabled) {
networkPath = 'regtest/bitcoin.conf';
Expand All @@ -508,7 +508,7 @@ Bitcoin.prototype._getNetworkConfigPath = function() {

Bitcoin.prototype._getNetworkOption = function() {
var networkOption;
if (this.node.network === btc.Networks.testnet) {
if (this.node.network === btcLib.Networks.testnet) {
networkOption = '--testnet';
if (this.node.network.regtestEnabled) {
networkOption = '--regtest';
Expand Down Expand Up @@ -631,7 +631,7 @@ Bitcoin.prototype._notifyAddressTxidSubscribers = function(txid, transaction) {

Bitcoin.prototype._zmqTransactionHandler = function(node, message) {
var self = this;
var hash = btc.crypto.Hash.sha256sha256(message);
var hash = btcLib.crypto.Hash.sha256sha256(message);
var id = hash.toString('binary');
if (!self.zmqKnownTransactions.get(id)) {
self.zmqKnownTransactions.set(id, true);
Expand All @@ -642,7 +642,7 @@ Bitcoin.prototype._zmqTransactionHandler = function(node, message) {
this.subscriptions.rawtransaction[i].emit('bitcoind/rawtransaction', message.toString('hex'));
}

var tx = btc.Transaction();
var tx = btcLib.Transaction();
tx.fromString(message);
var txid = tx.id;
self._notifyAddressTxidSubscribers(txid, tx);
Expand Down Expand Up @@ -1058,7 +1058,7 @@ Bitcoin.prototype.getAddressUnspentOutputs = function(addressArg, options, callb
var utxos = self.utxosCache.get(cacheKey);

function transformUnspentOutput(delta) {
var script = btc.Script.fromAddress(delta.address);
var script = btcLib.Script.fromAddress(delta.address);
return {
address: delta.address,
txid: delta.txid,
Expand Down Expand Up @@ -1349,7 +1349,7 @@ Bitcoin.prototype._getAddressStrings = function(addresses) {
var addressStrings = [];
for (var i = 0; i < addresses.length; i++) {
var address = addresses[i];
if (address instanceof btc.Address) {
if (address instanceof btcLib.Address) {
addressStrings.push(address.toString());
} else if (_.isString(address)) {
addressStrings.push(address);
Expand Down Expand Up @@ -1655,7 +1655,7 @@ Bitcoin.prototype.getBlock = function(blockArg, callback) {
if (err) {
return done(self._wrapRPCError(err));
}
var blockObj = btc.Block.fromString(response.result);
var blockObj = btcLib.Block.fromString(response.result);
self.blockCache.set(blockhash, blockObj);
done(null, blockObj);
});
Expand Down
4 changes: 2 additions & 2 deletions lib/services/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ var socketio = require('socket.io');
var inherits = require('util').inherits;

var BaseService = require('../service');
var btc = require('btc-lib');
var _ = btc.deps._;
var btcLib = require('btc-lib');
var _ = btcLib.deps._;
var index = require('../');
var log = index.log;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "btc-node",
"description": "Bitcoin Core full node with extended capabilities using Btc.",
"description": "Bitcoin Core full node with extended capabilities.",
"version": "0.0.1",
"main": "./index.js",
"repository": "git://github.com/owstack/btc-node.git",
Expand Down

0 comments on commit 46b46e0

Please sign in to comment.