Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Bitcoin Royale RPC Explorer
# Bitcoin Vault RPC Explorer

This is a fork of [BTC RPC Explorer](https://github.com/janoside/btc-rpc-explorer) with minor modifications to adapt it to Bitcoin Royale.
This is a fork of [BTC RPC Explorer](https://github.com/janoside/btc-rpc-explorer) with minor modifications to adapt it to Bitcoin Vault.

---

Simple, database-free Bitcoin Royale blockchain explorer, via RPC. Built with Node.js, express, bootstrap-v4.
Simple, database-free Bitcoin Vault blockchain explorer, via RPC. Built with Node.js, express, bootstrap-v4.

This tool is intended to be a simple, self-hosted explorer for the Bitcoin Royale blockchain, driven by RPC calls to your own broyaled node. This tool is easy to run but currently lacks features compared to database-backed explorers.
This tool is intended to be a simple, self-hosted explorer for the Bitcoin Vault blockchain, driven by RPC calls to your own bvaultd node. This tool is easy to run but currently lacks features compared to database-backed explorers.

Whatever reasons one might have for running a full node (trustlessness, technical curiosity, supporting the network, etc) it's helpful to appreciate the "fullness" of your node. With this explorer, you can not only explore the blockchain (in the traditional sense of the term "explorer"), but also explore the functional capabilities of your own node.

Live demo available at: [http://explorer.bitcoinroyale.org](http://explorer.bitcoinroyale.org)
Live demo available at: [http://explorer.bitcoinvault.global](http://explorer.bitcoinvault.global)

# Features

Expand All @@ -25,19 +25,19 @@ Live demo available at: [http://explorer.bitcoinroyale.org](http://explorer.bitc

# Getting started

The below instructions are geared toward BTCR, but can be adapted easily to other coins.
The below instructions are geared toward BTCV, but can be adapted easily to other coins.

## Prerequisites

1. Install and run a full, archiving [node](https://github.com/bitcoinroyale/bitcoinroyale/blob/master/INSTALL.md). Ensure that your bitcoin node has full transaction indexing enabled (`txindex=1`) and the RPC server enabled (`server=1`).
2. Synchronize your node with the Bitcoin Royale network.
1. Install and run a full, archiving [node](https://github.com/bitcoinvault/bitcoinvault/blob/master/INSTALL.md). Ensure that your bitcoin node has full transaction indexing enabled (`txindex=1`) and the RPC server enabled (`server=1`).
2. Synchronize your node with the Bitcoin Vault network.
3. "Recent" version of Node.js (8+ recommended).

## Instructions

```bash
apt-get install node npm
git clone https://github.com/bitcoinroyale/explorer
git clone https://github.com/bitcoinvault/explorer
cd explorer
npm install
./bin/cli.js
Expand All @@ -52,7 +52,7 @@ See [configuration](#configuration) for details.
### Configuration

Configuration options may be passed as environment variables
or by creating an env file at `~/.config/btcr-rpc-explorer.env`
or by creating an env file at `~/.config/btcv-rpc-explorer.env`
or at `.env` in the working directory.
See [.env-sample](.env-sample) for a list of the options and details for formatting `.env`.

Expand All @@ -69,15 +69,15 @@ BTCEXP_UI_SHOW_TOOLS_SUBHEADER=false
You may also pass options as CLI arguments, for example:

```bash
./bin/cli.js --port 8080 --bitcoind-port 18443 --bitcoind-cookie ~/.broyale/regtest/.cookie
./bin/cli.js --port 8080 --bitcoind-port 18443 --bitcoind-cookie ~/.bvault/regtest/.cookie
```

See `./bin/cli.js --help` for the full list of CLI options.

## Run via Docker

1. `docker build -t btcr-rpc-explorer .`
2. `docker run -p 3002:3002 -it btcr-rpc-explorer`
1. `docker build -t btcv-rpc-explorer .`
2. `docker run -p 3002:3002 -it btcv-rpc-explorer`

# Support

Expand Down
30 changes: 25 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var path = require('path');
var dotenv = require("dotenv");
var fs = require('fs');

var configPaths = [ path.join(os.homedir(), '.config', 'btcr-rpc-explorer.env'), path.join(process.cwd(), '.env') ];
var configPaths = [ path.join(os.homedir(), '.config', 'btcv-rpc-explorer.env'), path.join(process.cwd(), '.env') ];
configPaths.filter(fs.existsSync).forEach(path => {
console.log('Loading env file:', path);
dotenv.config({ path });
Expand Down Expand Up @@ -69,8 +69,8 @@ if (process.env.BTCEXP_BASIC_AUTH_PASSWORD) {
}

// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
//app.use(logger('dev'));
app.use(favicon(__dirname + '/public/favicon.png'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
Expand Down Expand Up @@ -118,7 +118,7 @@ function loadMiningPoolConfigs() {

function getSourcecodeProjectMetadata() {
var options = {
url: "https://api.github.com/repos/bitcoinroyale/explorer",
url: "https://api.github.com/repos/bitcoinvault/explorer",
headers: {
'User-Agent': 'request'
}
Expand Down Expand Up @@ -241,12 +241,32 @@ app.runOnStartup = function() {
setInterval(getSourcecodeProjectMetadata, 3600000);
}

if (global.exchangeRates == null) {
if (!global.exchangeRates) {
utils.refreshExchangeRates();
}

if (!global.totalCoinSupply) {
utils.refreshCoinSupply();
}

if (!global.totalWalletsNumber) {
utils.refreshWalletsNumber();
}

if (!global.txAvgVolume24h) {
utils.refreshTxVolume();
}

if (!global.miningPools) {
utils.refreshMiningPoolsData();
}

// refresh exchange rate periodically
setInterval(utils.refreshExchangeRates, 1800000);
setInterval(utils.refreshCoinSupply, 60000);
setInterval(utils.refreshWalletsNumber, 60000);
setInterval(utils.refreshTxVolume, 60000);
setInterval(utils.refreshMiningPoolsData, 60000);

utils.logMemoryUsage();
setInterval(utils.logMemoryUsage, 5000);
Expand Down
2 changes: 1 addition & 1 deletion app/api/electrumAddressApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function connectToServer(host, port, protocol) {
var defaultProtocol = port === 50001 ? 'tcp' : 'tls';

var electrumClient = new ElectrumClient(port, host, protocol || defaultProtocol);
electrumClient.initElectrum({client:"btcr-rpc-explorer-v1.1", version:"1.4"}).then(function(res) {
electrumClient.initElectrum({client:"btcv-rpc-explorer-v1.1", version:"1.4"}).then(function(res) {
debugLog("Connected to ElectrumX Server: " + host + ":" + port + ", versions: " + JSON.stringify(res));

electrumClients.push(electrumClient);
Expand Down
4 changes: 2 additions & 2 deletions app/coins.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ var btc = require("./coins/btc.js");
var ltc = require("./coins/ltc.js");

module.exports = {
"BTCR": btc,
"BTCV": btc,
"BTC": btc,
"LTC": ltc,

"coins":["BTCR", "BTC", "LTC"]
"coins":["BTCV", "BTC", "LTC"]
};
50 changes: 24 additions & 26 deletions app/coins/btc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ Decimal8 = Decimal.clone({ precision:8, rounding:8 });
var currencyUnits = [
{
type:"native",
name:"BTCR",
name:"BTCV",
multiplier:1,
default:true,
values:["", "btcr", "BTCR"],
values:["", "btcv", "BTCV"],
decimalPlaces:8
},
{
type:"native",
name:"mBTCR",
name:"mBTCV",
multiplier:1000,
values:["mbtcr"],
values:["mbtcv"],
decimalPlaces:5
},
{
Expand Down Expand Up @@ -50,22 +50,22 @@ var currencyUnits = [
];

module.exports = {
name:"Bitcoin Royale",
ticker:"BTCR",
name:"Bitcoin Vault",
ticker:"BTCV",
logoUrl:"/img/logo/btc.svg",
siteTitle:"Bitcoin Royale Explorer",
siteDescriptionHtml:"<b>BTCR Explorer</b> is <a href='https://github.com/bitcoinroyale/explorer). If you run your own [Bitcoin Royale Full Node](https://bitcoin.org/en/full-node), **BTCR Explorer** can easily run alongside it, communicating via RPC calls. See the project [ReadMe](https://github.com/bitcoinroyale/explorer) for a list of features and instructions for running.",
siteTitle:"Bitcoin Vault Explorer",
siteDescriptionHtml:"<b>BTCV Explorer</b> is <a href='https://github.com/bitcoinvault/explorer). If you run your own [Bitcoin Vault Full Node](https://bitcoin.org/en/full-node), **BTCV Explorer** can easily run alongside it, communicating via RPC calls. See the project [ReadMe](https://github.com/bitcoinvault/explorer) for a list of features and instructions for running.",
nodeTitle:"Bitcoin Full Node",
nodeUrl:"https://bitcoin.org/en/full-node",
demoSiteUrl: "http://explorer.bitcoinroyale.org",
demoSiteUrl: "http://explorer.bitcoinvault.global",
miningPoolsConfigUrls:[
"https://raw.githubusercontent.com/btccom/Blockchain-Known-Pools/master/pools.json",
"https://raw.githubusercontent.com/blockchain/Blockchain-Known-Pools/master/pools.json"
],
maxBlockWeight: 4000000,
targetBlockTimeSeconds: 600,
currencyUnits:currencyUnits,
currencyUnitsByName:{"BTCR":currencyUnits[0], "mBTCR":currencyUnits[1], "bits":currencyUnits[2], "sat":currencyUnits[3]},
currencyUnitsByName:{"BTCV":currencyUnits[0], "mBTCV":currencyUnits[1], "bits":currencyUnits[2], "sat":currencyUnits[3]},
baseCurrencyUnit:currencyUnits[3],
defaultCurrencyUnit:currencyUnits[0],
feeSatoshiPerByteBucketMaxima: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 50, 75, 100, 150],
Expand Down Expand Up @@ -226,25 +226,23 @@ module.exports = {
alertBodyHtml: "This is one of 2 'duplicate coinbase' transactions. An early bitcoin bug (fixed by <a href='https://github.com/bitcoin/bips/blob/master/bip-0030.mediawiki'>BIP30</a>) allowed identical coinbase transactions - a newer duplicate would overwrite older copies. This transaction was the coinbase transaction for <a href='/block-height/91812'>Block #91,812</a> and, ~3 hours later, <a href='/block-height/91842'>Block #91,842</a>. The 50 BTC claimed as the coinbase for block 91,812 were also overwritten and lost."
}
],
exchangeRateData:{
jsonUrl:"https://api.coindesk.com/v1/bpi/currentprice.json",
exchangeRateDataUSD:{
jsonUrl:"https://api.liquid.com/products/618",
responseBodySelectorFunction:function(responseBody) {
//console.log("Exchange Rate Response: " + JSON.stringify(responseBody));

var exchangedCurrencies = ["USD", "GBP", "EUR"];

if (responseBody.bpi) {
var exchangeRates = {};

for (var i = 0; i < exchangedCurrencies.length; i++) {
if (responseBody.bpi[exchangedCurrencies[i]]) {
exchangeRates[exchangedCurrencies[i].toLowerCase()] = responseBody.bpi[exchangedCurrencies[i]].rate_float;
}
}

return exchangeRates;
if (responseBody.last_traded_price) {
return responseBody.last_traded_price;
}
return null;
}
},
exchangeRateDataBTC:{
jsonUrl:"https://api.liquid.com/products/619",
responseBodySelectorFunction:function(responseBody) {
//console.log("Exchange Rate Response: " + JSON.stringify(responseBody));
if (responseBody.last_traded_price) {
return responseBody.last_traded_price;
}

return null;
}
},
Expand Down
7 changes: 6 additions & 1 deletion app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var url = require('url');
var coins = require("./coins.js");
var credentials = require("./credentials.js");

var currentCoin = process.env.BTCEXP_COIN || "BTC"; // BTC is the same as BTCR
var currentCoin = process.env.BTCEXP_COIN || "BTC"; // BTC is the same as BTCV

var rpcCred = credentials.rpc;

Expand Down Expand Up @@ -156,8 +156,13 @@ module.exports = {
{name:"Mempool Summary", url:"/mempool-summary", desc:"Detailed summary of the current mempool for this node.", fontawesome:"fas fa-clipboard-list"},
{name:"Unconfirmed Transactions", url:"/unconfirmed-tx", desc:"Browse unconfirmed/pending transactions.", fontawesome:"fas fa-unlock-alt"},

<<<<<<< HEAD
{name:"RPC Browser", url:"/rpc-browser", desc:"Browse the RPC functionality of this node. See docs and execute commands.", fontawesome:"fas fa-book"},
{name:"Hashrate distribution", url:"/mining-pools", desc:"Estimated hashrate of mining pools.", fontawesome:"fas fa-chart-pie"}
=======
{name:"Pool share chart", url:"/pool-share", desc:"The hashpower of top mining pools.", fontawesome:"fas fa-book"},
{name:"RPC Terminal", url:"/rpc-terminal", desc:"Directly execute RPCs against this node.", fontawesome:"fas fa-terminal"}
>>>>>>> dev
],

donations:{
Expand Down
35 changes: 35 additions & 0 deletions app/helpers/colorGenerator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function calculatePoint(i, intervalSize, colorRangeInfo) {
var {
colorStart,
colorEnd,
useEndAsStart
} = colorRangeInfo;
return (useEndAsStart ?
(colorEnd - (i * intervalSize)) :
(colorStart + (i * intervalSize)));
};

/**
* @description Must use an interpolated color scale, which has a range of [0, 1]
*/
function generateColors(dataLength, colorScale, colorRangeInfo) {
var {
colorStart,
colorEnd
} = colorRangeInfo;
var colorRange = colorEnd - colorStart;
var intervalSize = colorRange / dataLength;
var i, colorPoint;
var colorArray = [];

for (i = 0; i < dataLength; i++) {
colorPoint = calculatePoint(i, intervalSize, colorRangeInfo);
colorArray.push(colorScale(colorPoint));
}

return colorArray;
};

module.exports = {
generateColors
};
Loading