BTC -> Flo
This commit is contained in:
parent
79855ff4c2
commit
aafc5911f4
116
README.md
116
README.md
@ -1,26 +1,26 @@
|
||||
# Insight API
|
||||
# Flosight API
|
||||
|
||||
A Bitcoin blockchain REST and web socket API service for [Bitcore Node](https://github.com/bitpay/bitcore-node).
|
||||
A Florincoin blockchain REST and web socket API service for [Flocore Node](https://github.com/bitpay/flocore-node).
|
||||
|
||||
This is a backend-only service. If you're looking for the web frontend application, take a look at https://github.com/bitpay/insight-ui.
|
||||
This is a backend-only service. If you're looking for the web frontend application, take a look at https://github.com/bitpay/flosight-ui.
|
||||
|
||||
## Getting Started
|
||||
|
||||
```bashl
|
||||
npm install -g bitcore@latest
|
||||
bitcore create mynode
|
||||
npm install -g flocore@latest
|
||||
flocore create mynode
|
||||
cd mynode
|
||||
bitcore install insight-api
|
||||
bitcore start
|
||||
flocore install flosight-api
|
||||
flocore start
|
||||
```
|
||||
|
||||
The API endpoints will be available by default at: `http://localhost:3001/insight-api/`
|
||||
The API endpoints will be available by default at: `http://localhost:3001/flosight-api/`
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Bitcore 5.x](https://github.com/bitpay/bitcore)
|
||||
- [Flocore 5.x](https://github.com/bitpay/flocore)
|
||||
|
||||
**Note:** You can use an existing Bitcoin data directory, however `txindex`, `addressindex`, `timestampindex` and `spentindex` needs to be set to true in `bitcoin.conf`, as well as a few other additional fields.
|
||||
**Note:** You can use an existing Florincoin data directory, however `txindex`, `addressindex`, `timestampindex` and `spentindex` needs to be set to true in `florincoin.conf`, as well as a few other additional fields.
|
||||
|
||||
## Notes on Upgrading from v0.3
|
||||
|
||||
@ -69,8 +69,8 @@ There are a few changes to the `GET` endpoint for `/addr/[:address]`:
|
||||
|
||||
Some additional general notes:
|
||||
- The transaction history for an address will be sorted in block order
|
||||
- The response for the `/sync` endpoint does not include `startTs` and `endTs` as the sync is no longer relevant as indexes are built in bitcoind.
|
||||
- The endpoint for `/peer` is no longer relevant connection to bitcoind is via ZMQ.
|
||||
- The response for the `/sync` endpoint does not include `startTs` and `endTs` as the sync is no longer relevant as indexes are built in florincoind.
|
||||
- The endpoint for `/peer` is no longer relevant connection to florincoind is via ZMQ.
|
||||
- `/tx` endpoint results will now include block height, and spentTx related fields will be set to `null` if unspent.
|
||||
- `/block` endpoint results does not include `confirmations` and will include `poolInfo`.
|
||||
|
||||
@ -89,9 +89,9 @@ The `/tx/<txid>` endpoint JSON response will not include the following fields on
|
||||
object.
|
||||
- `spentTs`
|
||||
|
||||
The `/status?q=getTxOutSetInfo` method has also been removed due to the query being very slow and locking bitcoind.
|
||||
The `/status?q=getTxOutSetInfo` method has also been removed due to the query being very slow and locking florincoind.
|
||||
|
||||
Plug-in support for Insight API is also no longer available, as well as the endpoints:
|
||||
Plug-in support for Flosight API is also no longer available, as well as the endpoints:
|
||||
- `/email/retrieve`
|
||||
- `/rates/:code`
|
||||
|
||||
@ -99,22 +99,22 @@ Caching support has not yet been added in the v0.3 upgrade.
|
||||
|
||||
## Query Rate Limit
|
||||
|
||||
To protect the server, insight-api has a built it query rate limiter. It can be configurable in `bitcore-node.json` with:
|
||||
To protect the server, flosight-api has a built it query rate limiter. It can be configurable in `flocore-node.json` with:
|
||||
``` json
|
||||
"servicesConfig": {
|
||||
"insight-api": {
|
||||
"flosight-api": {
|
||||
"rateLimiterOptions": {
|
||||
"whitelist": ["::ffff:127.0.0.1"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
With all the configuration options available: https://github.com/bitpay/insight-api/blob/master/lib/ratelimiter.js#L10-17
|
||||
With all the configuration options available: https://github.com/bitpay/flosight-api/blob/master/lib/ratelimiter.js#L10-17
|
||||
|
||||
Or disabled entirely with:
|
||||
``` json
|
||||
"servicesConfig": {
|
||||
"insight-api": {
|
||||
"flosight-api": {
|
||||
"disableRateLimiter": true
|
||||
}
|
||||
}
|
||||
@ -125,15 +125,15 @@ Or disabled entirely with:
|
||||
|
||||
### Block
|
||||
```
|
||||
/insight-api/block/[:hash]
|
||||
/insight-api/block/00000000a967199a2fad0877433c93df785a8d8ce062e5f9b451cd1397bdbf62
|
||||
/flosight-api/block/[:hash]
|
||||
/flosight-api/block/00000000a967199a2fad0877433c93df785a8d8ce062e5f9b451cd1397bdbf62
|
||||
```
|
||||
|
||||
### Block Index
|
||||
Get block hash by height
|
||||
```
|
||||
/insight-api/block-index/[:height]
|
||||
/insight-api/block-index/0
|
||||
/flosight-api/block-index/[:height]
|
||||
/flosight-api/block-index/0
|
||||
```
|
||||
This would return:
|
||||
```
|
||||
@ -146,8 +146,8 @@ which is the hash of the Genesis block (0 height)
|
||||
|
||||
### Raw Block
|
||||
```
|
||||
/insight-api/rawblock/[:blockHash]
|
||||
/insight-api/rawblock/[:blockHeight]
|
||||
/flosight-api/rawblock/[:blockHash]
|
||||
/flosight-api/rawblock/[:blockHeight]
|
||||
```
|
||||
|
||||
This would return:
|
||||
@ -161,7 +161,7 @@ This would return:
|
||||
|
||||
Get block summaries by date:
|
||||
```
|
||||
/insight-api/blocks?limit=3&blockDate=2016-04-22
|
||||
/flosight-api/blocks?limit=3&blockDate=2016-04-22
|
||||
```
|
||||
|
||||
Example response:
|
||||
@ -195,31 +195,31 @@ Example response:
|
||||
|
||||
### Transaction
|
||||
```
|
||||
/insight-api/tx/[:txid]
|
||||
/insight-api/tx/525de308971eabd941b139f46c7198b5af9479325c2395db7f2fb5ae8562556c
|
||||
/insight-api/rawtx/[:rawid]
|
||||
/insight-api/rawtx/525de308971eabd941b139f46c7198b5af9479325c2395db7f2fb5ae8562556c
|
||||
/flosight-api/tx/[:txid]
|
||||
/flosight-api/tx/525de308971eabd941b139f46c7198b5af9479325c2395db7f2fb5ae8562556c
|
||||
/flosight-api/rawtx/[:rawid]
|
||||
/flosight-api/rawtx/525de308971eabd941b139f46c7198b5af9479325c2395db7f2fb5ae8562556c
|
||||
```
|
||||
|
||||
### Address
|
||||
```
|
||||
/insight-api/addr/[:addr][?noTxList=1][&from=&to=]
|
||||
/insight-api/addr/mmvP3mTe53qxHdPqXEvdu8WdC7GfQ2vmx5?noTxList=1
|
||||
/insight-api/addr/mmvP3mTe53qxHdPqXEvdu8WdC7GfQ2vmx5?from=1000&to=2000
|
||||
/flosight-api/addr/[:addr][?noTxList=1][&from=&to=]
|
||||
/flosight-api/addr/mmvP3mTe53qxHdPqXEvdu8WdC7GfQ2vmx5?noTxList=1
|
||||
/flosight-api/addr/mmvP3mTe53qxHdPqXEvdu8WdC7GfQ2vmx5?from=1000&to=2000
|
||||
```
|
||||
|
||||
### Address Properties
|
||||
```
|
||||
/insight-api/addr/[:addr]/balance
|
||||
/insight-api/addr/[:addr]/totalReceived
|
||||
/insight-api/addr/[:addr]/totalSent
|
||||
/insight-api/addr/[:addr]/unconfirmedBalance
|
||||
/flosight-api/addr/[:addr]/balance
|
||||
/flosight-api/addr/[:addr]/totalReceived
|
||||
/flosight-api/addr/[:addr]/totalSent
|
||||
/flosight-api/addr/[:addr]/unconfirmedBalance
|
||||
```
|
||||
The response contains the value in Satoshis.
|
||||
|
||||
### Unspent Outputs
|
||||
```
|
||||
/insight-api/addr/[:addr]/utxo
|
||||
/flosight-api/addr/[:addr]/utxo
|
||||
```
|
||||
Sample return:
|
||||
```
|
||||
@ -250,13 +250,13 @@ Sample return:
|
||||
### Unspent Outputs for Multiple Addresses
|
||||
GET method:
|
||||
```
|
||||
/insight-api/addrs/[:addrs]/utxo
|
||||
/insight-api/addrs/2NF2baYuJAkCKo5onjUKEPdARQkZ6SYyKd5,2NAre8sX2povnjy4aeiHKeEh97Qhn97tB1f/utxo
|
||||
/flosight-api/addrs/[:addrs]/utxo
|
||||
/flosight-api/addrs/2NF2baYuJAkCKo5onjUKEPdARQkZ6SYyKd5,2NAre8sX2povnjy4aeiHKeEh97Qhn97tB1f/utxo
|
||||
```
|
||||
|
||||
POST method:
|
||||
```
|
||||
/insight-api/addrs/utxo
|
||||
/flosight-api/addrs/utxo
|
||||
```
|
||||
|
||||
POST params:
|
||||
@ -266,25 +266,25 @@ addrs: 2NF2baYuJAkCKo5onjUKEPdARQkZ6SYyKd5,2NAre8sX2povnjy4aeiHKeEh97Qhn97tB1f
|
||||
|
||||
### Transactions by Block
|
||||
```
|
||||
/insight-api/txs/?block=HASH
|
||||
/insight-api/txs/?block=00000000fa6cf7367e50ad14eb0ca4737131f256fc4c5841fd3c3f140140e6b6
|
||||
/flosight-api/txs/?block=HASH
|
||||
/flosight-api/txs/?block=00000000fa6cf7367e50ad14eb0ca4737131f256fc4c5841fd3c3f140140e6b6
|
||||
```
|
||||
### Transactions by Address
|
||||
```
|
||||
/insight-api/txs/?address=ADDR
|
||||
/insight-api/txs/?address=mmhmMNfBiZZ37g1tgg2t8DDbNoEdqKVxAL
|
||||
/flosight-api/txs/?address=ADDR
|
||||
/flosight-api/txs/?address=mmhmMNfBiZZ37g1tgg2t8DDbNoEdqKVxAL
|
||||
```
|
||||
|
||||
### Transactions for Multiple Addresses
|
||||
GET method:
|
||||
```
|
||||
/insight-api/addrs/[:addrs]/txs[?from=&to=]
|
||||
/insight-api/addrs/2NF2baYuJAkCKo5onjUKEPdARQkZ6SYyKd5,2NAre8sX2povnjy4aeiHKeEh97Qhn97tB1f/txs?from=0&to=20
|
||||
/flosight-api/addrs/[:addrs]/txs[?from=&to=]
|
||||
/flosight-api/addrs/2NF2baYuJAkCKo5onjUKEPdARQkZ6SYyKd5,2NAre8sX2povnjy4aeiHKeEh97Qhn97tB1f/txs?from=0&to=20
|
||||
```
|
||||
|
||||
POST method:
|
||||
```
|
||||
/insight-api/addrs/txs
|
||||
/flosight-api/addrs/txs
|
||||
```
|
||||
|
||||
POST params:
|
||||
@ -330,7 +330,7 @@ Note: if pagination params are not specified, the result is an array of transact
|
||||
### Transaction Broadcasting
|
||||
POST method:
|
||||
```
|
||||
/insight-api/tx/send
|
||||
/flosight-api/tx/send
|
||||
```
|
||||
POST params:
|
||||
```
|
||||
@ -356,17 +356,17 @@ POST response:
|
||||
|
||||
### Historic Blockchain Data Sync Status
|
||||
```
|
||||
/insight-api/sync
|
||||
/flosight-api/sync
|
||||
```
|
||||
|
||||
### Live Network P2P Data Sync Status
|
||||
```
|
||||
/insight-api/peer
|
||||
/flosight-api/peer
|
||||
```
|
||||
|
||||
### Status of the Bitcoin Network
|
||||
### Status of the Florincoin Network
|
||||
```
|
||||
/insight-api/status?q=xxx
|
||||
/flosight-api/status?q=xxx
|
||||
```
|
||||
|
||||
Where "xxx" can be:
|
||||
@ -379,14 +379,14 @@ Where "xxx" can be:
|
||||
|
||||
### Utility Methods
|
||||
```
|
||||
/insight-api/utils/estimatefee[?nbBlocks=2]
|
||||
/flosight-api/utils/estimatefee[?nbBlocks=2]
|
||||
```
|
||||
|
||||
|
||||
## Web Socket API
|
||||
The web socket API is served using [socket.io](http://socket.io).
|
||||
|
||||
The following are the events published by insight:
|
||||
The following are the events published by flosight:
|
||||
|
||||
`tx`: new transaction received from network. This event is published in the 'inv' room. Data will be a app/models/Transaction object.
|
||||
Sample output:
|
||||
@ -409,7 +409,7 @@ Sample output:
|
||||
}
|
||||
```
|
||||
|
||||
`<bitcoinAddress>`: new transaction concerning <bitcoinAddress> received from network. This event is published in the `<bitcoinAddress>` room.
|
||||
`<florincoinAddress>`: new transaction concerning <florincoinAddress> received from network. This event is published in the `<florincoinAddress>` room.
|
||||
|
||||
`status`: every 1% increment on the sync task, this event will be triggered. This event is published in the `sync` room.
|
||||
|
||||
@ -429,18 +429,18 @@ Sample output:
|
||||
|
||||
### Example Usage
|
||||
|
||||
The following html page connects to the socket.io insight API and listens for new transactions.
|
||||
The following html page connects to the socket.io flosight API and listens for new transactions.
|
||||
|
||||
html
|
||||
```
|
||||
<html>
|
||||
<body>
|
||||
<script src="http://<insight-server>:<port>/socket.io/socket.io.js"></script>
|
||||
<script src="http://<flosight-server>:<port>/socket.io/socket.io.js"></script>
|
||||
<script>
|
||||
eventToListenTo = 'tx'
|
||||
room = 'inv'
|
||||
|
||||
var socket = io("http://<insight-server>:<port>/");
|
||||
var socket = io("http://<flosight-server>:<port>/");
|
||||
socket.on('connect', function() {
|
||||
// Join the room.
|
||||
socket.emit('subscribe', room);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var bitcore = require('bitcore-lib');
|
||||
var Unit = bitcore.Unit;
|
||||
var flocore = require('flocore-lib');
|
||||
var Unit = flocore.Unit;
|
||||
var async = require('async');
|
||||
var TxController = require('./transactions');
|
||||
var Common = require('./common');
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
var Bitcore_ = {
|
||||
btc: require('bitcore-lib'),
|
||||
bch: require('bitcore-lib-cash')
|
||||
var Flocore_ = {
|
||||
btc: require('flocore-lib'),
|
||||
bch: require('flocore-lib-cash')
|
||||
};
|
||||
|
||||
var _ = require('lodash');
|
||||
@ -11,11 +11,11 @@ function AddressTranslator() {
|
||||
|
||||
AddressTranslator.getAddressCoin = function(address) {
|
||||
try {
|
||||
new Bitcore_['btc'].Address(address);
|
||||
new Flocore_['btc'].Address(address);
|
||||
return 'btc';
|
||||
} catch (e) {
|
||||
try {
|
||||
new Bitcore_['bch'].Address(address);
|
||||
new Flocore_['bch'].Address(address);
|
||||
return 'bch';
|
||||
} catch (e) {
|
||||
return;
|
||||
@ -31,8 +31,8 @@ AddressTranslator.translate = function(addresses, coin, origCoin) {
|
||||
}
|
||||
origCoin = origCoin || AddressTranslator.getAddressCoin(addresses[0]);
|
||||
var ret = _.map(addresses, function(x) {
|
||||
var orig = new Bitcore_[origCoin].Address(x).toObject();
|
||||
return Bitcore_[coin].Address.fromObject(orig).toString();
|
||||
var orig = new Flocore_[origCoin].Address(x).toObject();
|
||||
return Flocore_[coin].Address.fromObject(orig).toString();
|
||||
});
|
||||
|
||||
if (wasArray)
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
var Stream = require('stream');
|
||||
var util = require('util');
|
||||
|
||||
var bitcore = require('bitcore-lib');
|
||||
var _ = bitcore.deps._;
|
||||
var flocore = require('flocore-lib');
|
||||
var _ = flocore.deps._;
|
||||
var pools = require('../pools.json');
|
||||
var LRU = require('lru-cache');
|
||||
var Common = require('./common');
|
||||
@ -121,7 +121,7 @@ BlockController.prototype.rawBlock = function(req, res, next) {
|
||||
};
|
||||
|
||||
BlockController.prototype._normalizePrevHash = function(hash) {
|
||||
// TODO fix bitcore to give back null instead of null hash
|
||||
// TODO fix flocore to give back null instead of null hash
|
||||
if (hash !== '0000000000000000000000000000000000000000000000000000000000000000') {
|
||||
return hash;
|
||||
} else {
|
||||
@ -335,7 +335,7 @@ BlockController.prototype.getBlockReward = function(tx) {
|
||||
tx.outputs.forEach(function(output) {
|
||||
amt += output.value;
|
||||
});
|
||||
return bitcore.Unit.fromSatoshis(amt).toBTC();
|
||||
return flocore.Unit.fromSatoshis(amt).toBTC();
|
||||
};
|
||||
|
||||
BlockController.prototype.getPoolInfo = function(tx) {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
var _ = require('lodash');
|
||||
var AddressTranslator = require('./addresstranslator');
|
||||
var bitcore = require('bitcore-lib');
|
||||
var flocore = require('flocore-lib');
|
||||
|
||||
function Common(options) {
|
||||
this.log = options.log;
|
||||
@ -40,7 +40,7 @@ Common.prototype.translateInputAddresses= function(addresses) {
|
||||
|
||||
for(var i = 0; i < addresses.length; i++) {
|
||||
try {
|
||||
new bitcore.Address(addresses[i]);
|
||||
new flocore.Address(addresses[i]);
|
||||
} catch(e) {
|
||||
|
||||
throw addresses[i];
|
||||
|
||||
48
lib/index.js
48
lib/index.js
@ -14,22 +14,22 @@ var UtilsController = require('./utils');
|
||||
var CurrencyController = require('./currency');
|
||||
var RateLimiter = require('./ratelimiter');
|
||||
var morgan = require('morgan');
|
||||
var bitcore = require('bitcore-lib');
|
||||
var _ = bitcore.deps._;
|
||||
var $ = bitcore.util.preconditions;
|
||||
var flocore = require('flocore-lib');
|
||||
var _ = flocore.deps._;
|
||||
var $ = flocore.util.preconditions;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
/**
|
||||
* A service for Bitcore to enable HTTP routes to query information about the blockchain.
|
||||
* A service for Flocore to enable HTTP routes to query information about the blockchain.
|
||||
*
|
||||
* @param {Object} options
|
||||
* @param {Boolean} options.enableCache - This will enable cache-control headers
|
||||
* @param {Number} options.cacheShortSeconds - The time to cache short lived cache responses.
|
||||
* @param {Number} options.cacheLongSeconds - The time to cache long lived cache responses.
|
||||
* @param {String} options.routePrefix - The URL route prefix
|
||||
* @param {String} options.translateAddresses - Translate request and output address to Copay's BCH address version (see https://support.bitpay.com/hc/en-us/articles/115004671663-BitPay-s-Adopted-Conventions-for-Bitcoin-Cash-Addresses-URIs-and-Payment-Requests)
|
||||
* @param {String} options.translateAddresses - Translate request and output address to Copay's BCH address version (see https://support.bitpay.com/hc/en-us/articles/115004671663-BitPay-s-Adopted-Conventions-for-Florincoin-Cash-Addresses-URIs-and-Payment-Requests)
|
||||
*/
|
||||
var InsightAPI = function(options) {
|
||||
var FlosightAPI = function(options) {
|
||||
BaseService.call(this, options);
|
||||
|
||||
// in minutes
|
||||
@ -62,11 +62,11 @@ var InsightAPI = function(options) {
|
||||
this.txController = new TxController(this.node);
|
||||
};
|
||||
|
||||
InsightAPI.dependencies = ['header', 'block', 'transaction', 'address', 'web', 'mempool', 'timestamp', 'fee'];
|
||||
FlosightAPI.dependencies = ['header', 'block', 'transaction', 'address', 'web', 'mempool', 'timestamp', 'fee'];
|
||||
|
||||
inherits(InsightAPI, BaseService);
|
||||
inherits(FlosightAPI, BaseService);
|
||||
|
||||
InsightAPI.prototype.cache = function(maxAge) {
|
||||
FlosightAPI.prototype.cache = function(maxAge) {
|
||||
var self = this;
|
||||
return function(req, res, next) {
|
||||
if (self.enableCache) {
|
||||
@ -76,21 +76,21 @@ InsightAPI.prototype.cache = function(maxAge) {
|
||||
};
|
||||
};
|
||||
|
||||
InsightAPI.prototype.cacheShort = function() {
|
||||
FlosightAPI.prototype.cacheShort = function() {
|
||||
var seconds = this.cacheShortSeconds || 30; // thirty seconds
|
||||
return this.cache(seconds);
|
||||
};
|
||||
|
||||
InsightAPI.prototype.cacheLong = function() {
|
||||
FlosightAPI.prototype.cacheLong = function() {
|
||||
var seconds = this.cacheLongSeconds || 86400; // one day
|
||||
return this.cache(seconds);
|
||||
};
|
||||
|
||||
InsightAPI.prototype.getRoutePrefix = function() {
|
||||
FlosightAPI.prototype.getRoutePrefix = function() {
|
||||
return this.routePrefix;
|
||||
};
|
||||
|
||||
InsightAPI.prototype.start = function(callback) {
|
||||
FlosightAPI.prototype.start = function(callback) {
|
||||
|
||||
if (this._subscribed) {
|
||||
return;
|
||||
@ -99,7 +99,7 @@ InsightAPI.prototype.start = function(callback) {
|
||||
this._subscribed = true;
|
||||
|
||||
if (!this._bus) {
|
||||
this._bus = this.node.openBus({remoteAddress: 'localhost-insight-api'});
|
||||
this._bus = this.node.openBus({remoteAddress: 'localhost-flosight-api'});
|
||||
}
|
||||
|
||||
this._bus.on('mempool/transaction', this.transactionEventHandler.bind(this));
|
||||
@ -112,7 +112,7 @@ InsightAPI.prototype.start = function(callback) {
|
||||
|
||||
};
|
||||
|
||||
InsightAPI.prototype.createLogInfoStream = function() {
|
||||
FlosightAPI.prototype.createLogInfoStream = function() {
|
||||
var self = this;
|
||||
|
||||
function Log(options) {
|
||||
@ -129,21 +129,21 @@ InsightAPI.prototype.createLogInfoStream = function() {
|
||||
return stream;
|
||||
};
|
||||
|
||||
InsightAPI.prototype.getRemoteAddress = function(req) {
|
||||
FlosightAPI.prototype.getRemoteAddress = function(req) {
|
||||
if (req.headers['cf-connecting-ip']) {
|
||||
return req.headers['cf-connecting-ip'];
|
||||
}
|
||||
return req.socket.remoteAddress;
|
||||
};
|
||||
|
||||
InsightAPI.prototype._getRateLimiter = function() {
|
||||
FlosightAPI.prototype._getRateLimiter = function() {
|
||||
var rateLimiterOptions = _.isUndefined(this.rateLimiterOptions) ? {} : _.clone(this.rateLimiterOptions);
|
||||
rateLimiterOptions.node = this.node;
|
||||
var limiter = new RateLimiter(rateLimiterOptions);
|
||||
return limiter;
|
||||
};
|
||||
|
||||
InsightAPI.prototype.setupRoutes = function(app) {
|
||||
FlosightAPI.prototype.setupRoutes = function(app) {
|
||||
|
||||
var self = this;
|
||||
|
||||
@ -262,7 +262,7 @@ InsightAPI.prototype.setupRoutes = function(app) {
|
||||
|
||||
};
|
||||
|
||||
InsightAPI.prototype.getPublishEvents = function() {
|
||||
FlosightAPI.prototype.getPublishEvents = function() {
|
||||
return [
|
||||
{
|
||||
name: 'inv',
|
||||
@ -274,12 +274,12 @@ InsightAPI.prototype.getPublishEvents = function() {
|
||||
];
|
||||
};
|
||||
|
||||
InsightAPI.prototype.blockEventHandler = function(block) {
|
||||
FlosightAPI.prototype.blockEventHandler = function(block) {
|
||||
for (var i = 0; i < this.subscriptions.inv.length; i++) {
|
||||
this.subscriptions.inv[i].emit('block', block.rhash());
|
||||
}
|
||||
};
|
||||
InsightAPI.prototype.transactionEventHandler = function(tx) {
|
||||
FlosightAPI.prototype.transactionEventHandler = function(tx) {
|
||||
var result = this.txController.transformInvTransaction(tx);
|
||||
|
||||
for (var i = 0; i < this.subscriptions.inv.length; i++) {
|
||||
@ -287,7 +287,7 @@ InsightAPI.prototype.transactionEventHandler = function(tx) {
|
||||
}
|
||||
};
|
||||
|
||||
InsightAPI.prototype.subscribe = function(emitter) {
|
||||
FlosightAPI.prototype.subscribe = function(emitter) {
|
||||
$.checkArgument(emitter instanceof EventEmitter, 'First argument is expected to be an EventEmitter');
|
||||
|
||||
var emitters = this.subscriptions.inv;
|
||||
@ -297,7 +297,7 @@ InsightAPI.prototype.subscribe = function(emitter) {
|
||||
}
|
||||
};
|
||||
|
||||
InsightAPI.prototype.unsubscribe = function(emitter) {
|
||||
FlosightAPI.prototype.unsubscribe = function(emitter) {
|
||||
$.checkArgument(emitter instanceof EventEmitter, 'First argument is expected to be an EventEmitter');
|
||||
|
||||
var emitters = this.subscriptions.inv;
|
||||
@ -307,4 +307,4 @@ InsightAPI.prototype.unsubscribe = function(emitter) {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = InsightAPI;
|
||||
module.exports = FlosightAPI;
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
var bitcore = require('bitcore-lib');
|
||||
var _ = bitcore.deps._;
|
||||
var Message = require('bitcore-message');
|
||||
var flocore = require('flocore-lib');
|
||||
var _ = flocore.deps._;
|
||||
var Message = require('flocore-message');
|
||||
var Common = require('./common');
|
||||
|
||||
function MessagesController(node) {
|
||||
|
||||
@ -6,7 +6,7 @@ var THREE_HOURS = 3 * 60 * 60 * 1000;
|
||||
* A rate limiter to be used as an express middleware.
|
||||
*
|
||||
* @param {Object} options
|
||||
* @param {Object} options.node - The bitcore node object
|
||||
* @param {Object} options.node - The flocore node object
|
||||
* @param {Number} options.limit - Number of requests for normal rate limiter
|
||||
* @param {Number} options.interval - Interval of the normal rate limiter
|
||||
* @param {Array} options.whitelist - IP addresses that should have whitelist rate limiting
|
||||
|
||||
@ -68,7 +68,7 @@ Service.prototype.start = function(done) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to be called when bitcore-node is stopped
|
||||
* Function to be called when flocore-node is stopped
|
||||
*/
|
||||
Service.prototype.stop = function(done) {
|
||||
setImmediate(done);
|
||||
|
||||
@ -121,7 +121,7 @@ StatusController.prototype.sync = function(req, res) {
|
||||
syncPercentage: Math.round(percentage),
|
||||
height: self._block.getTip().height,
|
||||
error: null,
|
||||
type: 'bitcore node'
|
||||
type: 'flocore node'
|
||||
};
|
||||
|
||||
res.jsonp(info);
|
||||
@ -132,7 +132,7 @@ StatusController.prototype.sync = function(req, res) {
|
||||
|
||||
};
|
||||
|
||||
// Hard coded to make insight ui happy, but not applicable
|
||||
// Hard coded to make flosight ui happy, but not applicable
|
||||
StatusController.prototype.peer = function(req, res) {
|
||||
res.jsonp({
|
||||
connected: true,
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
var bitcore = require('bitcore-lib');
|
||||
var _ = bitcore.deps._;
|
||||
var $ = bitcore.util.preconditions;
|
||||
var flocore = require('flocore-lib');
|
||||
var _ = flocore.deps._;
|
||||
var $ = flocore.util.preconditions;
|
||||
var Common = require('./common');
|
||||
var async = require('async');
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ UtilsController.prototype.estimateFee = function(req, res) {
|
||||
|
||||
async.map(nbBlocks, function(n, next) {
|
||||
var num = parseInt(n);
|
||||
// Insight and Bitcoin JSON-RPC return bitcoin for this value (instead of satoshis).
|
||||
// Flosight and Florincoin JSON-RPC return florincoin for this value (instead of satoshis).
|
||||
self._fee.estimateFee(num, function(err, fee) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
|
||||
30
package-lock.json
generated
30
package-lock.json
generated
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "insight-api",
|
||||
"name": "flosight-api",
|
||||
"version": "5.0.0-beta.44",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
@ -166,15 +166,15 @@
|
||||
"safe-buffer": "5.1.1"
|
||||
}
|
||||
},
|
||||
"bitcoind-rpc": {
|
||||
"florincoind-rpc": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/bitcoind-rpc/-/bitcoind-rpc-0.7.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/florincoind-rpc/-/florincoind-rpc-0.7.0.tgz",
|
||||
"integrity": "sha1-2/YkkmfuMovkjeV3hwQpgAksi/I=",
|
||||
"dev": true
|
||||
},
|
||||
"bitcore-lib": {
|
||||
"flocore-lib": {
|
||||
"version": "5.0.0-beta.1",
|
||||
"resolved": "https://registry.npmjs.org/bitcore-lib/-/bitcore-lib-5.0.0-beta.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/flocore-lib/-/flocore-lib-5.0.0-beta.1.tgz",
|
||||
"integrity": "sha512-y8aCkNJQieCPacLpW9wdg6Un2iAC/5Nt7g/lRHhK6PwrXw7dxXwc7eZOd87oPGn6bAd4jBd8YTCqIqwpf3UQsA==",
|
||||
"requires": {
|
||||
"bn.js": "2.0.4",
|
||||
@ -192,9 +192,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"bitcore-lib-cash": {
|
||||
"flocore-lib-cash": {
|
||||
"version": "0.15.1",
|
||||
"resolved": "https://registry.npmjs.org/bitcore-lib-cash/-/bitcore-lib-cash-0.15.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/flocore-lib-cash/-/flocore-lib-cash-0.15.1.tgz",
|
||||
"integrity": "sha512-2fftReEqbkohCwiblBGteEX5S7lc6oTGM1QyDr6rz88QA7xLqhtVkT9hWrwirZfw6H4IfApS2gAAtHGExCqMsw==",
|
||||
"requires": {
|
||||
"bn.js": "4.11.8",
|
||||
@ -244,17 +244,17 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"bitcore-message": {
|
||||
"flocore-message": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/bitcore-message/-/bitcore-message-1.0.2.tgz",
|
||||
"resolved": "https://registry.npmjs.org/flocore-message/-/flocore-message-1.0.2.tgz",
|
||||
"integrity": "sha1-BCvAjGrN9+o5fv85Zo2SZXf1geQ=",
|
||||
"requires": {
|
||||
"bitcore-lib": "0.13.19"
|
||||
"flocore-lib": "0.13.19"
|
||||
},
|
||||
"dependencies": {
|
||||
"bitcore-lib": {
|
||||
"flocore-lib": {
|
||||
"version": "0.13.19",
|
||||
"resolved": "https://registry.npmjs.org/bitcore-lib/-/bitcore-lib-0.13.19.tgz",
|
||||
"resolved": "https://registry.npmjs.org/flocore-lib/-/flocore-lib-0.13.19.tgz",
|
||||
"integrity": "sha1-SK8em9oQBnwasWJjRyta3SAA89w=",
|
||||
"requires": {
|
||||
"bn.js": "2.0.4",
|
||||
@ -320,14 +320,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"bitcore-p2p": {
|
||||
"flocore-p2p": {
|
||||
"version": "5.0.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/bitcore-p2p/-/bitcore-p2p-5.0.0-beta.2.tgz",
|
||||
"resolved": "https://registry.npmjs.org/flocore-p2p/-/flocore-p2p-5.0.0-beta.2.tgz",
|
||||
"integrity": "sha512-/keg4fns0NIXhfJtQL8paFAyp0IVZrig8bJYIZRLGH4Ne5sSyNHK2ZDG7Y58P3usdCeJNFiL/rntXsvguwLAnw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bcoin": "github:bcoin-org/bcoin#886008a1822ce1da7fa8395ee7db4bcc1750a28a",
|
||||
"bitcore-lib": "5.0.0-beta.1",
|
||||
"flocore-lib": "5.0.0-beta.1",
|
||||
"bloom-filter": "0.2.0",
|
||||
"buffers": "github:bitpay/node-buffers#04f4c4264e0d105db2b99b786843ed64f23230d8",
|
||||
"socks5-client": "0.3.6"
|
||||
|
||||
30
package.json
30
package.json
@ -1,21 +1,21 @@
|
||||
{
|
||||
"name": "insight-api",
|
||||
"description": "A Bitcoin blockchain REST and web socket API service for Bitcore Node.",
|
||||
"name": "flosight-api",
|
||||
"description": "A Florincoin blockchain REST and web socket API service for Flocore Node.",
|
||||
"version": "5.0.0-beta.44",
|
||||
"repository": "git://github.com/bitpay/insight-api.git",
|
||||
"repository": "git://github.com/bitpay/flosight-api.git",
|
||||
"bugs": {
|
||||
"url": "https://github.com/bitpay/insight-api/issues"
|
||||
"url": "https://github.com/bitpay/flosight-api/issues"
|
||||
},
|
||||
"homepage": "https://github.com/bitpay/insight-api",
|
||||
"homepage": "https://github.com/bitpay/flosight-api",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"insight",
|
||||
"insight api",
|
||||
"flosight",
|
||||
"flosight api",
|
||||
"blockchain",
|
||||
"bitcoin api",
|
||||
"florincoin api",
|
||||
"blockchain api",
|
||||
"json",
|
||||
"bitcore"
|
||||
"flocore"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=8.2.0"
|
||||
@ -26,14 +26,14 @@
|
||||
"perf": "mocha -R spec perf"
|
||||
},
|
||||
"main": "lib",
|
||||
"bitcoreNode": "lib",
|
||||
"flocoreNode": "lib",
|
||||
"dependencies": {
|
||||
"JSONStream": "^1.3.1",
|
||||
"async": "*",
|
||||
"bcoin": "bcoin-org/bcoin#886008a1822ce1da7fa8395ee7db4bcc1750a28a",
|
||||
"bitcore-lib": "5.0.0-beta.1",
|
||||
"bitcore-lib-cash": "0.15.1",
|
||||
"bitcore-message": "^1.0.1",
|
||||
"flocore-lib": "5.0.0-beta.1",
|
||||
"flocore-lib-cash": "0.15.1",
|
||||
"flocore-message": "^1.0.1",
|
||||
"body-parser": "^1.13.3",
|
||||
"compression": "^1.6.1",
|
||||
"lodash": "^2.4.1",
|
||||
@ -42,8 +42,8 @@
|
||||
"request": "^2.64.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bitcoind-rpc": "^0.7.0",
|
||||
"bitcore-p2p": "5.0.0-beta.2",
|
||||
"florincoind-rpc": "^0.7.0",
|
||||
"flocore-p2p": "5.0.0-beta.2",
|
||||
"chai": "^3.5.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"mocha": "^2.4.5",
|
||||
|
||||
96
perf/perf.js
96
perf/perf.js
@ -6,11 +6,11 @@ var rimraf = require('rimraf');
|
||||
var mkdirp = require('mkdirp');
|
||||
var fs = require('fs');
|
||||
var async = require('async');
|
||||
var RPC = require('bitcoind-rpc');
|
||||
var RPC = require('florincoind-rpc');
|
||||
var http = require('http');
|
||||
var bitcore = require('bitcore-lib');
|
||||
var PrivateKey = bitcore.PrivateKey;
|
||||
var Transaction = bitcore.Transaction;
|
||||
var flocore = require('flocore-lib');
|
||||
var PrivateKey = flocore.PrivateKey;
|
||||
var Transaction = flocore.Transaction;
|
||||
|
||||
console.log('This test takes a really long time to run, be patient.');
|
||||
|
||||
@ -31,10 +31,10 @@ var utxoCount = 3000;
|
||||
var outputKeys = [];
|
||||
var rpc1 = new RPC(rpcConfig);
|
||||
var debug = true;
|
||||
var bitcoreDataDir = '/tmp/bitcore';
|
||||
var bitcoinDataDirs = ['/tmp/bitcoin'];
|
||||
var flocoreDataDir = '/tmp/flocore';
|
||||
var florincoinDataDirs = ['/tmp/florincoin'];
|
||||
|
||||
var bitcoin = {
|
||||
var florincoin = {
|
||||
args: {
|
||||
datadir: null,
|
||||
listen: 1,
|
||||
@ -46,17 +46,17 @@ var bitcoin = {
|
||||
rpcport: 58332,
|
||||
},
|
||||
datadir: null,
|
||||
exec: 'bitcoind', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/bitcoind
|
||||
exec: 'florincoind', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/florincoind
|
||||
processes: []
|
||||
};
|
||||
|
||||
var bitcore = {
|
||||
var flocore = {
|
||||
configFile: {
|
||||
file: bitcoreDataDir + '/bitcore-node.json',
|
||||
file: flocoreDataDir + '/flocore-node.json',
|
||||
conf: {
|
||||
network: 'regtest',
|
||||
port: 53001,
|
||||
datadir: bitcoreDataDir,
|
||||
datadir: flocoreDataDir,
|
||||
services: [
|
||||
'p2p',
|
||||
'db',
|
||||
@ -66,7 +66,7 @@ var bitcore = {
|
||||
'transaction',
|
||||
'mempool',
|
||||
'web',
|
||||
'insight-api',
|
||||
'flosight-api',
|
||||
'fee',
|
||||
'timestamp'
|
||||
],
|
||||
@ -76,7 +76,7 @@ var bitcore = {
|
||||
{ 'ip': { 'v4': '127.0.0.1' }, port: 18444 }
|
||||
]
|
||||
},
|
||||
'insight-api': {
|
||||
'flosight-api': {
|
||||
'routePrefix': 'api'
|
||||
}
|
||||
}
|
||||
@ -87,27 +87,27 @@ var bitcore = {
|
||||
hostname: 'localhost',
|
||||
port: 53001,
|
||||
},
|
||||
opts: { cwd: bitcoreDataDir },
|
||||
datadir: bitcoreDataDir,
|
||||
exec: 'bitcored', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/bitcored
|
||||
opts: { cwd: flocoreDataDir },
|
||||
datadir: flocoreDataDir,
|
||||
exec: 'flocored', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/flocored
|
||||
args: ['start'],
|
||||
process: null
|
||||
};
|
||||
|
||||
var startBitcoind = function(count, callback) {
|
||||
var startFlorincoind = function(count, callback) {
|
||||
|
||||
var listenCount = 0;
|
||||
async.timesSeries(count, function(n, next) {
|
||||
|
||||
var datadir = bitcoinDataDirs.shift();
|
||||
var datadir = florincoinDataDirs.shift();
|
||||
|
||||
bitcoin.datadir = datadir;
|
||||
bitcoin.args.datadir = datadir;
|
||||
florincoin.datadir = datadir;
|
||||
florincoin.args.datadir = datadir;
|
||||
|
||||
if (listenCount++ > 0) {
|
||||
bitcoin.args.listen = 0;
|
||||
bitcoin.args.rpcport++;
|
||||
bitcoin.args.connect = '127.0.0.1';
|
||||
florincoin.args.listen = 0;
|
||||
florincoin.args.rpcport++;
|
||||
florincoin.args.connect = '127.0.0.1';
|
||||
}
|
||||
|
||||
rimraf(datadir, function(err) {
|
||||
@ -122,15 +122,15 @@ var startBitcoind = function(count, callback) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
var args = bitcoin.args;
|
||||
var args = florincoin.args;
|
||||
var argList = Object.keys(args).map(function(key) {
|
||||
return '-' + key + '=' + args[key];
|
||||
});
|
||||
|
||||
var bitcoinProcess = spawn(bitcoin.exec, argList, bitcoin.opts);
|
||||
bitcoin.processes.push(bitcoinProcess);
|
||||
var florincoinProcess = spawn(florincoin.exec, argList, florincoin.opts);
|
||||
florincoin.processes.push(florincoinProcess);
|
||||
|
||||
bitcoinProcess.stdout.on('data', function(data) {
|
||||
florincoinProcess.stdout.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stdout.write(data.toString());
|
||||
@ -138,7 +138,7 @@ var startBitcoind = function(count, callback) {
|
||||
|
||||
});
|
||||
|
||||
bitcoinProcess.stderr.on('data', function(data) {
|
||||
florincoinProcess.stderr.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stderr.write(data.toString());
|
||||
@ -157,11 +157,11 @@ var startBitcoind = function(count, callback) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var pids = bitcoin.processes.map(function(process) {
|
||||
var pids = florincoin.processes.map(function(process) {
|
||||
return process.pid;
|
||||
});
|
||||
|
||||
console.log(count + ' bitcoind\'s started at pid(s): ' + pids);
|
||||
console.log(count + ' florincoind\'s started at pid(s): ' + pids);
|
||||
async.retry({ interval: 1000, times: 1000 }, function(next) {
|
||||
rpc1.getInfo(next);
|
||||
}, callback);
|
||||
@ -174,7 +174,7 @@ var request = function(httpOpts, callback) {
|
||||
var request = http.request(httpOpts, function(res) {
|
||||
|
||||
if (res.statusCode !== 200 && res.statusCode !== 201) {
|
||||
return callback('Error from bitcore-node webserver: ' + res.statusCode);
|
||||
return callback('Error from flocore-node webserver: ' + res.statusCode);
|
||||
}
|
||||
|
||||
var resError;
|
||||
@ -207,16 +207,16 @@ var request = function(httpOpts, callback) {
|
||||
request.end();
|
||||
};
|
||||
|
||||
var shutdownBitcoind = function(callback) {
|
||||
bitcoin.processes.forEach(function(process) {
|
||||
var shutdownFlorincoind = function(callback) {
|
||||
florincoin.processes.forEach(function(process) {
|
||||
process.kill();
|
||||
});
|
||||
setTimeout(callback, 3000);
|
||||
};
|
||||
|
||||
var shutdownBitcore = function(callback) {
|
||||
if (bitcore.process) {
|
||||
bitcore.process.kill();
|
||||
var shutdownFlocore = function(callback) {
|
||||
if (flocore.process) {
|
||||
flocore.process.kill();
|
||||
}
|
||||
callback();
|
||||
};
|
||||
@ -324,26 +324,26 @@ var buildInitialChain = function(callback) {
|
||||
});
|
||||
};
|
||||
|
||||
var startBitcore = function(callback) {
|
||||
var startFlocore = function(callback) {
|
||||
|
||||
rimraf(bitcoreDataDir, function(err) {
|
||||
rimraf(flocoreDataDir, function(err) {
|
||||
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
mkdirp(bitcoreDataDir, function(err) {
|
||||
mkdirp(flocoreDataDir, function(err) {
|
||||
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
fs.writeFileSync(bitcore.configFile.file, JSON.stringify(bitcore.configFile.conf));
|
||||
fs.writeFileSync(flocore.configFile.file, JSON.stringify(flocore.configFile.conf));
|
||||
|
||||
var args = bitcore.args;
|
||||
bitcore.process = spawn(bitcore.exec, args, bitcore.opts);
|
||||
var args = flocore.args;
|
||||
flocore.process = spawn(flocore.exec, args, flocore.opts);
|
||||
|
||||
bitcore.process.stdout.on('data', function(data) {
|
||||
flocore.process.stdout.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stdout.write(data.toString());
|
||||
@ -351,7 +351,7 @@ var startBitcore = function(callback) {
|
||||
|
||||
});
|
||||
|
||||
bitcore.process.stderr.on('data', function(data) {
|
||||
flocore.process.stderr.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stderr.write(data.toString());
|
||||
@ -398,21 +398,21 @@ describe('Address Performance', function() {
|
||||
|
||||
async.series([
|
||||
function(next) {
|
||||
startBitcoind(bitcoinDataDirs.length, next);
|
||||
startFlorincoind(florincoinDataDirs.length, next);
|
||||
},
|
||||
function(next) {
|
||||
buildInitialChain(next);
|
||||
},
|
||||
function(next) {
|
||||
startBitcore(next);
|
||||
startFlocore(next);
|
||||
}
|
||||
], done);
|
||||
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
shutdownBitcore(function() {
|
||||
shutdownBitcoind(done);
|
||||
shutdownFlocore(function() {
|
||||
shutdownFlorincoind(done);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
},
|
||||
{
|
||||
"poolName": "ASICminer",
|
||||
"url": "https://bitcointalk.org/index.php?topic=99497.0",
|
||||
"url": "https://florincointalk.org/index.php?topic=99497.0",
|
||||
"searchStrings": [
|
||||
"Mined By ASICMiner"
|
||||
]
|
||||
|
||||
@ -6,13 +6,13 @@ var rimraf = require('rimraf');
|
||||
var mkdirp = require('mkdirp');
|
||||
var fs = require('fs');
|
||||
var async = require('async');
|
||||
var RPC = require('bitcoind-rpc');
|
||||
var RPC = require('florincoind-rpc');
|
||||
var http = require('http');
|
||||
var bitcore = require('bitcore-lib');
|
||||
var flocore = require('flocore-lib');
|
||||
var exec = require('child_process').exec;
|
||||
var bitcore = require('bitcore-lib');
|
||||
var PrivateKey = bitcore.PrivateKey;
|
||||
var Transaction = bitcore.Transaction;
|
||||
var flocore = require('flocore-lib');
|
||||
var PrivateKey = flocore.PrivateKey;
|
||||
var Transaction = flocore.Transaction;
|
||||
|
||||
var blocksGenerated = 0;
|
||||
|
||||
@ -27,16 +27,16 @@ var rpcConfig = {
|
||||
|
||||
var rpc = new RPC(rpcConfig);
|
||||
var debug = true;
|
||||
var bitcoreDataDir = '/tmp/bitcore';
|
||||
var bitcoinDir = '/tmp/bitcoin';
|
||||
var bitcoinDataDirs = [ bitcoinDir ];
|
||||
var flocoreDataDir = '/tmp/flocore';
|
||||
var florincoinDir = '/tmp/florincoin';
|
||||
var florincoinDataDirs = [ florincoinDir ];
|
||||
var pks = [];
|
||||
var txs = [];
|
||||
var txids = [];
|
||||
var initialTx;
|
||||
var startingPk;
|
||||
|
||||
var bitcoin = {
|
||||
var florincoin = {
|
||||
args: {
|
||||
datadir: null,
|
||||
listen: 1,
|
||||
@ -48,17 +48,17 @@ var bitcoin = {
|
||||
rpcport: 58332,
|
||||
},
|
||||
datadir: null,
|
||||
exec: 'bitcoind', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/bitcoind
|
||||
exec: 'florincoind', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/florincoind
|
||||
processes: []
|
||||
};
|
||||
|
||||
var bitcore = {
|
||||
var flocore = {
|
||||
configFile: {
|
||||
file: bitcoreDataDir + '/bitcore-node.json',
|
||||
file: flocoreDataDir + '/flocore-node.json',
|
||||
conf: {
|
||||
network: 'regtest',
|
||||
port: 53001,
|
||||
datadir: bitcoreDataDir,
|
||||
datadir: flocoreDataDir,
|
||||
services: [
|
||||
'p2p',
|
||||
'db',
|
||||
@ -68,7 +68,7 @@ var bitcore = {
|
||||
'transaction',
|
||||
'mempool',
|
||||
'web',
|
||||
'insight-api',
|
||||
'flosight-api',
|
||||
'fee',
|
||||
'timestamp'
|
||||
],
|
||||
@ -78,7 +78,7 @@ var bitcore = {
|
||||
{ 'ip': { 'v4': '127.0.0.1' }, port: 18444 }
|
||||
]
|
||||
},
|
||||
'insight-api': {
|
||||
'flosight-api': {
|
||||
'routePrefix': 'api'
|
||||
},
|
||||
'block': {
|
||||
@ -92,9 +92,9 @@ var bitcore = {
|
||||
hostname: 'localhost',
|
||||
port: 53001,
|
||||
},
|
||||
opts: { cwd: bitcoreDataDir },
|
||||
datadir: bitcoreDataDir,
|
||||
exec: 'bitcored', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/bitcored
|
||||
opts: { cwd: flocoreDataDir },
|
||||
datadir: flocoreDataDir,
|
||||
exec: 'flocored', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/flocored
|
||||
args: ['start'],
|
||||
process: null
|
||||
};
|
||||
@ -113,7 +113,7 @@ var request = function(httpOpts, callback) {
|
||||
var request = http.request(httpOpts, function(res) {
|
||||
|
||||
if (res.statusCode !== 200 && res.statusCode !== 201) {
|
||||
return callback('Error from bitcore-node webserver: ' + res.statusCode);
|
||||
return callback('Error from flocore-node webserver: ' + res.statusCode);
|
||||
}
|
||||
|
||||
var resError;
|
||||
@ -196,17 +196,17 @@ var resetDirs = function(dirs, callback) {
|
||||
|
||||
};
|
||||
|
||||
var startBitcoind = function(callback) {
|
||||
var startFlorincoind = function(callback) {
|
||||
|
||||
var args = bitcoin.args;
|
||||
var args = florincoin.args;
|
||||
var argList = Object.keys(args).map(function(key) {
|
||||
return '-' + key + '=' + args[key];
|
||||
});
|
||||
|
||||
var bitcoinProcess = spawn(bitcoin.exec, argList, bitcoin.opts);
|
||||
bitcoin.processes.push(bitcoinProcess);
|
||||
var florincoinProcess = spawn(florincoin.exec, argList, florincoin.opts);
|
||||
florincoin.processes.push(florincoinProcess);
|
||||
|
||||
bitcoinProcess.stdout.on('data', function(data) {
|
||||
florincoinProcess.stdout.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stdout.write(data.toString());
|
||||
@ -214,7 +214,7 @@ var startBitcoind = function(callback) {
|
||||
|
||||
});
|
||||
|
||||
bitcoinProcess.stderr.on('data', function(data) {
|
||||
florincoinProcess.stderr.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stderr.write(data.toString());
|
||||
@ -226,40 +226,40 @@ var startBitcoind = function(callback) {
|
||||
};
|
||||
|
||||
|
||||
var reportBitcoindsStarted = function() {
|
||||
var pids = bitcoin.processes.map(function(process) {
|
||||
var reportFlorincoindsStarted = function() {
|
||||
var pids = florincoin.processes.map(function(process) {
|
||||
return process.pid;
|
||||
});
|
||||
|
||||
console.log(pids.length + ' bitcoind\'s started at pid(s): ' + pids);
|
||||
console.log(pids.length + ' florincoind\'s started at pid(s): ' + pids);
|
||||
};
|
||||
|
||||
var startBitcoinds = function(datadirs, callback) {
|
||||
var startFlorincoinds = function(datadirs, callback) {
|
||||
|
||||
var listenCount = 0;
|
||||
async.eachSeries(datadirs, function(datadir, next) {
|
||||
|
||||
bitcoin.datadir = datadir;
|
||||
bitcoin.args.datadir = datadir;
|
||||
florincoin.datadir = datadir;
|
||||
florincoin.args.datadir = datadir;
|
||||
|
||||
if (listenCount++ > 0) {
|
||||
bitcoin.args.listen = 0;
|
||||
bitcoin.args.rpcport = bitcoin.args.rpcport + 1;
|
||||
bitcoin.args.connect = '127.0.0.1';
|
||||
florincoin.args.listen = 0;
|
||||
florincoin.args.rpcport = florincoin.args.rpcport + 1;
|
||||
florincoin.args.connect = '127.0.0.1';
|
||||
}
|
||||
|
||||
startBitcoind(next);
|
||||
startFlorincoind(next);
|
||||
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
reportBitcoindsStarted();
|
||||
reportFlorincoindsStarted();
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
var waitForBitcoinReady = function(rpc, callback) {
|
||||
var waitForFlorincoinReady = function(rpc, callback) {
|
||||
async.retry({ interval: 1000, times: 1000 }, function(next) {
|
||||
rpc.getInfo(function(err) {
|
||||
if (err) {
|
||||
@ -275,10 +275,10 @@ var waitForBitcoinReady = function(rpc, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
var shutdownBitcoind = function(callback) {
|
||||
var shutdownFlorincoind = function(callback) {
|
||||
var process;
|
||||
do {
|
||||
process = bitcoin.processes.shift();
|
||||
process = florincoin.processes.shift();
|
||||
if (process) {
|
||||
process.kill();
|
||||
}
|
||||
@ -286,24 +286,24 @@ var shutdownBitcoind = function(callback) {
|
||||
setTimeout(callback, 3000);
|
||||
};
|
||||
|
||||
var shutdownBitcore = function(callback) {
|
||||
if (bitcore.process) {
|
||||
bitcore.process.kill();
|
||||
var shutdownFlocore = function(callback) {
|
||||
if (flocore.process) {
|
||||
flocore.process.kill();
|
||||
}
|
||||
callback();
|
||||
};
|
||||
|
||||
var writeBitcoreConf = function() {
|
||||
fs.writeFileSync(bitcore.configFile.file, JSON.stringify(bitcore.configFile.conf));
|
||||
var writeFlocoreConf = function() {
|
||||
fs.writeFileSync(flocore.configFile.file, JSON.stringify(flocore.configFile.conf));
|
||||
};
|
||||
|
||||
var startBitcore = function(callback) {
|
||||
var startFlocore = function(callback) {
|
||||
|
||||
var args = bitcore.args;
|
||||
console.log('Using bitcored from: ');
|
||||
var args = flocore.args;
|
||||
console.log('Using flocored from: ');
|
||||
async.series([
|
||||
function(next) {
|
||||
exec('which bitcored', function(err, stdout, stderr) {
|
||||
exec('which flocored', function(err, stdout, stderr) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
@ -312,16 +312,16 @@ var startBitcore = function(callback) {
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
bitcore.process = spawn(bitcore.exec, args, bitcore.opts);
|
||||
flocore.process = spawn(flocore.exec, args, flocore.opts);
|
||||
|
||||
bitcore.process.stdout.on('data', function(data) {
|
||||
flocore.process.stdout.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stdout.write(data.toString());
|
||||
}
|
||||
|
||||
});
|
||||
bitcore.process.stderr.on('data', function(data) {
|
||||
flocore.process.stderr.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stderr.write(data.toString());
|
||||
@ -419,23 +419,23 @@ var addrtxs1 = function(callback) {
|
||||
// 0. reset the test directories
|
||||
function(next) {
|
||||
console.log('step 0: setting up directories.');
|
||||
var dirs = bitcoinDataDirs.concat([bitcoreDataDir]);
|
||||
var dirs = florincoinDataDirs.concat([flocoreDataDir]);
|
||||
resetDirs(dirs, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
writeBitcoreConf();
|
||||
writeFlocoreConf();
|
||||
next();
|
||||
});
|
||||
},
|
||||
// 1. start 1 bitcoind in regtest mode
|
||||
// 1. start 1 florincoind in regtest mode
|
||||
function(next) {
|
||||
console.log('step 1: starting bitcoind.');
|
||||
startBitcoinds(bitcoinDataDirs, function(err) {
|
||||
console.log('step 1: starting florincoind.');
|
||||
startFlorincoinds(florincoinDataDirs, function(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
waitForBitcoinReady(rpc, function(err) {
|
||||
waitForFlorincoinReady(rpc, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@ -444,12 +444,12 @@ var addrtxs1 = function(callback) {
|
||||
});
|
||||
});
|
||||
},
|
||||
// 2. start up bitcore
|
||||
// 2. start up flocore
|
||||
function(next) {
|
||||
console.log('step 2: starting bitcore...');
|
||||
startBitcore(next);
|
||||
console.log('step 2: starting flocore...');
|
||||
startFlocore(next);
|
||||
},
|
||||
// 3. wait for blocks to be fully synced in bitcore
|
||||
// 3. wait for blocks to be fully synced in flocore
|
||||
function(next) {
|
||||
waitForBlocksGenerated(next);
|
||||
},
|
||||
@ -491,8 +491,8 @@ describe('Address', function() {
|
||||
describe('addrs/txs', function() {
|
||||
|
||||
after(function(done) {
|
||||
shutdownBitcore(function() {
|
||||
shutdownBitcoind(done);
|
||||
shutdownFlocore(function() {
|
||||
shutdownFlorincoind(done);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
114
regtest/block.js
114
regtest/block.js
@ -6,12 +6,12 @@ var rimraf = require('rimraf');
|
||||
var mkdirp = require('mkdirp');
|
||||
var fs = require('fs');
|
||||
var async = require('async');
|
||||
var RPC = require('bitcoind-rpc');
|
||||
var RPC = require('florincoind-rpc');
|
||||
var http = require('http');
|
||||
var bitcore = require('bitcore-lib');
|
||||
var flocore = require('flocore-lib');
|
||||
var exec = require('child_process').exec;
|
||||
var bitcore = require('bitcore-lib');
|
||||
var Block = bitcore.Block;
|
||||
var flocore = require('flocore-lib');
|
||||
var Block = flocore.Block;
|
||||
|
||||
var blocksGenerated = 0;
|
||||
|
||||
@ -26,12 +26,12 @@ var rpcConfig = {
|
||||
|
||||
var rpc = new RPC(rpcConfig);
|
||||
var debug = true;
|
||||
var bitcoreDataDir = '/tmp/bitcore';
|
||||
var bitcoinDir = '/tmp/bitcoin';
|
||||
var bitcoinDataDirs = [ bitcoinDir ];
|
||||
var flocoreDataDir = '/tmp/flocore';
|
||||
var florincoinDir = '/tmp/florincoin';
|
||||
var florincoinDataDirs = [ florincoinDir ];
|
||||
var blocks= [];
|
||||
|
||||
var bitcoin = {
|
||||
var florincoin = {
|
||||
args: {
|
||||
datadir: null,
|
||||
listen: 1,
|
||||
@ -43,17 +43,17 @@ var bitcoin = {
|
||||
rpcport: 58332,
|
||||
},
|
||||
datadir: null,
|
||||
exec: 'bitcoind', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/bitcoind
|
||||
exec: 'florincoind', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/florincoind
|
||||
processes: []
|
||||
};
|
||||
|
||||
var bitcore = {
|
||||
var flocore = {
|
||||
configFile: {
|
||||
file: bitcoreDataDir + '/bitcore-node.json',
|
||||
file: flocoreDataDir + '/flocore-node.json',
|
||||
conf: {
|
||||
network: 'regtest',
|
||||
port: 53001,
|
||||
datadir: bitcoreDataDir,
|
||||
datadir: flocoreDataDir,
|
||||
services: [
|
||||
'p2p',
|
||||
'db',
|
||||
@ -63,7 +63,7 @@ var bitcore = {
|
||||
'transaction',
|
||||
'mempool',
|
||||
'web',
|
||||
'insight-api',
|
||||
'flosight-api',
|
||||
'fee',
|
||||
'timestamp'
|
||||
],
|
||||
@ -73,7 +73,7 @@ var bitcore = {
|
||||
{ 'ip': { 'v4': '127.0.0.1' }, port: 18444 }
|
||||
]
|
||||
},
|
||||
'insight-api': {
|
||||
'flosight-api': {
|
||||
'routePrefix': 'api'
|
||||
},
|
||||
'block': {
|
||||
@ -87,9 +87,9 @@ var bitcore = {
|
||||
hostname: 'localhost',
|
||||
port: 53001,
|
||||
},
|
||||
opts: { cwd: bitcoreDataDir },
|
||||
datadir: bitcoreDataDir,
|
||||
exec: 'bitcored', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/bitcored
|
||||
opts: { cwd: flocoreDataDir },
|
||||
datadir: flocoreDataDir,
|
||||
exec: 'flocored', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/flocored
|
||||
args: ['start'],
|
||||
process: null
|
||||
};
|
||||
@ -99,7 +99,7 @@ var request = function(httpOpts, callback) {
|
||||
var request = http.request(httpOpts, function(res) {
|
||||
|
||||
if (res.statusCode !== 200 && res.statusCode !== 201) {
|
||||
return callback('Error from bitcore-node webserver: ' + res.statusCode);
|
||||
return callback('Error from flocore-node webserver: ' + res.statusCode);
|
||||
}
|
||||
|
||||
var resError;
|
||||
@ -182,17 +182,17 @@ var resetDirs = function(dirs, callback) {
|
||||
|
||||
};
|
||||
|
||||
var startBitcoind = function(callback) {
|
||||
var startFlorincoind = function(callback) {
|
||||
|
||||
var args = bitcoin.args;
|
||||
var args = florincoin.args;
|
||||
var argList = Object.keys(args).map(function(key) {
|
||||
return '-' + key + '=' + args[key];
|
||||
});
|
||||
|
||||
var bitcoinProcess = spawn(bitcoin.exec, argList, bitcoin.opts);
|
||||
bitcoin.processes.push(bitcoinProcess);
|
||||
var florincoinProcess = spawn(florincoin.exec, argList, florincoin.opts);
|
||||
florincoin.processes.push(florincoinProcess);
|
||||
|
||||
bitcoinProcess.stdout.on('data', function(data) {
|
||||
florincoinProcess.stdout.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stdout.write(data.toString());
|
||||
@ -200,7 +200,7 @@ var startBitcoind = function(callback) {
|
||||
|
||||
});
|
||||
|
||||
bitcoinProcess.stderr.on('data', function(data) {
|
||||
florincoinProcess.stderr.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stderr.write(data.toString());
|
||||
@ -212,40 +212,40 @@ var startBitcoind = function(callback) {
|
||||
};
|
||||
|
||||
|
||||
var reportBitcoindsStarted = function() {
|
||||
var pids = bitcoin.processes.map(function(process) {
|
||||
var reportFlorincoindsStarted = function() {
|
||||
var pids = florincoin.processes.map(function(process) {
|
||||
return process.pid;
|
||||
});
|
||||
|
||||
console.log(pids.length + ' bitcoind\'s started at pid(s): ' + pids);
|
||||
console.log(pids.length + ' florincoind\'s started at pid(s): ' + pids);
|
||||
};
|
||||
|
||||
var startBitcoinds = function(datadirs, callback) {
|
||||
var startFlorincoinds = function(datadirs, callback) {
|
||||
|
||||
var listenCount = 0;
|
||||
async.eachSeries(datadirs, function(datadir, next) {
|
||||
|
||||
bitcoin.datadir = datadir;
|
||||
bitcoin.args.datadir = datadir;
|
||||
florincoin.datadir = datadir;
|
||||
florincoin.args.datadir = datadir;
|
||||
|
||||
if (listenCount++ > 0) {
|
||||
bitcoin.args.listen = 0;
|
||||
bitcoin.args.rpcport = bitcoin.args.rpcport + 1;
|
||||
bitcoin.args.connect = '127.0.0.1';
|
||||
florincoin.args.listen = 0;
|
||||
florincoin.args.rpcport = florincoin.args.rpcport + 1;
|
||||
florincoin.args.connect = '127.0.0.1';
|
||||
}
|
||||
|
||||
startBitcoind(next);
|
||||
startFlorincoind(next);
|
||||
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
reportBitcoindsStarted();
|
||||
reportFlorincoindsStarted();
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
var waitForBitcoinReady = function(rpc, callback) {
|
||||
var waitForFlorincoinReady = function(rpc, callback) {
|
||||
async.retry({ interval: 1000, times: 1000 }, function(next) {
|
||||
rpc.getInfo(function(err) {
|
||||
if (err) {
|
||||
@ -261,10 +261,10 @@ var waitForBitcoinReady = function(rpc, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
var shutdownBitcoind = function(callback) {
|
||||
var shutdownFlorincoind = function(callback) {
|
||||
var process;
|
||||
do {
|
||||
process = bitcoin.processes.shift();
|
||||
process = florincoin.processes.shift();
|
||||
if (process) {
|
||||
process.kill();
|
||||
}
|
||||
@ -272,24 +272,24 @@ var shutdownBitcoind = function(callback) {
|
||||
setTimeout(callback, 3000);
|
||||
};
|
||||
|
||||
var shutdownBitcore = function(callback) {
|
||||
if (bitcore.process) {
|
||||
bitcore.process.kill();
|
||||
var shutdownFlocore = function(callback) {
|
||||
if (flocore.process) {
|
||||
flocore.process.kill();
|
||||
}
|
||||
callback();
|
||||
};
|
||||
|
||||
var writeBitcoreConf = function() {
|
||||
fs.writeFileSync(bitcore.configFile.file, JSON.stringify(bitcore.configFile.conf));
|
||||
var writeFlocoreConf = function() {
|
||||
fs.writeFileSync(flocore.configFile.file, JSON.stringify(flocore.configFile.conf));
|
||||
};
|
||||
|
||||
var startBitcore = function(callback) {
|
||||
var startFlocore = function(callback) {
|
||||
|
||||
var args = bitcore.args;
|
||||
console.log('Using bitcored from: ');
|
||||
var args = flocore.args;
|
||||
console.log('Using flocored from: ');
|
||||
async.series([
|
||||
function(next) {
|
||||
exec('which bitcored', function(err, stdout, stderr) {
|
||||
exec('which flocored', function(err, stdout, stderr) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
@ -298,16 +298,16 @@ var startBitcore = function(callback) {
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
bitcore.process = spawn(bitcore.exec, args, bitcore.opts);
|
||||
flocore.process = spawn(flocore.exec, args, flocore.opts);
|
||||
|
||||
bitcore.process.stdout.on('data', function(data) {
|
||||
flocore.process.stdout.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stdout.write(data.toString());
|
||||
}
|
||||
|
||||
});
|
||||
bitcore.process.stderr.on('data', function(data) {
|
||||
flocore.process.stderr.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stderr.write(data.toString());
|
||||
@ -330,21 +330,21 @@ describe('Block', function() {
|
||||
async.series([
|
||||
function(next) {
|
||||
console.log('step 0: setting up directories.');
|
||||
var dirs = bitcoinDataDirs.concat([bitcoreDataDir]);
|
||||
var dirs = florincoinDataDirs.concat([flocoreDataDir]);
|
||||
resetDirs(dirs, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
writeBitcoreConf();
|
||||
writeFlocoreConf();
|
||||
next();
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
startBitcoinds(bitcoinDataDirs, function(err) {
|
||||
startFlorincoinds(florincoinDataDirs, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
waitForBitcoinReady(rpc, function(err) {
|
||||
waitForFlorincoinReady(rpc, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@ -360,15 +360,15 @@ describe('Block', function() {
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
startBitcore(next);
|
||||
startFlocore(next);
|
||||
}
|
||||
], done);
|
||||
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
shutdownBitcore(function() {
|
||||
shutdownBitcoind(done);
|
||||
shutdownFlocore(function() {
|
||||
shutdownFlorincoind(done);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
336
regtest/reorg.js
336
regtest/reorg.js
@ -18,16 +18,16 @@ var rimraf = require('rimraf');
|
||||
var mkdirp = require('mkdirp');
|
||||
var fs = require('fs');
|
||||
var async = require('async');
|
||||
var RPC = require('bitcoind-rpc');
|
||||
var RPC = require('florincoind-rpc');
|
||||
var http = require('http');
|
||||
var bitcore = require('bitcore-lib');
|
||||
var flocore = require('flocore-lib');
|
||||
var exec = require('child_process').exec;
|
||||
var net = require('net');
|
||||
var p2p = require('bitcore-p2p');
|
||||
var bitcore = require('bitcore-lib');
|
||||
var Networks = bitcore.Networks;
|
||||
var BlockHeader = bitcore.BlockHeader;
|
||||
var Block = bitcore.Block;
|
||||
var p2p = require('flocore-p2p');
|
||||
var flocore = require('flocore-lib');
|
||||
var Networks = flocore.Networks;
|
||||
var BlockHeader = flocore.BlockHeader;
|
||||
var Block = flocore.Block;
|
||||
var bcoin = require('bcoin');
|
||||
var BcoinBlock = bcoin.block;
|
||||
var BcoinTx = bcoin.tx;
|
||||
@ -90,7 +90,7 @@ var getOrphanedBlock = function() {
|
||||
return BcoinBlock.fromRaw(require('./data/blocks_orphaned.json')[0], 'hex');
|
||||
};
|
||||
|
||||
var TestBitcoind = function TestBitcoind() {
|
||||
var TestFlorincoind = function TestFlorincoind() {
|
||||
|
||||
var self = this;
|
||||
self._orphans = {};
|
||||
@ -147,7 +147,7 @@ var TestBitcoind = function TestBitcoind() {
|
||||
}
|
||||
|
||||
if (command === 'getheaders') {
|
||||
msg.push(messages.Headers(self._getHeaders())); // these are bitcore block headers
|
||||
msg.push(messages.Headers(self._getHeaders())); // these are flocore block headers
|
||||
}
|
||||
|
||||
if (command === 'getblocks') {
|
||||
@ -223,12 +223,12 @@ var rpc1 = new RPC(rpcConfig);
|
||||
rpcConfig.port++;
|
||||
var rpc2 = new RPC(rpcConfig);
|
||||
var debug = true;
|
||||
var bitcoreDataDir = '/tmp/bitcore';
|
||||
var bitcoinDir1 = '/tmp/bitcoin1';
|
||||
var bitcoinDir2 = '/tmp/bitcoin2';
|
||||
var bitcoinDataDirs = [ bitcoinDir1, bitcoinDir2 ];
|
||||
var flocoreDataDir = '/tmp/flocore';
|
||||
var florincoinDir1 = '/tmp/florincoin1';
|
||||
var florincoinDir2 = '/tmp/florincoin2';
|
||||
var florincoinDataDirs = [ florincoinDir1, florincoinDir2 ];
|
||||
|
||||
var bitcoin = {
|
||||
var florincoin = {
|
||||
args: {
|
||||
datadir: null,
|
||||
listen: 1,
|
||||
@ -240,17 +240,17 @@ var bitcoin = {
|
||||
rpcport: 58332,
|
||||
},
|
||||
datadir: null,
|
||||
exec: 'bitcoind', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/bitcoind
|
||||
exec: 'florincoind', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/florincoind
|
||||
processes: []
|
||||
};
|
||||
|
||||
var bitcore = {
|
||||
var flocore = {
|
||||
configFile: {
|
||||
file: bitcoreDataDir + '/bitcore-node.json',
|
||||
file: flocoreDataDir + '/flocore-node.json',
|
||||
conf: {
|
||||
network: 'regtest',
|
||||
port: 53001,
|
||||
datadir: bitcoreDataDir,
|
||||
datadir: flocoreDataDir,
|
||||
services: [
|
||||
'p2p',
|
||||
'db',
|
||||
@ -260,7 +260,7 @@ var bitcore = {
|
||||
'transaction',
|
||||
'mempool',
|
||||
'web',
|
||||
'insight-api',
|
||||
'flosight-api',
|
||||
'fee',
|
||||
'timestamp'
|
||||
],
|
||||
@ -270,7 +270,7 @@ var bitcore = {
|
||||
{ 'ip': { 'v4': '127.0.0.1' }, port: 18444 }
|
||||
]
|
||||
},
|
||||
'insight-api': {
|
||||
'flosight-api': {
|
||||
'routePrefix': 'api'
|
||||
},
|
||||
'block': {
|
||||
@ -284,9 +284,9 @@ var bitcore = {
|
||||
hostname: 'localhost',
|
||||
port: 53001,
|
||||
},
|
||||
opts: { cwd: bitcoreDataDir },
|
||||
datadir: bitcoreDataDir,
|
||||
exec: 'bitcored', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/bitcored
|
||||
opts: { cwd: flocoreDataDir },
|
||||
datadir: flocoreDataDir,
|
||||
exec: 'flocored', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/flocored
|
||||
args: ['start'],
|
||||
process: null
|
||||
};
|
||||
@ -296,7 +296,7 @@ var request = function(httpOpts, callback) {
|
||||
var request = http.request(httpOpts, function(res) {
|
||||
|
||||
if (res.statusCode !== 200 && res.statusCode !== 201) {
|
||||
return callback('Error from bitcore-node webserver: ' + res.statusCode);
|
||||
return callback('Error from flocore-node webserver: ' + res.statusCode);
|
||||
}
|
||||
|
||||
var resError;
|
||||
@ -379,17 +379,17 @@ var resetDirs = function(dirs, callback) {
|
||||
|
||||
};
|
||||
|
||||
var startBitcoind = function(callback) {
|
||||
var startFlorincoind = function(callback) {
|
||||
|
||||
var args = bitcoin.args;
|
||||
var args = florincoin.args;
|
||||
var argList = Object.keys(args).map(function(key) {
|
||||
return '-' + key + '=' + args[key];
|
||||
});
|
||||
|
||||
var bitcoinProcess = spawn(bitcoin.exec, argList, bitcoin.opts);
|
||||
bitcoin.processes.push(bitcoinProcess);
|
||||
var florincoinProcess = spawn(florincoin.exec, argList, florincoin.opts);
|
||||
florincoin.processes.push(florincoinProcess);
|
||||
|
||||
bitcoinProcess.stdout.on('data', function(data) {
|
||||
florincoinProcess.stdout.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stdout.write(data.toString());
|
||||
@ -397,7 +397,7 @@ var startBitcoind = function(callback) {
|
||||
|
||||
});
|
||||
|
||||
bitcoinProcess.stderr.on('data', function(data) {
|
||||
florincoinProcess.stderr.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stderr.write(data.toString());
|
||||
@ -409,40 +409,40 @@ var startBitcoind = function(callback) {
|
||||
};
|
||||
|
||||
|
||||
var reportBitcoindsStarted = function() {
|
||||
var pids = bitcoin.processes.map(function(process) {
|
||||
var reportFlorincoindsStarted = function() {
|
||||
var pids = florincoin.processes.map(function(process) {
|
||||
return process.pid;
|
||||
});
|
||||
|
||||
console.log(pids.length + ' bitcoind\'s started at pid(s): ' + pids);
|
||||
console.log(pids.length + ' florincoind\'s started at pid(s): ' + pids);
|
||||
};
|
||||
|
||||
var startBitcoinds = function(datadirs, callback) {
|
||||
var startFlorincoinds = function(datadirs, callback) {
|
||||
|
||||
var listenCount = 0;
|
||||
async.eachSeries(datadirs, function(datadir, next) {
|
||||
|
||||
bitcoin.datadir = datadir;
|
||||
bitcoin.args.datadir = datadir;
|
||||
florincoin.datadir = datadir;
|
||||
florincoin.args.datadir = datadir;
|
||||
|
||||
if (listenCount++ > 0) {
|
||||
bitcoin.args.listen = 0;
|
||||
bitcoin.args.rpcport = bitcoin.args.rpcport + 1;
|
||||
bitcoin.args.connect = '127.0.0.1';
|
||||
florincoin.args.listen = 0;
|
||||
florincoin.args.rpcport = florincoin.args.rpcport + 1;
|
||||
florincoin.args.connect = '127.0.0.1';
|
||||
}
|
||||
|
||||
startBitcoind(next);
|
||||
startFlorincoind(next);
|
||||
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
reportBitcoindsStarted();
|
||||
reportFlorincoindsStarted();
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
var waitForBitcoinReady = function(rpc, callback) {
|
||||
var waitForFlorincoinReady = function(rpc, callback) {
|
||||
async.retry({ interval: 1000, times: 1000 }, function(next) {
|
||||
rpc.getInfo(function(err) {
|
||||
if (err) {
|
||||
@ -458,10 +458,10 @@ var waitForBitcoinReady = function(rpc, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
var shutdownBitcoind = function(callback) {
|
||||
var shutdownFlorincoind = function(callback) {
|
||||
var process;
|
||||
do {
|
||||
process = bitcoin.processes.shift();
|
||||
process = florincoin.processes.shift();
|
||||
if (process) {
|
||||
process.kill();
|
||||
}
|
||||
@ -469,24 +469,24 @@ var shutdownBitcoind = function(callback) {
|
||||
setTimeout(callback, 3000);
|
||||
};
|
||||
|
||||
var shutdownBitcore = function(callback) {
|
||||
if (bitcore.process) {
|
||||
bitcore.process.kill();
|
||||
var shutdownFlocore = function(callback) {
|
||||
if (flocore.process) {
|
||||
flocore.process.kill();
|
||||
}
|
||||
callback();
|
||||
};
|
||||
|
||||
var writeBitcoreConf = function() {
|
||||
fs.writeFileSync(bitcore.configFile.file, JSON.stringify(bitcore.configFile.conf));
|
||||
var writeFlocoreConf = function() {
|
||||
fs.writeFileSync(flocore.configFile.file, JSON.stringify(flocore.configFile.conf));
|
||||
};
|
||||
|
||||
var startBitcore = function(callback) {
|
||||
var startFlocore = function(callback) {
|
||||
|
||||
var args = bitcore.args;
|
||||
console.log('Using bitcored from: ');
|
||||
var args = flocore.args;
|
||||
console.log('Using flocored from: ');
|
||||
async.series([
|
||||
function(next) {
|
||||
exec('which bitcored', function(err, stdout, stderr) {
|
||||
exec('which flocored', function(err, stdout, stderr) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
@ -495,16 +495,16 @@ var startBitcore = function(callback) {
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
bitcore.process = spawn(bitcore.exec, args, bitcore.opts);
|
||||
flocore.process = spawn(flocore.exec, args, flocore.opts);
|
||||
|
||||
bitcore.process.stdout.on('data', function(data) {
|
||||
flocore.process.stdout.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stdout.write(data.toString());
|
||||
}
|
||||
|
||||
});
|
||||
bitcore.process.stderr.on('data', function(data) {
|
||||
flocore.process.stderr.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stderr.write(data.toString());
|
||||
@ -521,7 +521,7 @@ var startBitcore = function(callback) {
|
||||
var sync100Blocks = function(callback) {
|
||||
// regtests can generate high numbers of blocks all at one time, but
|
||||
// the full node may not relay those blocks faithfully. This is a problem
|
||||
// with the full node and not bitcore. So, generate blocks at a slow rate
|
||||
// with the full node and not flocore. So, generate blocks at a slow rate
|
||||
async.timesSeries(100, function(n, next) {
|
||||
rpc2.generate(1, function(err) {
|
||||
if (err) {
|
||||
@ -544,43 +544,43 @@ var performTest1 = function(callback) {
|
||||
// 0. reset the test directories
|
||||
function(next) {
|
||||
console.log('step 0: setting up directories.');
|
||||
var dirs = bitcoinDataDirs.concat([bitcoreDataDir]);
|
||||
var dirs = florincoinDataDirs.concat([flocoreDataDir]);
|
||||
resetDirs(dirs, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
writeBitcoreConf();
|
||||
writeFlocoreConf();
|
||||
next();
|
||||
});
|
||||
},
|
||||
// 1. start 2 bitcoinds in regtest mode
|
||||
// 1. start 2 florincoinds in regtest mode
|
||||
function(next) {
|
||||
console.log('step 1: starting 2 bitcoinds.');
|
||||
startBitcoinds(bitcoinDataDirs, function(err) {
|
||||
console.log('step 1: starting 2 florincoinds.');
|
||||
startFlorincoinds(florincoinDataDirs, function(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
waitForBitcoinReady(rpc1, next);
|
||||
waitForFlorincoinReady(rpc1, next);
|
||||
});
|
||||
},
|
||||
// 2. ensure that both bitcoind's are connected
|
||||
// 2. ensure that both florincoind's are connected
|
||||
function(next) {
|
||||
console.log('step 2: checking to see if bitcoind\'s are connected to each other.');
|
||||
console.log('step 2: checking to see if florincoind\'s are connected to each other.');
|
||||
rpc1.getInfo(function(err, res) {
|
||||
if (err || res.result.connections !== 1) {
|
||||
next(err || new Error('bitcoind\'s not connected to each other.'));
|
||||
next(err || new Error('florincoind\'s not connected to each other.'));
|
||||
}
|
||||
console.log('bitcoind\'s are connected.');
|
||||
console.log('florincoind\'s are connected.');
|
||||
next();
|
||||
});
|
||||
},
|
||||
// 3. generate 10 blocks on the 1st bitcoind
|
||||
// 3. generate 10 blocks on the 1st florincoind
|
||||
function(next) {
|
||||
blocksGenerated += 10;
|
||||
console.log('step 3: generating 10 blocks on bitcoin 1.');
|
||||
console.log('step 3: generating 10 blocks on florincoin 1.');
|
||||
rpc1.generate(10, next);
|
||||
},
|
||||
// 4. ensure that the 2nd bitcoind syncs those blocks
|
||||
// 4. ensure that the 2nd florincoind syncs those blocks
|
||||
function(next) {
|
||||
console.log('step 4: checking for synced blocks.');
|
||||
async.retry(function(next) {
|
||||
@ -588,67 +588,67 @@ var performTest1 = function(callback) {
|
||||
if (err || res.result.blocks < 10) {
|
||||
return next(1);
|
||||
}
|
||||
console.log('bitcoin 2 has synced the blocks generated on bitcoin 1.');
|
||||
console.log('florincoin 2 has synced the blocks generated on florincoin 1.');
|
||||
next();
|
||||
});
|
||||
}, next);
|
||||
},
|
||||
// 5. start up bitcore and let it sync the 10 blocks
|
||||
// 5. start up flocore and let it sync the 10 blocks
|
||||
function(next) {
|
||||
console.log('step 5: starting bitcore...');
|
||||
startBitcore(next);
|
||||
console.log('step 5: starting flocore...');
|
||||
startFlocore(next);
|
||||
},
|
||||
function(next) {
|
||||
// 6. shut down both bitcoind's
|
||||
console.log('bitcore is running and sync\'ed.');
|
||||
console.log('step 6: shutting down all bitcoind\'s.');
|
||||
shutdownBitcoind(next);
|
||||
// 6. shut down both florincoind's
|
||||
console.log('flocore is running and sync\'ed.');
|
||||
console.log('step 6: shutting down all florincoind\'s.');
|
||||
shutdownFlorincoind(next);
|
||||
},
|
||||
// 7. change the config for the second bitcoind to listen for p2p, start bitcoin 2
|
||||
// 7. change the config for the second florincoind to listen for p2p, start florincoin 2
|
||||
function(next) {
|
||||
console.log('step 7: changing config of bitcoin 2 and restarting it.');
|
||||
bitcoin.datadir = bitcoinDataDirs[1];
|
||||
bitcoin.args.datadir = bitcoinDataDirs[1];
|
||||
bitcoin.args.listen = 1;
|
||||
startBitcoind(function(err) {
|
||||
console.log('step 7: changing config of florincoin 2 and restarting it.');
|
||||
florincoin.datadir = florincoinDataDirs[1];
|
||||
florincoin.args.datadir = florincoinDataDirs[1];
|
||||
florincoin.args.listen = 1;
|
||||
startFlorincoind(function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
reportBitcoindsStarted();
|
||||
waitForBitcoinReady(rpc2, next);
|
||||
reportFlorincoindsStarted();
|
||||
waitForFlorincoinReady(rpc2, next);
|
||||
});
|
||||
},
|
||||
// 8. generate 100 blocks on the second bitcoind
|
||||
// 8. generate 100 blocks on the second florincoind
|
||||
function(next) {
|
||||
console.log('step 8: generating 100 blocks on bitcoin 2.');
|
||||
console.log('step 8: generating 100 blocks on florincoin 2.');
|
||||
blocksGenerated += 100;
|
||||
console.log('generating 100 blocks on bitcoin 2.');
|
||||
console.log('generating 100 blocks on florincoin 2.');
|
||||
sync100Blocks(next);
|
||||
},
|
||||
// 9. let bitcore connect and sync those 100 blocks
|
||||
// 9. let flocore connect and sync those 100 blocks
|
||||
function(next) {
|
||||
console.log('step 9: syncing 100 blocks to bitcore.');
|
||||
console.log('step 9: syncing 100 blocks to flocore.');
|
||||
waitForBlocksGenerated(next);
|
||||
},
|
||||
// 10. shutdown the second bitcoind
|
||||
// 10. shutdown the second florincoind
|
||||
function(next) {
|
||||
console.log('100 more blocks synced to bitcore.');
|
||||
console.log('step 10: shutting down bitcoin 2.');
|
||||
shutdownBitcoind(next);
|
||||
console.log('100 more blocks synced to flocore.');
|
||||
console.log('step 10: shutting down florincoin 2.');
|
||||
shutdownFlorincoind(next);
|
||||
},
|
||||
// 11. start up the first bitcoind
|
||||
// 11. start up the first florincoind
|
||||
function(next) {
|
||||
console.log('bitcoin 2 shut down.');
|
||||
console.log('step 11: starting up bitcoin 1');
|
||||
bitcoin.args.rpcport = bitcoin.args.rpcport - 1;
|
||||
bitcoin.datadir = bitcoinDataDirs[0];
|
||||
bitcoin.args.datadir = bitcoinDataDirs[0];
|
||||
startBitcoind(function(err) {
|
||||
console.log('florincoin 2 shut down.');
|
||||
console.log('step 11: starting up florincoin 1');
|
||||
florincoin.args.rpcport = florincoin.args.rpcport - 1;
|
||||
florincoin.datadir = florincoinDataDirs[0];
|
||||
florincoin.args.datadir = florincoinDataDirs[0];
|
||||
startFlorincoind(function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
reportBitcoindsStarted();
|
||||
waitForBitcoinReady(rpc1, next);
|
||||
reportFlorincoindsStarted();
|
||||
waitForFlorincoinReady(rpc1, next);
|
||||
});
|
||||
},
|
||||
// 12. generate one block
|
||||
@ -664,9 +664,9 @@ var performTest1 = function(callback) {
|
||||
next();
|
||||
});
|
||||
},
|
||||
// 13. let bitcore sync that block and reorg back to it
|
||||
// 13. let flocore sync that block and reorg back to it
|
||||
function(next) {
|
||||
console.log('step 13: Waiting for bitcore to reorg to block height 11.');
|
||||
console.log('step 13: Waiting for flocore to reorg to block height 11.');
|
||||
waitForBlocksGenerated(next);
|
||||
}
|
||||
], function(err) {
|
||||
@ -686,13 +686,13 @@ var performTest2 = function(fakeServer, callback) {
|
||||
// 0. reset the test directories
|
||||
function(next) {
|
||||
console.log('step 0: setting up directories.');
|
||||
bitcore.configFile.conf.servicesConfig.header = { slowMode: 1000 };
|
||||
var dirs = bitcoinDataDirs.concat([bitcoreDataDir]);
|
||||
flocore.configFile.conf.servicesConfig.header = { slowMode: 1000 };
|
||||
var dirs = florincoinDataDirs.concat([flocoreDataDir]);
|
||||
resetDirs(dirs, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
writeBitcoreConf();
|
||||
writeFlocoreConf();
|
||||
next();
|
||||
});
|
||||
},
|
||||
@ -702,17 +702,17 @@ var performTest2 = function(fakeServer, callback) {
|
||||
fakeServer.start();
|
||||
next();
|
||||
},
|
||||
// 2. init server with blocks (the initial set from which bitcore will sync)
|
||||
// 2. init server with blocks (the initial set from which flocore will sync)
|
||||
function(next) {
|
||||
console.log('step 2: init server with blocks (the initial set from which bitcore will sync)');
|
||||
console.log('step 2: init server with blocks (the initial set from which flocore will sync)');
|
||||
next();
|
||||
},
|
||||
// 3. start bitcore in slow mode (slow the block service's sync speed down so we
|
||||
// 3. start flocore in slow mode (slow the block service's sync speed down so we
|
||||
// can send a reorg block to the header service while the block service is still syncing.
|
||||
function(next) {
|
||||
console.log('step 3: start bitcore in slow mode.');
|
||||
console.log('step 3: start flocore in slow mode.');
|
||||
blocksGenerated = 4;
|
||||
startBitcore(next);
|
||||
startFlocore(next);
|
||||
},
|
||||
function(next) {
|
||||
console.log('step 4: send a block in to reorg the header service without reorging the block service.');
|
||||
@ -737,13 +737,13 @@ var performTest3 = function(fakeServer, callback) {
|
||||
// 0. reset the test directories
|
||||
function(next) {
|
||||
console.log('step 0: setting up directories.');
|
||||
bitcore.configFile.conf.servicesConfig.header = { slowMode: 1000 };
|
||||
var dirs = bitcoinDataDirs.concat([bitcoreDataDir]);
|
||||
flocore.configFile.conf.servicesConfig.header = { slowMode: 1000 };
|
||||
var dirs = florincoinDataDirs.concat([flocoreDataDir]);
|
||||
resetDirs(dirs, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
writeBitcoreConf();
|
||||
writeFlocoreConf();
|
||||
next();
|
||||
});
|
||||
},
|
||||
@ -753,17 +753,17 @@ var performTest3 = function(fakeServer, callback) {
|
||||
fakeServer.start();
|
||||
next();
|
||||
},
|
||||
// 2. init server with blocks (the initial set from which bitcore will sync)
|
||||
// 2. init server with blocks (the initial set from which flocore will sync)
|
||||
function(next) {
|
||||
console.log('step 2: init server with blocks (the initial set from which bitcore will sync)');
|
||||
console.log('step 2: init server with blocks (the initial set from which flocore will sync)');
|
||||
next();
|
||||
},
|
||||
// 3. start bitcore in slow mode (slow the block service's sync speed down so we
|
||||
// 3. start flocore in slow mode (slow the block service's sync speed down so we
|
||||
// can send a reorg block to the header service while the block service is still syncing.
|
||||
function(next) {
|
||||
console.log('step 3: start bitcore in slow mode.');
|
||||
console.log('step 3: start flocore in slow mode.');
|
||||
blocksGenerated = 6;
|
||||
startBitcore(next);
|
||||
startFlocore(next);
|
||||
},
|
||||
function(next) {
|
||||
console.log('step 4: send a block in to reorg the header service without reorging the block service.');
|
||||
@ -796,12 +796,12 @@ var performTest4 = function(fakeServer, callback) {
|
||||
// 0. reset the test directories
|
||||
function(next) {
|
||||
console.log('step 0: setting up directories.');
|
||||
var dirs = bitcoinDataDirs.concat([bitcoreDataDir]);
|
||||
var dirs = florincoinDataDirs.concat([flocoreDataDir]);
|
||||
resetDirs(dirs, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
writeBitcoreConf();
|
||||
writeFlocoreConf();
|
||||
next();
|
||||
});
|
||||
},
|
||||
@ -811,16 +811,16 @@ var performTest4 = function(fakeServer, callback) {
|
||||
fakeServer.start();
|
||||
next();
|
||||
},
|
||||
// 2. start bitcore
|
||||
// 2. start flocore
|
||||
function(next) {
|
||||
console.log('step 2: start bitcore and let sync.');
|
||||
console.log('step 2: start flocore and let sync.');
|
||||
blocksGenerated = 7;
|
||||
startBitcore(next);
|
||||
startFlocore(next);
|
||||
},
|
||||
// 3. shutdown bitcore
|
||||
// 3. shutdown flocore
|
||||
function(next) {
|
||||
console.log('step 3: shut down bitcore.');
|
||||
shutdownBitcore(next);
|
||||
console.log('step 3: shut down flocore.');
|
||||
shutdownFlocore(next);
|
||||
},
|
||||
// 4. setup the fake server to send a reorg'ed set of headers
|
||||
function(next) {
|
||||
@ -829,11 +829,11 @@ var performTest4 = function(fakeServer, callback) {
|
||||
fakeServer.reorientData(reorgBlock);
|
||||
next();
|
||||
},
|
||||
// 5. start up bitcore once again
|
||||
// 5. start up flocore once again
|
||||
function(next) {
|
||||
console.log('step 5: start up bitcore.');
|
||||
console.log('step 5: start up flocore.');
|
||||
blocksGenerated = 7;
|
||||
startBitcore(next);
|
||||
startFlocore(next);
|
||||
}
|
||||
], function(err) {
|
||||
if (err) {
|
||||
@ -851,12 +851,12 @@ var performTest5 = function(fakeServer, callback) {
|
||||
// 0. reset the test directories
|
||||
function(next) {
|
||||
console.log('step 0: setting up directories.');
|
||||
var dirs = bitcoinDataDirs.concat([bitcoreDataDir]);
|
||||
var dirs = florincoinDataDirs.concat([flocoreDataDir]);
|
||||
resetDirs(dirs, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
writeBitcoreConf();
|
||||
writeFlocoreConf();
|
||||
next();
|
||||
});
|
||||
},
|
||||
@ -866,11 +866,11 @@ var performTest5 = function(fakeServer, callback) {
|
||||
fakeServer.start();
|
||||
next();
|
||||
},
|
||||
// 2. start bitcore
|
||||
// 2. start flocore
|
||||
function(next) {
|
||||
console.log('step 2: start bitcore and let sync.');
|
||||
console.log('step 2: start flocore and let sync.');
|
||||
blocksGenerated = 7;
|
||||
startBitcore(next);
|
||||
startFlocore(next);
|
||||
},
|
||||
// 3. send in a block that has nothing to do with anything in my chain.
|
||||
function(next) {
|
||||
@ -895,30 +895,30 @@ describe('Reorg', function() {
|
||||
describe('Reorg case 1: block service fully sync\'ed, p2p block subscription active (normal operating mode)', function() {
|
||||
|
||||
after(function(done) {
|
||||
shutdownBitcore(function() {
|
||||
shutdownBitcoind(done);
|
||||
shutdownFlocore(function() {
|
||||
shutdownFlorincoind(done);
|
||||
});
|
||||
});
|
||||
|
||||
// case 1.
|
||||
it('should reorg correctly when bitcore reconnects to a peer that is not yet sync\'ed, but when a block does come in, it is a reorg block.', function(done) {
|
||||
it('should reorg correctly when flocore reconnects to a peer that is not yet sync\'ed, but when a block does come in, it is a reorg block.', function(done) {
|
||||
/*
|
||||
What this test does:
|
||||
|
||||
step 0: set up directories
|
||||
step 1: start 2 bitcoinds.
|
||||
step 2: check to see if bitcoind's are connected to each other.
|
||||
step 3: generate 10 blocks on bitcoin 1.
|
||||
step 4: check for synced blocks between bitcoinds.
|
||||
step 5: start bitcore
|
||||
step 6: shut down all bitcoind's.
|
||||
step 7: change config of bitcoin 2 and restart it.
|
||||
step 8: generate 100 blocks on bitcoin 2.
|
||||
step 9: sync 100 blocks to bitcore.
|
||||
step 10: shut down bitcoin 2.
|
||||
step 11: start up bitcoin 1
|
||||
step 1: start 2 florincoinds.
|
||||
step 2: check to see if florincoind's are connected to each other.
|
||||
step 3: generate 10 blocks on florincoin 1.
|
||||
step 4: check for synced blocks between florincoinds.
|
||||
step 5: start flocore
|
||||
step 6: shut down all florincoind's.
|
||||
step 7: change config of florincoin 2 and restart it.
|
||||
step 8: generate 100 blocks on florincoin 2.
|
||||
step 9: sync 100 blocks to flocore.
|
||||
step 10: shut down florincoin 2.
|
||||
step 11: start up florincoin 1
|
||||
step 12: generate 1 block
|
||||
step 13: Wait for bitcore to reorg to block height 11.
|
||||
step 13: Wait for flocore to reorg to block height 11.
|
||||
*/
|
||||
|
||||
|
||||
@ -959,12 +959,12 @@ describe('Reorg', function() {
|
||||
|
||||
var fakeServer;
|
||||
before(function(done) {
|
||||
fakeServer = new TestBitcoind();
|
||||
fakeServer = new TestFlorincoind();
|
||||
done();
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
shutdownBitcore(function() {
|
||||
shutdownFlocore(function() {
|
||||
fakeServer.stop();
|
||||
done();
|
||||
});
|
||||
@ -976,14 +976,14 @@ describe('Reorg', function() {
|
||||
What this test does:
|
||||
|
||||
step 0: setup directories
|
||||
step 1: start fake server (fake bitcoin)
|
||||
step 2: init server with blocks (the initial set from which bitcore will sync)
|
||||
step 3: start bitcore in slow mode (slow the block service's sync speed down so we
|
||||
step 1: start fake server (fake florincoin)
|
||||
step 2: init server with blocks (the initial set from which flocore will sync)
|
||||
step 3: start flocore in slow mode (slow the block service's sync speed down so we
|
||||
can send a reorg block to the header service while the block service is still syncing.
|
||||
step 4: send an inventory message with a reorg block hash
|
||||
|
||||
the header service will get this message, discover the reorg, handle the reorg
|
||||
and call onHeaders on the block service, query bitcore for the results
|
||||
and call onHeaders on the block service, query flocore for the results
|
||||
*/
|
||||
performTest2(fakeServer, function(err) {
|
||||
|
||||
@ -1022,12 +1022,12 @@ describe('Reorg', function() {
|
||||
|
||||
var fakeServer;
|
||||
before(function(done) {
|
||||
fakeServer = new TestBitcoind();
|
||||
fakeServer = new TestFlorincoind();
|
||||
done();
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
shutdownBitcore(function() {
|
||||
shutdownFlocore(function() {
|
||||
fakeServer.stop();
|
||||
done();
|
||||
});
|
||||
@ -1039,9 +1039,9 @@ describe('Reorg', function() {
|
||||
What this test does:
|
||||
|
||||
step 0: setup directories
|
||||
step 1: start fake server (fake bitcoin)
|
||||
step 2: init server with blocks (the initial set from which bitcore will sync)
|
||||
step 3: start bitcore in slow mode
|
||||
step 1: start fake server (fake florincoin)
|
||||
step 2: init server with blocks (the initial set from which flocore will sync)
|
||||
step 3: start flocore in slow mode
|
||||
step 4: send an inventory message with a reorg block hash
|
||||
|
||||
*/
|
||||
@ -1081,12 +1081,12 @@ describe('Reorg', function() {
|
||||
|
||||
var fakeServer;
|
||||
before(function(done) {
|
||||
fakeServer = new TestBitcoind();
|
||||
fakeServer = new TestFlorincoind();
|
||||
done();
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
shutdownBitcore(function() {
|
||||
shutdownFlocore(function() {
|
||||
fakeServer.stop();
|
||||
done();
|
||||
});
|
||||
@ -1124,12 +1124,12 @@ describe('Reorg', function() {
|
||||
|
||||
var fakeServer;
|
||||
before(function(done) {
|
||||
fakeServer = new TestBitcoind();
|
||||
fakeServer = new TestFlorincoind();
|
||||
done();
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
shutdownBitcore(function() {
|
||||
shutdownFlocore(function() {
|
||||
fakeServer.stop();
|
||||
done();
|
||||
});
|
||||
|
||||
@ -6,7 +6,7 @@ var rimraf = require('rimraf');
|
||||
var mkdirp = require('mkdirp');
|
||||
var fs = require('fs');
|
||||
var async = require('async');
|
||||
var RPC = require('bitcoind-rpc');
|
||||
var RPC = require('florincoind-rpc');
|
||||
var http = require('http');
|
||||
|
||||
var rpc1Address;
|
||||
@ -28,10 +28,10 @@ var rpc1 = new RPC(rpcConfig);
|
||||
rpcConfig.port++;
|
||||
var rpc2 = new RPC(rpcConfig);
|
||||
var debug = true;
|
||||
var bitcoreDataDir = '/tmp/bitcore';
|
||||
var bitcoinDataDirs = ['/tmp/bitcoin1', '/tmp/bitcoin2'];
|
||||
var flocoreDataDir = '/tmp/flocore';
|
||||
var florincoinDataDirs = ['/tmp/florincoin1', '/tmp/florincoin2'];
|
||||
|
||||
var bitcoin = {
|
||||
var florincoin = {
|
||||
args: {
|
||||
datadir: null,
|
||||
listen: 1,
|
||||
@ -43,17 +43,17 @@ var bitcoin = {
|
||||
rpcport: 58332,
|
||||
},
|
||||
datadir: null,
|
||||
exec: 'bitcoind', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/bitcoind
|
||||
exec: 'florincoind', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/florincoind
|
||||
processes: []
|
||||
};
|
||||
|
||||
var bitcore = {
|
||||
var flocore = {
|
||||
configFile: {
|
||||
file: bitcoreDataDir + '/bitcore-node.json',
|
||||
file: flocoreDataDir + '/flocore-node.json',
|
||||
conf: {
|
||||
network: 'regtest',
|
||||
port: 53001,
|
||||
datadir: bitcoreDataDir,
|
||||
datadir: flocoreDataDir,
|
||||
services: [
|
||||
'p2p',
|
||||
'db',
|
||||
@ -63,7 +63,7 @@ var bitcore = {
|
||||
'transaction',
|
||||
'mempool',
|
||||
'web',
|
||||
'insight-api',
|
||||
'flosight-api',
|
||||
'fee',
|
||||
'timestamp'
|
||||
],
|
||||
@ -82,7 +82,7 @@ var bitcore = {
|
||||
'port': 58332
|
||||
}
|
||||
},
|
||||
'insight-api': {
|
||||
'flosight-api': {
|
||||
'routePrefix': 'api'
|
||||
}
|
||||
}
|
||||
@ -93,27 +93,27 @@ var bitcore = {
|
||||
hostname: 'localhost',
|
||||
port: 53001,
|
||||
},
|
||||
opts: { cwd: bitcoreDataDir },
|
||||
datadir: bitcoreDataDir,
|
||||
exec: 'bitcored',
|
||||
opts: { cwd: flocoreDataDir },
|
||||
datadir: flocoreDataDir,
|
||||
exec: 'flocored',
|
||||
args: ['start'],
|
||||
process: null
|
||||
};
|
||||
|
||||
var startBitcoind = function(count, callback) {
|
||||
var startFlorincoind = function(count, callback) {
|
||||
|
||||
var listenCount = 0;
|
||||
async.timesSeries(count, function(n, next) {
|
||||
|
||||
var datadir = bitcoinDataDirs.shift();
|
||||
var datadir = florincoinDataDirs.shift();
|
||||
|
||||
bitcoin.datadir = datadir;
|
||||
bitcoin.args.datadir = datadir;
|
||||
florincoin.datadir = datadir;
|
||||
florincoin.args.datadir = datadir;
|
||||
|
||||
if (listenCount++ > 0) {
|
||||
bitcoin.args.listen = 0;
|
||||
bitcoin.args.rpcport++;
|
||||
bitcoin.args.connect = '127.0.0.1';
|
||||
florincoin.args.listen = 0;
|
||||
florincoin.args.rpcport++;
|
||||
florincoin.args.connect = '127.0.0.1';
|
||||
}
|
||||
|
||||
rimraf(datadir, function(err) {
|
||||
@ -128,15 +128,15 @@ var startBitcoind = function(count, callback) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
var args = bitcoin.args;
|
||||
var args = florincoin.args;
|
||||
var argList = Object.keys(args).map(function(key) {
|
||||
return '-' + key + '=' + args[key];
|
||||
});
|
||||
|
||||
var bitcoinProcess = spawn(bitcoin.exec, argList, bitcoin.opts);
|
||||
bitcoin.processes.push(bitcoinProcess);
|
||||
var florincoinProcess = spawn(florincoin.exec, argList, florincoin.opts);
|
||||
florincoin.processes.push(florincoinProcess);
|
||||
|
||||
bitcoinProcess.stdout.on('data', function(data) {
|
||||
florincoinProcess.stdout.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stdout.write(data.toString());
|
||||
@ -144,7 +144,7 @@ var startBitcoind = function(count, callback) {
|
||||
|
||||
});
|
||||
|
||||
bitcoinProcess.stderr.on('data', function(data) {
|
||||
florincoinProcess.stderr.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stderr.write(data.toString());
|
||||
@ -163,26 +163,26 @@ var startBitcoind = function(count, callback) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var pids = bitcoin.processes.map(function(process) {
|
||||
var pids = florincoin.processes.map(function(process) {
|
||||
return process.pid;
|
||||
});
|
||||
|
||||
console.log(count + ' bitcoind\'s started at pid(s): ' + pids);
|
||||
console.log(count + ' florincoind\'s started at pid(s): ' + pids);
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
var shutdownBitcoind = function(callback) {
|
||||
bitcoin.processes.forEach(function(process) {
|
||||
var shutdownFlorincoind = function(callback) {
|
||||
florincoin.processes.forEach(function(process) {
|
||||
process.kill();
|
||||
});
|
||||
setTimeout(callback, 3000);
|
||||
};
|
||||
|
||||
var shutdownBitcore = function(callback) {
|
||||
if (bitcore.process) {
|
||||
bitcore.process.kill();
|
||||
var shutdownFlocore = function(callback) {
|
||||
if (flocore.process) {
|
||||
flocore.process.kill();
|
||||
}
|
||||
callback();
|
||||
};
|
||||
@ -191,10 +191,10 @@ var shutdownBitcore = function(callback) {
|
||||
var buildInitialChain = function(callback) {
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
console.log('checking to see if bitcoind\'s are connected to each other.');
|
||||
console.log('checking to see if florincoind\'s are connected to each other.');
|
||||
rpc1.getinfo(function(err, res) {
|
||||
if (err || res.result.connections !== 1) {
|
||||
next(err || new Error('bitcoind\'s not connected to each other.'));
|
||||
next(err || new Error('florincoind\'s not connected to each other.'));
|
||||
}
|
||||
next();
|
||||
});
|
||||
@ -262,33 +262,33 @@ var buildInitialChain = function(callback) {
|
||||
|
||||
};
|
||||
|
||||
var startBitcore = function(callback) {
|
||||
var startFlocore = function(callback) {
|
||||
|
||||
rimraf(bitcoreDataDir, function(err) {
|
||||
rimraf(flocoreDataDir, function(err) {
|
||||
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
mkdirp(bitcoreDataDir, function(err) {
|
||||
mkdirp(flocoreDataDir, function(err) {
|
||||
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
fs.writeFileSync(bitcore.configFile.file, JSON.stringify(bitcore.configFile.conf));
|
||||
fs.writeFileSync(flocore.configFile.file, JSON.stringify(flocore.configFile.conf));
|
||||
|
||||
var args = bitcore.args;
|
||||
bitcore.process = spawn(bitcore.exec, args, bitcore.opts);
|
||||
var args = flocore.args;
|
||||
flocore.process = spawn(flocore.exec, args, flocore.opts);
|
||||
|
||||
bitcore.process.stdout.on('data', function(data) {
|
||||
flocore.process.stdout.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stdout.write(data.toString());
|
||||
}
|
||||
|
||||
});
|
||||
bitcore.process.stderr.on('data', function(data) {
|
||||
flocore.process.stderr.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stderr.write(data.toString());
|
||||
@ -312,7 +312,7 @@ describe('Status', function() {
|
||||
|
||||
async.series([
|
||||
function(next) {
|
||||
startBitcoind(2, next);
|
||||
startFlorincoind(2, next);
|
||||
},
|
||||
function(next) {
|
||||
setTimeout(function() {
|
||||
@ -321,7 +321,7 @@ describe('Status', function() {
|
||||
},
|
||||
function(next) {
|
||||
setTimeout(function() {
|
||||
startBitcore(next);
|
||||
startFlocore(next);
|
||||
}, 6000);
|
||||
}
|
||||
], function(err) {
|
||||
@ -334,8 +334,8 @@ describe('Status', function() {
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
shutdownBitcore(function() {
|
||||
shutdownBitcoind(done);
|
||||
shutdownFlocore(function() {
|
||||
shutdownFlorincoind(done);
|
||||
});
|
||||
});
|
||||
|
||||
@ -350,7 +350,7 @@ describe('Status', function() {
|
||||
return;
|
||||
}
|
||||
|
||||
return done('Error from bitcore-node webserver: ' + res.statusCode);
|
||||
return done('Error from flocore-node webserver: ' + res.statusCode);
|
||||
|
||||
}
|
||||
|
||||
@ -390,7 +390,7 @@ describe('Status', function() {
|
||||
return;
|
||||
}
|
||||
|
||||
return done('Error from bitcore-node webserver: ' + res.statusCode);
|
||||
return done('Error from flocore-node webserver: ' + res.statusCode);
|
||||
|
||||
}
|
||||
|
||||
@ -431,7 +431,7 @@ describe('Status', function() {
|
||||
return;
|
||||
}
|
||||
|
||||
return done('Error from bitcore-node webserver: ' + res.statusCode);
|
||||
return done('Error from flocore-node webserver: ' + res.statusCode);
|
||||
|
||||
}
|
||||
|
||||
@ -472,7 +472,7 @@ describe('Status', function() {
|
||||
return;
|
||||
}
|
||||
|
||||
return done('Error from bitcore-node webserver: ' + res.statusCode);
|
||||
return done('Error from flocore-node webserver: ' + res.statusCode);
|
||||
|
||||
}
|
||||
|
||||
@ -515,7 +515,7 @@ describe('Status', function() {
|
||||
return;
|
||||
}
|
||||
|
||||
return done('Error from bitcore-node webserver: ' + res.statusCode);
|
||||
return done('Error from flocore-node webserver: ' + res.statusCode);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -6,14 +6,14 @@ var rimraf = require('rimraf');
|
||||
var mkdirp = require('mkdirp');
|
||||
var fs = require('fs');
|
||||
var async = require('async');
|
||||
var RPC = require('bitcoind-rpc');
|
||||
var RPC = require('florincoind-rpc');
|
||||
var http = require('http');
|
||||
var bitcore = require('bitcore-lib');
|
||||
var flocore = require('flocore-lib');
|
||||
var exec = require('child_process').exec;
|
||||
var bitcore = require('bitcore-lib');
|
||||
var Block = bitcore.Block;
|
||||
var PrivateKey = bitcore.PrivateKey;
|
||||
var Transaction = bitcore.Transaction;
|
||||
var flocore = require('flocore-lib');
|
||||
var Block = flocore.Block;
|
||||
var PrivateKey = flocore.PrivateKey;
|
||||
var Transaction = flocore.Transaction;
|
||||
var io = require('socket.io-client');
|
||||
|
||||
/*
|
||||
@ -39,9 +39,9 @@ var rpcConfig = {
|
||||
|
||||
var rpc = new RPC(rpcConfig);
|
||||
var debug = true;
|
||||
var bitcoreDataDir = '/tmp/bitcore';
|
||||
var bitcoinDir = '/tmp/bitcoin';
|
||||
var bitcoinDataDirs = [ bitcoinDir ];
|
||||
var flocoreDataDir = '/tmp/flocore';
|
||||
var florincoinDir = '/tmp/florincoin';
|
||||
var florincoinDataDirs = [ florincoinDir ];
|
||||
var blocks= [];
|
||||
var pks = [];
|
||||
var initialTx;
|
||||
@ -49,7 +49,7 @@ var startingPk;
|
||||
var txs = [];
|
||||
var txids = [];
|
||||
|
||||
var bitcoin = {
|
||||
var florincoin = {
|
||||
args: {
|
||||
datadir: null,
|
||||
listen: 1,
|
||||
@ -61,17 +61,17 @@ var bitcoin = {
|
||||
rpcport: 58332,
|
||||
},
|
||||
datadir: null,
|
||||
exec: 'bitcoind', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/bitcoind
|
||||
exec: 'florincoind', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/florincoind
|
||||
processes: []
|
||||
};
|
||||
|
||||
var bitcore = {
|
||||
var flocore = {
|
||||
configFile: {
|
||||
file: bitcoreDataDir + '/bitcore-node.json',
|
||||
file: flocoreDataDir + '/flocore-node.json',
|
||||
conf: {
|
||||
network: 'regtest',
|
||||
port: 53001,
|
||||
datadir: bitcoreDataDir,
|
||||
datadir: flocoreDataDir,
|
||||
services: [
|
||||
'p2p',
|
||||
'db',
|
||||
@ -81,7 +81,7 @@ var bitcore = {
|
||||
'transaction',
|
||||
'mempool',
|
||||
'web',
|
||||
'insight-api',
|
||||
'flosight-api',
|
||||
'fee',
|
||||
'timestamp'
|
||||
],
|
||||
@ -91,7 +91,7 @@ var bitcore = {
|
||||
{ 'ip': { 'v4': '127.0.0.1' }, port: 18444 }
|
||||
]
|
||||
},
|
||||
'insight-api': {
|
||||
'flosight-api': {
|
||||
'routePrefix': 'api'
|
||||
},
|
||||
'block': {
|
||||
@ -105,9 +105,9 @@ var bitcore = {
|
||||
hostname: 'localhost',
|
||||
port: 53001,
|
||||
},
|
||||
opts: { cwd: bitcoreDataDir },
|
||||
datadir: bitcoreDataDir,
|
||||
exec: 'bitcored', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/bitcored
|
||||
opts: { cwd: flocoreDataDir },
|
||||
datadir: flocoreDataDir,
|
||||
exec: 'flocored', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/flocored
|
||||
args: ['start'],
|
||||
process: null
|
||||
};
|
||||
@ -117,7 +117,7 @@ var request = function(httpOpts, callback) {
|
||||
var request = http.request(httpOpts, function(res) {
|
||||
|
||||
if (res.statusCode !== 200 && res.statusCode !== 201) {
|
||||
return callback('Error from bitcore-node webserver: ' + res.statusCode);
|
||||
return callback('Error from flocore-node webserver: ' + res.statusCode);
|
||||
}
|
||||
|
||||
var resError;
|
||||
@ -200,17 +200,17 @@ var resetDirs = function(dirs, callback) {
|
||||
|
||||
};
|
||||
|
||||
var startBitcoind = function(callback) {
|
||||
var startFlorincoind = function(callback) {
|
||||
|
||||
var args = bitcoin.args;
|
||||
var args = florincoin.args;
|
||||
var argList = Object.keys(args).map(function(key) {
|
||||
return '-' + key + '=' + args[key];
|
||||
});
|
||||
|
||||
var bitcoinProcess = spawn(bitcoin.exec, argList, bitcoin.opts);
|
||||
bitcoin.processes.push(bitcoinProcess);
|
||||
var florincoinProcess = spawn(florincoin.exec, argList, florincoin.opts);
|
||||
florincoin.processes.push(florincoinProcess);
|
||||
|
||||
bitcoinProcess.stdout.on('data', function(data) {
|
||||
florincoinProcess.stdout.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stdout.write(data.toString());
|
||||
@ -218,7 +218,7 @@ var startBitcoind = function(callback) {
|
||||
|
||||
});
|
||||
|
||||
bitcoinProcess.stderr.on('data', function(data) {
|
||||
florincoinProcess.stderr.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stderr.write(data.toString());
|
||||
@ -230,40 +230,40 @@ var startBitcoind = function(callback) {
|
||||
};
|
||||
|
||||
|
||||
var reportBitcoindsStarted = function() {
|
||||
var pids = bitcoin.processes.map(function(process) {
|
||||
var reportFlorincoindsStarted = function() {
|
||||
var pids = florincoin.processes.map(function(process) {
|
||||
return process.pid;
|
||||
});
|
||||
|
||||
console.log(pids.length + ' bitcoind\'s started at pid(s): ' + pids);
|
||||
console.log(pids.length + ' florincoind\'s started at pid(s): ' + pids);
|
||||
};
|
||||
|
||||
var startBitcoinds = function(datadirs, callback) {
|
||||
var startFlorincoinds = function(datadirs, callback) {
|
||||
|
||||
var listenCount = 0;
|
||||
async.eachSeries(datadirs, function(datadir, next) {
|
||||
|
||||
bitcoin.datadir = datadir;
|
||||
bitcoin.args.datadir = datadir;
|
||||
florincoin.datadir = datadir;
|
||||
florincoin.args.datadir = datadir;
|
||||
|
||||
if (listenCount++ > 0) {
|
||||
bitcoin.args.listen = 0;
|
||||
bitcoin.args.rpcport = bitcoin.args.rpcport + 1;
|
||||
bitcoin.args.connect = '127.0.0.1';
|
||||
florincoin.args.listen = 0;
|
||||
florincoin.args.rpcport = florincoin.args.rpcport + 1;
|
||||
florincoin.args.connect = '127.0.0.1';
|
||||
}
|
||||
|
||||
startBitcoind(next);
|
||||
startFlorincoind(next);
|
||||
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
reportBitcoindsStarted();
|
||||
reportFlorincoindsStarted();
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
var waitForBitcoinReady = function(rpc, callback) {
|
||||
var waitForFlorincoinReady = function(rpc, callback) {
|
||||
async.retry({ interval: 1000, times: 1000 }, function(next) {
|
||||
rpc.getInfo(function(err) {
|
||||
if (err) {
|
||||
@ -279,10 +279,10 @@ var waitForBitcoinReady = function(rpc, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
var shutdownBitcoind = function(callback) {
|
||||
var shutdownFlorincoind = function(callback) {
|
||||
var process;
|
||||
do {
|
||||
process = bitcoin.processes.shift();
|
||||
process = florincoin.processes.shift();
|
||||
if (process) {
|
||||
process.kill();
|
||||
}
|
||||
@ -290,24 +290,24 @@ var shutdownBitcoind = function(callback) {
|
||||
setTimeout(callback, 3000);
|
||||
};
|
||||
|
||||
var shutdownBitcore = function(callback) {
|
||||
if (bitcore.process) {
|
||||
bitcore.process.kill();
|
||||
var shutdownFlocore = function(callback) {
|
||||
if (flocore.process) {
|
||||
flocore.process.kill();
|
||||
}
|
||||
callback();
|
||||
};
|
||||
|
||||
var writeBitcoreConf = function() {
|
||||
fs.writeFileSync(bitcore.configFile.file, JSON.stringify(bitcore.configFile.conf));
|
||||
var writeFlocoreConf = function() {
|
||||
fs.writeFileSync(flocore.configFile.file, JSON.stringify(flocore.configFile.conf));
|
||||
};
|
||||
|
||||
var startBitcore = function(callback) {
|
||||
var startFlocore = function(callback) {
|
||||
|
||||
var args = bitcore.args;
|
||||
console.log('Using bitcored from: ');
|
||||
var args = flocore.args;
|
||||
console.log('Using flocored from: ');
|
||||
async.series([
|
||||
function(next) {
|
||||
exec('which bitcored', function(err, stdout, stderr) {
|
||||
exec('which flocored', function(err, stdout, stderr) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
@ -316,16 +316,16 @@ var startBitcore = function(callback) {
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
bitcore.process = spawn(bitcore.exec, args, bitcore.opts);
|
||||
flocore.process = spawn(flocore.exec, args, flocore.opts);
|
||||
|
||||
bitcore.process.stdout.on('data', function(data) {
|
||||
flocore.process.stdout.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stdout.write(data.toString());
|
||||
}
|
||||
|
||||
});
|
||||
bitcore.process.stderr.on('data', function(data) {
|
||||
flocore.process.stderr.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stderr.write(data.toString());
|
||||
@ -456,22 +456,22 @@ describe('Subscriptions', function() {
|
||||
async.series([
|
||||
function(next) {
|
||||
console.log('step 0: setting up directories.');
|
||||
var dirs = bitcoinDataDirs.concat([bitcoreDataDir]);
|
||||
var dirs = florincoinDataDirs.concat([flocoreDataDir]);
|
||||
resetDirs(dirs, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
writeBitcoreConf();
|
||||
writeFlocoreConf();
|
||||
next();
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
console.log('step 1: start bitcoind');
|
||||
startBitcoinds(bitcoinDataDirs, function(err) {
|
||||
console.log('step 1: start florincoind');
|
||||
startFlorincoinds(florincoinDataDirs, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
waitForBitcoinReady(rpc, function(err) {
|
||||
waitForFlorincoinReady(rpc, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@ -481,8 +481,8 @@ describe('Subscriptions', function() {
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
console.log('step 2: start bitcore');
|
||||
startBitcore(next);
|
||||
console.log('step 2: start flocore');
|
||||
startFlocore(next);
|
||||
},
|
||||
function(next) {
|
||||
console.log('step 3: make local private keys.');
|
||||
@ -498,8 +498,8 @@ describe('Subscriptions', function() {
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
shutdownBitcore(function() {
|
||||
shutdownBitcoind(done);
|
||||
shutdownFlocore(function() {
|
||||
shutdownFlorincoind(done);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ var rimraf = require('rimraf');
|
||||
var mkdirp = require('mkdirp');
|
||||
var fs = require('fs');
|
||||
var async = require('async');
|
||||
var RPC = require('bitcoind-rpc');
|
||||
var RPC = require('florincoind-rpc');
|
||||
var http = require('http');
|
||||
|
||||
var rpc1Address;
|
||||
@ -29,10 +29,10 @@ var rpc1 = new RPC(rpcConfig);
|
||||
rpcConfig.port++;
|
||||
var rpc2 = new RPC(rpcConfig);
|
||||
var debug = true;
|
||||
var bitcoreDataDir = '/tmp/bitcore';
|
||||
var bitcoinDataDirs = ['/tmp/bitcoin1', '/tmp/bitcoin2'];
|
||||
var flocoreDataDir = '/tmp/flocore';
|
||||
var florincoinDataDirs = ['/tmp/florincoin1', '/tmp/florincoin2'];
|
||||
|
||||
var bitcoin = {
|
||||
var florincoin = {
|
||||
args: {
|
||||
datadir: null,
|
||||
listen: 1,
|
||||
@ -44,17 +44,17 @@ var bitcoin = {
|
||||
rpcport: 58332,
|
||||
},
|
||||
datadir: null,
|
||||
exec: 'bitcoind', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/bitcoind
|
||||
exec: 'florincoind', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/florincoind
|
||||
processes: []
|
||||
};
|
||||
|
||||
var bitcore = {
|
||||
var flocore = {
|
||||
configFile: {
|
||||
file: bitcoreDataDir + '/bitcore-node.json',
|
||||
file: flocoreDataDir + '/flocore-node.json',
|
||||
conf: {
|
||||
network: 'regtest',
|
||||
port: 53001,
|
||||
datadir: bitcoreDataDir,
|
||||
datadir: flocoreDataDir,
|
||||
services: [
|
||||
'p2p',
|
||||
'db',
|
||||
@ -64,7 +64,7 @@ var bitcore = {
|
||||
'transaction',
|
||||
'mempool',
|
||||
'web',
|
||||
'insight-api',
|
||||
'flosight-api',
|
||||
'fee',
|
||||
'timestamp'
|
||||
],
|
||||
@ -74,7 +74,7 @@ var bitcore = {
|
||||
{ 'ip': { 'v4': '127.0.0.1' }, port: 18444 }
|
||||
]
|
||||
},
|
||||
'insight-api': {
|
||||
'flosight-api': {
|
||||
'routePrefix': 'api'
|
||||
}
|
||||
}
|
||||
@ -85,9 +85,9 @@ var bitcore = {
|
||||
hostname: 'localhost',
|
||||
port: 53001,
|
||||
},
|
||||
opts: { cwd: bitcoreDataDir },
|
||||
datadir: bitcoreDataDir,
|
||||
exec: 'bitcored', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/bitcored
|
||||
opts: { cwd: flocoreDataDir },
|
||||
datadir: flocoreDataDir,
|
||||
exec: 'flocored', //if this isn't on your PATH, then provide the absolute path, e.g. /usr/local/bin/flocored
|
||||
args: ['start'],
|
||||
process: null
|
||||
};
|
||||
@ -97,7 +97,7 @@ var request = function(httpOpts, callback) {
|
||||
var request = http.request(httpOpts, function(res) {
|
||||
|
||||
if (res.statusCode !== 200 && res.statusCode !== 201) {
|
||||
return callback('Error from bitcore-node webserver: ' + res.statusCode);
|
||||
return callback('Error from flocore-node webserver: ' + res.statusCode);
|
||||
}
|
||||
|
||||
var resError;
|
||||
@ -162,20 +162,20 @@ var waitForBlocksGenerated = function(callback) {
|
||||
}, callback);
|
||||
};
|
||||
|
||||
var startBitcoind = function(count, callback) {
|
||||
var startFlorincoind = function(count, callback) {
|
||||
|
||||
var listenCount = 0;
|
||||
async.timesSeries(count, function(n, next) {
|
||||
|
||||
var datadir = bitcoinDataDirs.shift();
|
||||
var datadir = florincoinDataDirs.shift();
|
||||
|
||||
bitcoin.datadir = datadir;
|
||||
bitcoin.args.datadir = datadir;
|
||||
florincoin.datadir = datadir;
|
||||
florincoin.args.datadir = datadir;
|
||||
|
||||
if (listenCount++ > 0) {
|
||||
bitcoin.args.listen = 0;
|
||||
bitcoin.args.rpcport++;
|
||||
bitcoin.args.connect = '127.0.0.1';
|
||||
florincoin.args.listen = 0;
|
||||
florincoin.args.rpcport++;
|
||||
florincoin.args.connect = '127.0.0.1';
|
||||
}
|
||||
|
||||
rimraf(datadir, function(err) {
|
||||
@ -190,15 +190,15 @@ var startBitcoind = function(count, callback) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
var args = bitcoin.args;
|
||||
var args = florincoin.args;
|
||||
var argList = Object.keys(args).map(function(key) {
|
||||
return '-' + key + '=' + args[key];
|
||||
});
|
||||
|
||||
var bitcoinProcess = spawn(bitcoin.exec, argList, bitcoin.opts);
|
||||
bitcoin.processes.push(bitcoinProcess);
|
||||
var florincoinProcess = spawn(florincoin.exec, argList, florincoin.opts);
|
||||
florincoin.processes.push(florincoinProcess);
|
||||
|
||||
bitcoinProcess.stdout.on('data', function(data) {
|
||||
florincoinProcess.stdout.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stdout.write(data.toString());
|
||||
@ -206,7 +206,7 @@ var startBitcoind = function(count, callback) {
|
||||
|
||||
});
|
||||
|
||||
bitcoinProcess.stderr.on('data', function(data) {
|
||||
florincoinProcess.stderr.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stderr.write(data.toString());
|
||||
@ -225,11 +225,11 @@ var startBitcoind = function(count, callback) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var pids = bitcoin.processes.map(function(process) {
|
||||
var pids = florincoin.processes.map(function(process) {
|
||||
return process.pid;
|
||||
});
|
||||
|
||||
console.log(count + ' bitcoind\'s started at pid(s): ' + pids);
|
||||
console.log(count + ' florincoind\'s started at pid(s): ' + pids);
|
||||
|
||||
async.retry({ interval: 1000, times: 1000 }, function(next) {
|
||||
rpc1.getInfo(function(err, res) {
|
||||
@ -247,16 +247,16 @@ var startBitcoind = function(count, callback) {
|
||||
};
|
||||
|
||||
|
||||
var shutdownBitcoind = function(callback) {
|
||||
bitcoin.processes.forEach(function(process) {
|
||||
var shutdownFlorincoind = function(callback) {
|
||||
florincoin.processes.forEach(function(process) {
|
||||
process.kill();
|
||||
});
|
||||
setTimeout(callback, 3000);
|
||||
};
|
||||
|
||||
var shutdownBitcore = function(callback) {
|
||||
if (bitcore.process) {
|
||||
bitcore.process.kill();
|
||||
var shutdownFlocore = function(callback) {
|
||||
if (flocore.process) {
|
||||
flocore.process.kill();
|
||||
}
|
||||
callback();
|
||||
};
|
||||
@ -265,10 +265,10 @@ var shutdownBitcore = function(callback) {
|
||||
var buildInitialChain = function(callback) {
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
console.log('checking to see if bitcoind\'s are connected to each other.');
|
||||
console.log('checking to see if florincoind\'s are connected to each other.');
|
||||
rpc1.getinfo(function(err, res) {
|
||||
if (err || res.result.connections !== 1) {
|
||||
next(err || new Error('bitcoind\'s not connected to each other.'));
|
||||
next(err || new Error('florincoind\'s not connected to each other.'));
|
||||
}
|
||||
next();
|
||||
});
|
||||
@ -339,33 +339,33 @@ var buildInitialChain = function(callback) {
|
||||
|
||||
};
|
||||
|
||||
var startBitcore = function(callback) {
|
||||
var startFlocore = function(callback) {
|
||||
|
||||
rimraf(bitcoreDataDir, function(err) {
|
||||
rimraf(flocoreDataDir, function(err) {
|
||||
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
mkdirp(bitcoreDataDir, function(err) {
|
||||
mkdirp(flocoreDataDir, function(err) {
|
||||
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
fs.writeFileSync(bitcore.configFile.file, JSON.stringify(bitcore.configFile.conf));
|
||||
fs.writeFileSync(flocore.configFile.file, JSON.stringify(flocore.configFile.conf));
|
||||
|
||||
var args = bitcore.args;
|
||||
bitcore.process = spawn(bitcore.exec, args, bitcore.opts);
|
||||
var args = flocore.args;
|
||||
flocore.process = spawn(flocore.exec, args, flocore.opts);
|
||||
|
||||
bitcore.process.stdout.on('data', function(data) {
|
||||
flocore.process.stdout.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stdout.write(data.toString());
|
||||
}
|
||||
|
||||
});
|
||||
bitcore.process.stderr.on('data', function(data) {
|
||||
flocore.process.stderr.on('data', function(data) {
|
||||
|
||||
if (debug) {
|
||||
process.stderr.write(data.toString());
|
||||
@ -389,13 +389,13 @@ describe('Transaction', function() {
|
||||
|
||||
async.series([
|
||||
function(next) {
|
||||
startBitcoind(2, next);
|
||||
startFlorincoind(2, next);
|
||||
},
|
||||
function(next) {
|
||||
buildInitialChain(next);
|
||||
},
|
||||
function(next) {
|
||||
startBitcore(next);
|
||||
startFlocore(next);
|
||||
}
|
||||
], function(err) {
|
||||
if (err) {
|
||||
@ -407,8 +407,8 @@ describe('Transaction', function() {
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
shutdownBitcore(function() {
|
||||
shutdownBitcoind(done);
|
||||
shutdownFlocore(function() {
|
||||
shutdownFlorincoind(done);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ var should = require('should');
|
||||
var sinon = require('sinon');
|
||||
var AddressController = require('../lib/addresses');
|
||||
var _ = require('lodash');
|
||||
var bitcore = require('bitcore-lib');
|
||||
var flocore = require('flocore-lib');
|
||||
var bcoin = require('bcoin');
|
||||
|
||||
var txinfos = {
|
||||
@ -243,11 +243,11 @@ describe('Addresses', function() {
|
||||
});
|
||||
|
||||
it('/balance', function(done) {
|
||||
var insight = 0;
|
||||
var flosight = 0;
|
||||
|
||||
var res = {
|
||||
jsonp: function(data) {
|
||||
should(data).eql(insight);
|
||||
should(data).eql(flosight);
|
||||
done();
|
||||
}
|
||||
};
|
||||
@ -255,11 +255,11 @@ describe('Addresses', function() {
|
||||
});
|
||||
|
||||
it('/totalReceived', function(done) {
|
||||
var insight = 2782729129;
|
||||
var flosight = 2782729129;
|
||||
|
||||
var res = {
|
||||
jsonp: function(data) {
|
||||
should(data).eql(insight);
|
||||
should(data).eql(flosight);
|
||||
done();
|
||||
}
|
||||
};
|
||||
@ -268,11 +268,11 @@ describe('Addresses', function() {
|
||||
});
|
||||
|
||||
it('/totalSent', function(done) {
|
||||
var insight = 2782729129;
|
||||
var flosight = 2782729129;
|
||||
|
||||
var res = {
|
||||
jsonp: function(data) {
|
||||
should(data).eql(insight);
|
||||
should(data).eql(flosight);
|
||||
done();
|
||||
}
|
||||
};
|
||||
@ -281,11 +281,11 @@ describe('Addresses', function() {
|
||||
});
|
||||
|
||||
it('/unconfirmedBalance', function(done) {
|
||||
var insight = 0;
|
||||
var flosight = 0;
|
||||
|
||||
var res = {
|
||||
jsonp: function(data) {
|
||||
should(data).eql(insight);
|
||||
should(data).eql(flosight);
|
||||
done();
|
||||
}
|
||||
};
|
||||
@ -296,7 +296,7 @@ describe('Addresses', function() {
|
||||
|
||||
describe('/addr/:addr/utxo', function() {
|
||||
it('should have correct data', function(done) {
|
||||
var insight = [
|
||||
var flosight = [
|
||||
{
|
||||
'address': 'mzkD4nmQ8ixqxySdBgsXTpgvAMK5iRZpNK',
|
||||
'txid': '63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73',
|
||||
@ -338,7 +338,7 @@ describe('Addresses', function() {
|
||||
var res = {
|
||||
jsonp: function(data) {
|
||||
var merged = _.merge(data, todos);
|
||||
should(merged).eql(insight);
|
||||
should(merged).eql(flosight);
|
||||
done();
|
||||
}
|
||||
};
|
||||
@ -351,7 +351,7 @@ describe('Addresses', function() {
|
||||
|
||||
it('should have the correct data', function(done) {
|
||||
|
||||
var insight = [
|
||||
var flosight = [
|
||||
{
|
||||
'address': 'mzkD4nmQ8ixqxySdBgsXTpgvAMK5iRZpNK',
|
||||
'txid': '63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73',
|
||||
@ -406,7 +406,7 @@ describe('Addresses', function() {
|
||||
},
|
||||
end: function() {
|
||||
var finalObject = JSON.parse(finalData);
|
||||
finalObject.should.eql(insight);
|
||||
finalObject.should.eql(flosight);
|
||||
done();
|
||||
}
|
||||
};
|
||||
@ -419,7 +419,7 @@ describe('Addresses', function() {
|
||||
|
||||
it('should have correct data', function(done) {
|
||||
|
||||
var insight = {
|
||||
var flosight = {
|
||||
'totalItems': 1,
|
||||
'from': 0,
|
||||
'to': 1,
|
||||
@ -485,7 +485,7 @@ describe('Addresses', function() {
|
||||
|
||||
var res = {
|
||||
jsonp: function(data) {
|
||||
should(data).eql(insight);
|
||||
should(data).eql(flosight);
|
||||
done();
|
||||
}
|
||||
};
|
||||
@ -494,7 +494,7 @@ describe('Addresses', function() {
|
||||
});
|
||||
|
||||
it('should have trimmed data', function(done) {
|
||||
var insight = {
|
||||
var flosight = {
|
||||
'totalItems': 1,
|
||||
'from': 0,
|
||||
'to': 1,
|
||||
@ -556,7 +556,7 @@ describe('Addresses', function() {
|
||||
|
||||
var res = {
|
||||
jsonp: function(data) {
|
||||
should(data).eql(insight);
|
||||
should(data).eql(flosight);
|
||||
done();
|
||||
}
|
||||
};
|
||||
|
||||
@ -4,7 +4,7 @@ var should = require('should');
|
||||
var sinon = require('sinon');
|
||||
var AddressController = require('../lib/addresses');
|
||||
var _ = require('lodash');
|
||||
var bitcore = require('bitcore-lib');
|
||||
var flocore = require('flocore-lib');
|
||||
var bcoin = require('bcoin');
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ var utxos = [
|
||||
}
|
||||
];
|
||||
|
||||
describe('Addresses / Bitcoin Cash', function() {
|
||||
describe('Addresses / Florincoin Cash', function() {
|
||||
var summary = {
|
||||
addrStr: 'CcJ4qUfyQ8x5NwhAeCQkrBSWVeXxXghcNz',
|
||||
balance: 0,
|
||||
@ -77,7 +77,7 @@ describe('Addresses / Bitcoin Cash', function() {
|
||||
query: {}
|
||||
};
|
||||
it('checkAddrs', function(done) {
|
||||
var insight = 0;
|
||||
var flosight = 0;
|
||||
|
||||
var req = {
|
||||
query: {
|
||||
@ -106,7 +106,7 @@ describe('Addresses / Bitcoin Cash', function() {
|
||||
|
||||
describe('/addr/:addr/utxo', function() {
|
||||
it('should have correct data', function(done) {
|
||||
var insight = [
|
||||
var flosight = [
|
||||
{
|
||||
'address': 'CcJ4qUfyQ8x5NwhAeCQkrBSWVeXxXghcNz',
|
||||
'txid': '63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73',
|
||||
@ -148,7 +148,7 @@ describe('Addresses / Bitcoin Cash', function() {
|
||||
var res = {
|
||||
jsonp: function(data) {
|
||||
var merged = _.merge(data, todos);
|
||||
should(merged).eql(insight);
|
||||
should(merged).eql(flosight);
|
||||
done();
|
||||
}
|
||||
};
|
||||
@ -161,7 +161,7 @@ describe('Addresses / Bitcoin Cash', function() {
|
||||
|
||||
it('should have the correct data', function(done) {
|
||||
|
||||
var insight = [
|
||||
var flosight = [
|
||||
{
|
||||
'address': 'CcJ4qUfyQ8x5NwhAeCQkrBSWVeXxXghcNz',
|
||||
'txid': '63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73',
|
||||
@ -216,7 +216,7 @@ describe('Addresses / Bitcoin Cash', function() {
|
||||
},
|
||||
end: function() {
|
||||
var finalObject = JSON.parse(finalData);
|
||||
finalObject.should.eql(insight);
|
||||
finalObject.should.eql(flosight);
|
||||
done();
|
||||
}
|
||||
};
|
||||
@ -229,7 +229,7 @@ describe('Addresses / Bitcoin Cash', function() {
|
||||
|
||||
it('should have correct data', function(done) {
|
||||
|
||||
var insight = {
|
||||
var flosight = {
|
||||
'totalItems': 1,
|
||||
'from': 0,
|
||||
'to': 1,
|
||||
@ -295,7 +295,7 @@ describe('Addresses / Bitcoin Cash', function() {
|
||||
|
||||
var res = {
|
||||
jsonp: function(data) {
|
||||
should(data).eql(insight);
|
||||
should(data).eql(flosight);
|
||||
done();
|
||||
}
|
||||
};
|
||||
|
||||
@ -44,7 +44,7 @@ var blockIndexes = {
|
||||
|
||||
describe('Blocks', function() {
|
||||
describe('/blocks/:blockHash route', function() {
|
||||
var insight = {
|
||||
var flosight = {
|
||||
'hash': '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7',
|
||||
'confirmations': 119,
|
||||
'size': 1011,
|
||||
@ -97,7 +97,7 @@ describe('Blocks', function() {
|
||||
var next = function() {
|
||||
should.exist(req.block);
|
||||
var block = req.block;
|
||||
should(block).eql(insight);
|
||||
should(block).eql(flosight);
|
||||
done();
|
||||
};
|
||||
controller.block(req, res, next);
|
||||
@ -149,7 +149,7 @@ describe('Blocks', function() {
|
||||
it('should have correct data', function(done) {
|
||||
var blocks = new BlockController({node: node});
|
||||
|
||||
var insight = {
|
||||
var flosight = {
|
||||
'blockHash': '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7'
|
||||
};
|
||||
|
||||
@ -162,7 +162,7 @@ describe('Blocks', function() {
|
||||
};
|
||||
var res = {
|
||||
jsonp: function(data) {
|
||||
should(data).eql(insight);
|
||||
should(data).eql(flosight);
|
||||
done();
|
||||
}
|
||||
};
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
var should = require('should');
|
||||
var sinon = require('sinon');
|
||||
var InsightAPI = require('../lib/index');
|
||||
var FlosightAPI = require('../lib/index');
|
||||
|
||||
describe('Index', function() {
|
||||
describe('@constructor', function() {
|
||||
@ -11,7 +11,7 @@ describe('Index', function() {
|
||||
var node = { services: { block: {} },
|
||||
log: sinon.stub()
|
||||
};
|
||||
var index = new InsightAPI({
|
||||
var index = new FlosightAPI({
|
||||
rateLimiterOptions: options,
|
||||
node: node
|
||||
});
|
||||
@ -21,7 +21,7 @@ describe('Index', function() {
|
||||
var node = { services: { block: {} },
|
||||
log: sinon.stub()
|
||||
};
|
||||
var index = new InsightAPI({
|
||||
var index = new FlosightAPI({
|
||||
disableRateLimiter: true,
|
||||
node: node
|
||||
});
|
||||
@ -36,7 +36,7 @@ describe('Index', function() {
|
||||
var node = { services: { block: {} },
|
||||
log: sinon.stub()
|
||||
};
|
||||
var index = new InsightAPI({
|
||||
var index = new FlosightAPI({
|
||||
rateLimiterOptions: options,
|
||||
node: node
|
||||
});
|
||||
@ -49,7 +49,7 @@ describe('Index', function() {
|
||||
var node = { services: { block: {} },
|
||||
log: sinon.stub()
|
||||
};
|
||||
var index = new InsightAPI({
|
||||
var index = new FlosightAPI({
|
||||
enableCache: true,
|
||||
node: node
|
||||
});
|
||||
@ -71,7 +71,7 @@ describe('Index', function() {
|
||||
log: sinon.stub()
|
||||
};
|
||||
|
||||
var index = new InsightAPI({
|
||||
var index = new FlosightAPI({
|
||||
enableCache: false,
|
||||
node: node
|
||||
});
|
||||
@ -91,7 +91,7 @@ describe('Index', function() {
|
||||
var node = { services: { block: {} },
|
||||
log: sinon.stub()
|
||||
};
|
||||
var index = new InsightAPI({
|
||||
var index = new FlosightAPI({
|
||||
enableCache: true,
|
||||
cacheShortSeconds: 35,
|
||||
node: node
|
||||
@ -112,7 +112,7 @@ describe('Index', function() {
|
||||
var node = { services: { block: {} },
|
||||
log: sinon.stub()
|
||||
};
|
||||
var index = new InsightAPI({
|
||||
var index = new FlosightAPI({
|
||||
enableCache: true,
|
||||
node: node
|
||||
});
|
||||
@ -134,7 +134,7 @@ describe('Index', function() {
|
||||
var node = { services: { block: {} },
|
||||
log: sinon.stub()
|
||||
};
|
||||
var index = new InsightAPI({
|
||||
var index = new FlosightAPI({
|
||||
enableCache: true,
|
||||
cacheLongSeconds: 86400000,
|
||||
node: node
|
||||
@ -156,7 +156,7 @@ describe('Index', function() {
|
||||
var node = { services: { block: {} },
|
||||
log: sinon.stub()
|
||||
};
|
||||
var index = new InsightAPI({
|
||||
var index = new FlosightAPI({
|
||||
enableCache: true,
|
||||
node: node
|
||||
});
|
||||
@ -176,7 +176,7 @@ describe('Index', function() {
|
||||
describe('#setupRoutes', function() {
|
||||
it('will use rate limiter by default', function() {
|
||||
var node = { services: { block: {} } };
|
||||
var index = new InsightAPI({
|
||||
var index = new FlosightAPI({
|
||||
node: node
|
||||
});
|
||||
var middlewareFunc = sinon.stub();
|
||||
@ -199,7 +199,7 @@ describe('Index', function() {
|
||||
});
|
||||
it('will NOT use rate limiter if disabled', function() {
|
||||
var node = { services: { block: {} } };
|
||||
var index = new InsightAPI({
|
||||
var index = new FlosightAPI({
|
||||
node: node,
|
||||
disableRateLimiter: true
|
||||
});
|
||||
|
||||
@ -3,12 +3,12 @@
|
||||
var should = require('should');
|
||||
var sinon = require('sinon');
|
||||
var MessagesController = require('../lib/messages');
|
||||
var bitcore = require('bitcore-lib');
|
||||
var flocore = require('flocore-lib');
|
||||
var _ = require('lodash');
|
||||
|
||||
describe('Messages', function() {
|
||||
|
||||
var privateKey = bitcore.PrivateKey.fromWIF('cQwApHAg8hw9AZuxiU4a7g9kFWdaemhPxVZXWiAKgJTx6dPP32fN');
|
||||
var privateKey = flocore.PrivateKey.fromWIF('cQwApHAg8hw9AZuxiU4a7g9kFWdaemhPxVZXWiAKgJTx6dPP32fN');
|
||||
var address = 'mswTKCE2tYSFvUNnNPBKZfeNmugYL1rZMx';
|
||||
var badAddress = 'mswTKCE2tYSFvUNnNPBKZfeNmuhYL1rZMm';
|
||||
var signature = 'IA4sIwhcLMPPsYtB8tN0PI+aQuwDyl+/4Ksa89llNSAeVaRdMyyIxpo1H5N3GHbPl9LQqZ7CvaokeQgsOkK9fn4=';
|
||||
|
||||
@ -130,7 +130,7 @@ describe('Status', function() {
|
||||
syncPercentage: 100,
|
||||
height: 500000,
|
||||
error: null,
|
||||
type: 'bitcore node'
|
||||
type: 'flocore node'
|
||||
};
|
||||
|
||||
var status = new StatusController(node);
|
||||
|
||||
@ -11,7 +11,7 @@ describe('Transactions', function() {
|
||||
|
||||
it('should have correct data', function(done) {
|
||||
|
||||
var insight = {
|
||||
var flosight = {
|
||||
'txid': 'eac9723230b8b632117ac3d75288d6f8eb81cf1ea553eb9fd42562d5f767d54a',
|
||||
'version': 1,
|
||||
'locktime': 0,
|
||||
@ -109,7 +109,7 @@ describe('Transactions', function() {
|
||||
|
||||
var res = {};
|
||||
var next = function() {
|
||||
should(req.transaction).eql(insight);
|
||||
should(req.transaction).eql(flosight);
|
||||
done();
|
||||
};
|
||||
|
||||
@ -165,7 +165,7 @@ describe('Transactions', function() {
|
||||
|
||||
var transactions = new TxController(node);
|
||||
|
||||
var insight = {
|
||||
var flosight = {
|
||||
'pagesTotal': 1,
|
||||
'txs': [
|
||||
{
|
||||
@ -216,7 +216,7 @@ describe('Transactions', function() {
|
||||
|
||||
var res = {
|
||||
jsonp: function(data) {
|
||||
should(data).eql(insight);
|
||||
should(data).eql(flosight);
|
||||
done();
|
||||
}
|
||||
};
|
||||
@ -251,7 +251,7 @@ describe('Transactions', function() {
|
||||
}
|
||||
};
|
||||
|
||||
var insight = {
|
||||
var flosight = {
|
||||
'pagesTotal': 1,
|
||||
'txs': [
|
||||
{
|
||||
@ -313,7 +313,7 @@ describe('Transactions', function() {
|
||||
|
||||
var res = {
|
||||
jsonp: function(data) {
|
||||
should(data).eql(insight);
|
||||
should(data).eql(flosight);
|
||||
done();
|
||||
}
|
||||
};
|
||||
@ -359,7 +359,7 @@ describe('Transactions', function() {
|
||||
describe('#transformInvTransaction', function() {
|
||||
|
||||
it('should give the correct data', function() {
|
||||
var insight = {
|
||||
var flosight = {
|
||||
'txid': 'a15a7c257af596704390d345ff3ea2eed4cd02ce8bfb8afb700bff82257e49fb',
|
||||
'valueOut': 0.02038504,
|
||||
'vout': [
|
||||
@ -384,11 +384,11 @@ describe('Transactions', function() {
|
||||
var transactions = new TxController(node);
|
||||
|
||||
var result = transactions.transformInvTransaction(tx);
|
||||
should(result).eql(insight);
|
||||
should(result).eql(flosight);
|
||||
});
|
||||
|
||||
it('will not include null values in vout array', function() {
|
||||
var insight = {
|
||||
var flosight = {
|
||||
'txid': '716d54157c31e52c820494c6c2b8af1b64352049f4dcc80632aa15742a7f82c4',
|
||||
'valueOut': 12.5002,
|
||||
'vout': [
|
||||
@ -410,7 +410,7 @@ describe('Transactions', function() {
|
||||
var transactions = new TxController(node);
|
||||
|
||||
var result = transactions.transformInvTransaction(tx);
|
||||
should(result).eql(insight);
|
||||
should(result).eql(flosight);
|
||||
});
|
||||
|
||||
it('should detect RBF txs', function() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user