Skip to content

Open-source mutlicoin block explorer. Regular Updates ~ Platform Independent ~ Mobile Friendly ~ Dark Theme ~ Supports Markets, Charts, Claiming Addresses, Public API's, Custom RPC Cmds, Bitcoin, Dogecoin, Heavycoin, Raptoreum, Bitoreum, zk-SNARKs ~ List Masternodes, Network Peers, Top 100 Wallets

License

miningplanet/but-x

 
 

Repository files navigation

but-x

GitHub release (latest by date) GitHub Release Date GitHub last commit GitHub

Stable, secure and customizable multicoin open-source blockchain explorer with support for virtually any coin that implements the Bitcoin RPC API protocol. Take a look at the but-x' features first or see our Installation Guide to get started.


Support

but-x is open-source and comes without support. However. Contact us at Github or at the butkoin.com discord channel.

Samples

but-x is tested with these coins.

Contact us if you have a blockchain node and need an explorer. Or you just run a blockchain node and want to provide us with data for an explorer.

Table of Contents

System Overview

but-x is a multicoin backend system and comes with several APIs and a web UI.

Prerequisites

Hardware

The hardware system requirements depend on the data processed and stored and the type of deployment(s). For a single chain deployment, the following is considered as minimum requirements.

  • 2 CPU core or more
  • 4 GB or more of RAM
  • 20 GB disk space

Software

but-x is platform independent and requires:

  • Linux, MacOS or MS Windows
  • Node.js - min. v19.9.0, current dev and prod version is v20.9.0
  • MongoDB - v6.3.0 or newer
  • Reverse-Proxy Apache2 or Nginx (optional)

Features

  • Multicoin blockchain explorer
  • Supports various mining algorithms grouped by CPU, GPU or ASIC
  • Rich JSON API
  • Exchange and other external data
  • External data synchronization
  • Individual blockchain functions
  • Frontend cache
  • Configurable and mobile-friendly web UI
  • i18n support
  • Dezentralized architecture
  • Distributed deployments
  • Platform independent

Features and functions in more detail

API Functions

but-x offers a rich set of API functions per blockchain (parameter {net}=chain), enriched with external data, such as coin or market data. See X API for comprehensive information.

Coin data by DB / cache API

  • api/getblockchaininfo/{net}: Returns coin stats incl. circulating supply or USD price.
  • api/getmininginfo/{net}: Returns mining related information and stats.
  • api/getdifficulty/{net}: Returns the current difficulty.
  • api/getconnectioncount/{net}: Returns the number of peers.
  • api/getblockcount/{net}: Returns the current tip.
  • api/getblockhash/{height}/{net}: Returns block hash for the height.
  • api/getblock/{net}: Returns information about the block with the given hash.
  • api/getrawtransaction/{txid}/{net} Returns TX information for the TX ID.
  • api/getnetworkhashps/{net}: Returns the current network hashrate(s).
  • api/getmasternodecount/{net}: Returns the number of masternodes.
  • api/verifymessage/{net}: Verifies the message signed with an address private key.
  • api/validateaddress/{address}/{net}: Validates the address.
  • api/getvotelist/{net}: Returns the current vote list.
  • api/getgovernanceinfo/{net}: Returns the current governance info including proposal fees, quorum sizes and more.

Extended data by DB / cache API

  • ext/getmoneysupply/{net}: Returns current money supply.
  • ext/getdistribution/{net}: Returns the wealth distribution and some stats.
  • ext/getaddress/{address}/{net}: Returns information for the given address.
  • ext/getaddresstxs/{address}/{net}/{start}/{length}: Returns TXs for a wallet address starting with an offset.
  • ext/gettx/{hash}/{net}: Returns information for given TX hash.
  • ext/getbalance/{address}/{net}: Returns current balance of the given address.
  • ext/getlasttxs/{net}/{min}/{length}/{start}/{type}: Returns a list of length of TXs with minimum amount and offset, optional by TX type.
  • ext/getcurrentprice/{net}: Returns last known exchange prices.
  • ext/getnetworkpeers/{net}: Returns the list of current network peers.
  • ext/getbasicstats/{net}: Returns basic coin stats including: block count, circulating supply, USD price, etc.
  • ext/getticker/{mode}/{net}: Returns various ticker data.
  • ext/getmarkets/{net}: Returns various market data.
  • ext/getsummary/{net}: Returns a summary including: (hybrid) difficulty, supply, hash rate, market prices, other coin and masternode stats.
  • ext/getmasternodelist/{net}: Returns the list of current masternodes in the network.
  • ext/getmasternoderewards/{net}: Returns a list of masternode reward TX after a block height for an address.
  • ext/getmasternoderewardstotal/{net}: Returns the total reward of a masternode after a block height for an address.

Net API

  • getallnet: Returns a list of the current chains this API instance supports.

Exchange data

but-x supports the following crypto currency exchanges.

Configurable Web UI

The web UI of but-x is highly configurable. Content and design can be defined individually for each blockchain.

Customizable pages

  • Home/X: Displays latest blockchain TX.

  • Smartnodes: Lists the current masternodes in the network.

  • Movement: Displays latest blockchain transactions that are greater than a certain configurable amount

  • Network: Displays a list of peers that have connected to the coind wallet in the past 24 hours, along with useful addnode data that can be used to connect your own wallets to the network easier

  • Top 100: Top 100 richest wallet addresses, top 100 wallet addresses received coins, top 100 TX and a pie chart breakdown of the wealth distribution.

  • Markets: Displays a number of exchange-related metrics including market summary, 24 hour chart, most recent buy/sell orders and latest trade history. The last known default exchange price is automatically converted to USD using the coingecko API. See Exchanges.

  • API: A listing of available public API's that can be used to retrieve information from the network without the need for a local wallet. See API functions.

  • Claim Address: Allows anyone to set custom display names for wallet addresses that they own using the Sign Message feature from their local wallet. Includes bad word filter support.

  • Block Info: Displays block detail information and the list of TX.

  • Transaction Info: Displays TX detail information for various TX types incl. protx and quorom TX.

  • Address Info: Wallet address summary (balance, total sent, total received, QR code) and latest TX.

  • Custom social links like twitter, facebook, instgram github, or others like coingecko, coinmarketcap or coinpaprika or any other external links.

Customizable panels

  • Customizable panels at the top of every page to display the following information:

    • Network: Displays the current network hash rate *only applicable to POW coins
    • Difficulty: Displays the current proof-of-work and/or proof-of-stake difficulty
    • Smartnodes: Displays a count of online and unreachable smartnodes *only applicable to smartnode coins
    • Coin Supply: Displays the current circulating coin supply value
    • Price: Displays the current market price (value measured using default market pair)
    • Market Cap: Displays the current market cap value in (value measured using default market pair)
    • Logo: Display an image of your coin logo
  • Configurable network charts that can independently be displayed at the top or bottom of any page. Supports individual mining algorithm configuration per blockchain.

    • Hashrate chart: Line graph listing the estimated network hashes per second.
    • Difficulty chart: Line graph listing the block difficulty.

Blockchain Specific Functionality

  • Support for Dash special TX and extra payloads as described in Dash Special Transactions.
  • Zcash/zk-SNARKs private TX support
  • Bitcoin P2PK transactions
    • Bitcoin RPC / API commands:
      • getdescriptorinfo: Accepts a descriptor as input and returns an object with more detailed information, including its computed checksum
      • deriveaddresses: Accepts an output descriptor as input and returns an array containing one or more P2PKH addresses
  • Heavycoin democratic voting and reward support
    • Reward Page: Displays reward/voting information
    • Heavycoin RPC / API commands:
      • getmaxmoney: Returns the number of coins that will be produced in total
      • getmaxvote: Returns the maximum allowed vote for the current phase of voting
      • getvote: Returns the current block reward vote setting
      • getphase: Returns the current voting phase name
      • getreward: Returns the current block reward
      • getsupply: Returns the current money supply
      • getnextrewardestimate: Returns an estimate for the next block reward based on the current state of decentralized voting
      • getnextrewardwhenstr: Returns a string describing how long until the votes are tallied and the next block reward is computed
    • Heavycoin public API's:
      • getmaxmoney: Returns the maximum possible money supply
      • getmaxvote: Returns the maximum allowed vote for the current phase of voting
      • getvote: Returns the current block reward vote setting
      • getphase: Returns the current voting phase
      • getreward: Returns the current block reward, which has been decided democratically in the previous round of block reward voting
      • getsupply: Returns the current money supply
      • getnextrewardestimate: Returns an estimate for the next block reward based on the current state of decentralized voting
      • getnextrewardwhenstr: Returns a string describing how long until the votes are tallied and the next block reward is computed.

Installation

Distributed Deployments

but-x is a multicoin explorer and requires a synchronized fully indexed node for each coin to enable full functionality. It supports distributed deployments to ensure scalability and reliability with low operating costs.

Instances or clusters can perform tasks for one or more coins in different roles such as X frontend or data synchronizer. Blockchain nodes, frontends, data synchronizers and databases can be operated on separate hosts. Frontends can be configured with individual caching options.

Quick Install Instructions

Pre-Install

The following prerequisites must be installed before using but-x:

  • Node.js (v19.9.0 or newer recommended)
  • MongoDB (v5.3.0 or newer recommended)
  • Git (v2.36.0 or newer recommended) if you do not download but-x in another way
  • A fully indexed and synchronized coind wallet daemon that supports the Bitcoin RPC API protocol. NOTE: In most cases, the blockchain must be synchronized with the addressindex, txindex, timestampindex, spentindex and futureindex option enabled to have access to all features. See the Wallet Settings section for more details.
Database Setup

Open the MongoDB cli:

mongo

Select database:

NOTE: {name} is the name of the user and database where you will be storing local but-x data.

You can change this to any name you want, but you must make sure that you set the same name in the settings.json file for the dbs[i].database setting.

use {name}

Now create a new user with read/write access. Collections and indexes are created or updated during startup or by the sync_chain.js script. Set your secure {password}.

db.createUser( { user: "{name}", pwd: "{password}", roles: [ "readWrite" ] } )
Download Source Code
git clone https://github.com/miningplanet/but-x
Install Node Modules
cd but-x && npm install --only=prod
Configure but-x Settings
cp ./settings.json.template ./settings.json

Make required changes in settings.json

NOTE: You can further customize the site by adding your own javascript code to the public/js/custom.js file and css rules to the public/css/{theme-name}.scss file. Adding changes to custom.js and {theme-name}.scss is the preferred method of customizing your site, without affecting the ability to receive but-x code updates in the future.


Start/Stop but-x

Start but-x (Use for Testing)

You can launch but-x in a terminal window that will output all warnings and error msgs with one of the following commands (be sure to run from within but-x directory):

npm start

or (useful for crontab):

cd /path/to/but-x && /path/to/npm run prestart && /path/to/node --stack-size=10000 ./bin/cluster

NOTE: mongod must be running to start but-x.

but-x defaults to cluster mode by forking an instance of its process to each cpu core, which results in increased performance and stability. Load balancing gets automatically taken care of and any instances that for some reason die, will be restarted automatically. If desired, a single instance can be launched with:

npm run start-instance

or (useful for crontab):

cd /path/to/but-x && /path/to/npm run prestart && /path/to/node --stack-size=10000 ./bin/cluster 1

Stop but-x (Use for Testing)

To stop but-x running with npm start you can end the process with the key combination CTRL+C in the terminal that is running but-x, or from another terminal you can use one of the following commands (be sure to run from within but-x directory):

npm stop

or (useful for crontab):

cd /path/to/but-x && /path/to/node ./scripts/stop_explorer.js

Start but-x Using PM2 (Recommended for Production)

PM2 is a process manager for Node.js applications with a built-in load balancer that allows you to always keep but-x alive and running even if it crashes. Once you have configured but-x to work properly in a production environment, it is recommended to use PM2 to start and stop but-x instead of npm start and npm stop to keep but-x constantly running without the need to always keep a terminal window open.

You can start but-x using PM2 with one of the following terminal commands (be sure to run from within the but-x directory):

npm run start-pm2

or (useful for crontab):

cd /path/to/but-x && /path/to/npm run prestart "pm2" && /path/to/pm2 start ./bin/instance -i 0 -n but-x -p "./tmp/pm2.pid" --node-args="--stack-size=10000"

NOTE: Use the following cmd to find the install path for PM2 (Linux only):

which pm2

Start but-x Using PM2 and Log Viewer

Alternatively, you can start but-x using PM2 and automatically open the log viewer which will allow for viewing all warnings and error msgs as they come up by using one of the following terminal commands (be sure to run from within the but-x directory):

npm run start-pm2-debug

or (useful for crontab):

cd /path/to/but-x && /path/to/npm run prestart "pm2" && /path/to/pm2 start ./bin/instance -i 0 -n but-x -p "./tmp/pm2.pid" --node-args="--stack-size=10000" && /path/to/pm2 logs

Stop but-x Using PM2 (Recommended for Production)

To stop but-x when it is running via PM2 you can use one of the following terminal commands (be sure to run from within the but-x directory):

npm run stop-pm2

or (useful for crontab):

cd /path/to/but-x && /path/to/pm2 stop but-x

Reload but-x Using PM2 (Recommended for Production)

but-x can be stopped and restarted in a single cmd when it is running via PM2, which is often necessary after updating but-x code for example. Use one of the following terminal commands to reload but-x (be sure to run from within the but-x directory):

NOTE: Assuming but-x has access to 2 or more cpus, this reload will be done in such a way that there will be zero-downtime while the restart is being performed. If you only have a single cpu then but-x will be inaccessible for a few seconds while the restart is being performed.

npm run reload-pm2

or (useful for crontab):

cd /path/to/but-x && /path/to/pm2 reload but-x

Syncing the Database with the Blockchain (or other Data)

sync_${database}.js (located in scripts/) is used to update the local or remote databases. This scripts must be called from the explorers root directory.

Usage: /path/to/node scripts/sync-_${database}.js [net] {other options..}

Notes:
- All scripts lock its execution based the database to be updated in ./tmp.
- Lockings are deactivated if the PIDs locked are obsolete.

It is recommended to do the initial syncing of your blockchain, markets, peers and masternodes using the manual commands below to ensure there are no sync issues. When you are sure that everything is syncing correctly, you should then install the necessary scripts to a crontab at 1+ minute intervals as indicated below

Commands for Manually Syncing Databases

A number of npm scripts are included with but-x for easy syncing of the various but-x databases. The following scripts are the main commands used for syncing but-x with your blockchain:

  • npm run sync-blocks: Connect to the wallet daemon to pull blocks/transactions into but-x, starting from genesis to current block. Repeat calls of this command will remember the last block downloaded, to allow continuous syncing of new blocks.
  • npm run sync-markets: Connect to the various exchange apis as defined in the settings.json file to provide market related data such as market summaries, orderbooks, trade history and charts.
  • npm run sync-peers: Connect to the wallet daemon and pull in data regarding connected nodes.
  • npm run sync-masternodes: Connect to the wallet daemon and pull in the list of active masternodes on the network. *only applicable to masternode coins

A small handful of useful scripts are also included to assist in solving various issues you may experience with but-x:

  • npm run check-blocks: Recheck all previously synced blocks by comparing against the wallet daemon to look for and add any missing transactions/addresses. Optional parameter: block number to start checking from. Example: npm run check-blocks 1000 will begin the check starting at block 1000. ⚠️ WARNING: This can take a very long time depending on the length of the blockchain and is generally not recommended unless absolutely necessary. Furthermore, while you are checking for missing data, you will be unable to sync new blocks into but-x until the check command has finished. If you do find missing transactions with this check (other than new data since last sync), this likely means that sync.update_timeout in settings.json is set too low.
  • npm run reindex: Delete all blocks, transactions and addresses, and resync from genesis to current block. ⚠️ WARNING: This will wipe out all blockchain-related data from but-x. It is recommended to backup the but-x database before continuing with this command.
  • npm run reindex-rich: Clears and recreates the richlist data for the top 100 coin holders page. Rarely needed, but can be useful for debugging or if you are certain the richlist data is incorrect for some reason.
  • npm run reindex-txcount: Recalculate the count of transactions stored in stats.txes by recounting the txes stored in the mongo database. Rarely needed, but can be useful for debugging or if you notice the main list of transactions is showing the wrong number of entries. If this value is off for some reason, you will not be able to page back to the 1st blocks on the main list of transactions for example.
  • npm run reindex-last: Lookup the last transaction in the mongo database and reset the stats.last value to that most recent block index. Rarely needed, but can be useful for debugging. The stats.last value is used to remember which block the last sync left off on to resume syncing from the next block.

Also see the Useful Scripts section for more helpful scripts.

Sample Crontab

Example crontab; update index every minute, market data every 2 minutes, peers and masternodes every 5 minutes

Easier crontab syntax using npm scripts, but may not work on some systems depending on permissions and how nodejs was installed:

*/1 * * * * cd /path/to/but-x && npm run sync-blocks [net] > /dev/null 2>&1
*/2 * * * * cd /path/to/but-x && npm run sync-markets [net] > /dev/null 2>&1
*/5 * * * * cd /path/to/but-x && npm run sync-peers [net] > /dev/null 2>&1
*/5 * * * * cd /path/to/but-x && npm run sync-masternodes [net] > /dev/null 2>&1
*/9 * * * * cd /path/to/but-x && npm run sync-richlist [net] > /dev/null 2>&1

Or, run the crontab by calling the sync script directly, which should work better in the event you have problems running the npm scripts from a crontab:

*/1 * * * * cd /path/to/but-x && /path/to/node scripts/sync_chain.js [net] > /dev/null 2>&1
*/2 * * * * cd /path/to/but-x && /path/to/node scripts/sync_markets.js [net] > /dev/null 2>&1
*/5 * * * * cd /path/to/but-x && /path/to/node scripts/sync_peers.js [net] > /dev/null 2>&1
*/5 * * * * cd /path/to/but-x && /path/to/node scripts/sync_masternodes.js [net] > /dev/null 2>&1
*/9 * * * * cd /path/to/but-x && /path/to/node scripts/sync_richlist.js [net] > /dev/null 2>&1

Wallet Settings

The wallet connected to but-x must be running with the following flags:

-txindex

You may either call your coins daemon using this syntax. Not all index options are available for all chains.

coind -txindex -addressindex -timestampindex -spentindex -futureindex

or else you can add the settings to your coins config file (recommended):

txindex=1
addressindex=1
timestampindex=1
spentindex=1
futureindex=1

Run Express Webserver on Port 80

A typical webserver binds to port 80 to serve webpages over the http protocol, but the Express webserver cannot do this by default unless it is given root permissions, which isn't recommended for security reasons. Instead, there are two recommended workarounds to achieve the same end result:

NOTE: Be sure to allow port 80 through any firewalls you may have configured or the but-x website may not be accessible remotely.

Use Setcap to Safely Grant User Permissions

NOTE: This option is only available to Linux users

  1. You can use the setcap command to change the capabilities of the node binary file to specifically allow the Express webserver to bind to a port less than 1024 (this one-time cmd requires root privileges):
sudo setcap cap_net_bind_service=+ep `readlink -f \`which node\``
  1. Open the settings.json file and change the webserver.port setting to a value of 80. Save the change and restart but-x.

You should now be able to browse to but-x by IP address or domain name without the need for specifying the 3001 port any longer.

Use Another Webserver as a Reverse Proxy

NOTE: The following instructions are for Linux users only, but installing and configuring another webserver should be possible on any OS

A few steps are involved in setting up another webserver that can bind to port 80 and 443 and forward all incoming traffic to but-x. Any commercial webserver can be used to create the reverse proxy, but in this case, Nginx will be used as an example:

  1. Install Nginx with the following terminal cmd:
sudo apt-get install nginx
  1. Remove the default configuration file:
sudo rm /etc/nginx/sites-enabled/default
  1. Create a new file in /etc/nginx/sites-available/ called node and open it with the nano text editor:
sudo nano /etc/nginx/sites-available/node
  1. Paste the following code in the file and make sure to change example.com to your domain or IP address, and change port 3001 on the proxy_pass line to the port # you have configured for the webserver.port setting in the settings.json file. When done editing, press CTRL+X, then Y (for yes to save) and then ENTER to finish saving the changes to the config file:
server {
    listen 80;
    server_name example.com;

    location / {
        proxy_set_header   X-Forwarded-For $remote_addr;
        proxy_set_header   Host $http_host;
        proxy_pass         "http://127.0.0.1:3001";
    }
}
  1. Create a new symbolic link for the Nginx configuration file that was just created and link it to the /etc/nginx/sites-enabled directory:
sudo ln -s /etc/nginx/sites-available/node /etc/nginx/sites-enabled/node
  1. Restart Nginx to apply the configuration changes:
sudo service nginx restart
  1. Nginx will now forward all incoming requests to but-x and after restarting but-x it should be browsable via http://example.com without the need for the http://example.com:3001 port any longer.

TLS/SSL Support

Similar to the problem with binding to port 80, a typical webserver binds to port 443 to serve webpages over the https protocol, but the Express webserver cannot do this by default unless it is given root permissions, which isn't recommended for security reasons. Instead, there are two recommended workarounds to achieve the same end result: Manually Link TLS/SSL Certificates to but-x or Use Nginx as a Reverse Proxy.

NOTE: Be sure to allow port 443 through any firewalls you may have configured or the but-x website may not be accessible remotely.

Prerequisites

NOTE: The following instructions are for Linux users only, but installing and configuring certbot should be possible on any OS

There are a few common steps that must be completed before TLS/SSL certificates can be generated:

  1. Install snapd:
sudo apt install snapd
  1. Ensure that snapd is up to date:
sudo snap install core; sudo snap refresh core
  1. Install certbot (full install instructions for different operating systems and configurations can be found here: https://certbot.eff.org/instructions):
sudo snap install --classic certbot
  1. Prepare the certbot command:
sudo ln -s /snap/bin/certbot /usr/bin/certbot

Manually Link TLS/SSL Certificates to but-x

NOTE: The following instructions are for Linux users only, but installing and configuring certbot should be possible on any OS

Follow the steps below to configure the Express webserver for use with TLS/SSL:

  1. If you haven't already done so, run the setcap cmd from the Use Setcap to Safely Grant User Permissions Instructions which will allow node.js to bind to port 443 without needing root permissions.

  2. There are different options for generating a valid TLS/SSL certificate, but in this case it is assumed that you do not have another webserver running on port 80 and therefore the standalone install method will be used. If you do have a webserver running, this cmd will fail unless you temporarily stop the webserver before continuing:

sudo certbot certonly --standalone

Certbot will ask a few simple questions and generate the necessary TLS/SSL certificate files for your domain. It will also install the necessary files to automatically renew the certificates when they are about to expire, so you shouldn't need to do anything special to keep them up to date.

  1. Once the TLS/SSL certificates are generated, you will need to grant permission to non-root users with the following commands:
sudo chmod -R 755 /etc/letsencrypt/live/
sudo chmod -R 755 /etc/letsencrypt/archive/
  1. The last step is to enable TLS in but-x' settings.json file and specify the paths to the 3 main certificate files that you just generated. Example:
  "webserver": {
    "port": 80,
    "tls": {
      "enabled": true,
      "port": 443,
      "cert_file": "/etc/letsencrypt/live/example.com/cert.pem",
      "chain_file": "/etc/letsencrypt/live/example.com/chain.pem",
      "key_file": "/etc/letsencrypt/live/example.com/privkey.pem"
    },
    "cors": {
      "enabled": false,
      "corsorigin": "*"
    }
  },

Ensure that webserver.tls.enabled = true and that you specify the exact path to the webserver.tls.cert_file, webserver.tls.chain_file and webserver.tls.key_file files by changing example.com to the domain name that you just generated TLS/SSL certificates for.

  1. If all went well, you should now be able to start up but-x and browse to it using a secure https connection like https://example.com.

Use Nginx as a Reverse Proxy

NOTE: The following instructions are for Linux users only, but installing and configuring certbot and nginx should be possible on any OS

  1. If you haven't already done so, first follow through the Use Another Webserver as a Reverse Proxy Instructions and then continue with step #2 below.

  2. Generate a new TLS/SSL certificate via certbot which will automatically edit your Nginx configuration files and enable https at the same time:

sudo certbot --nginx

Certbot will ask a few simple questions and generate the necessary TLS/SSL certificate files for your domain and link them to Nginx. It will also install the necessary files to automatically renew the certificates when they are about to expire, so you shouldn't need to do anything special to keep them up to date.

  1. If all went well, you should now be able to start up but-x and browse to it using a secure https connection like https://example.com.

CORS Support

but-x has basic CORS support which is useful to prevent other sites from consuming public APIs while still allowing specific websites whitelisted access.

What is CORS?

CORS description taken from MaxCDN One

To prevent websites from tampering with each other, web browsers implement a security measure known as the same-origin policy. The same-origin policy lets resources (such as JavaScript) interact with resources from the same domain, but not with resources from a different domain. This provides security for the user by preventing abuse, such as running a script that reads the password field on a secure website.

In cases where cross-domain scripting is desired, CORS allows web developers to work around the same-origin policy. CORS adds HTTP headers which instruct web browsers on how to use and manage cross-domain content. The browser then allows or denies access to the content based on its security configuration.

How to Benefit From Using CORS?

You must first set up CORS in but-x by editing the settings.json file and setting the value for webserver.cors.enabled to true.

  "webserver": {
    "cors": {
      "enabled": true,

The webserver.cors.corsorigin setting defaults to "*" which allows all requests from any origin. Keeping this setting at "*" can lead to abuse and is not recommended. Therefore, you should change the webserver.cors.corsorigin setting to an external origin that you control, as seen in the following example:

  "webserver": {
    "cors": {
      "enabled": true,
      "corsorigin": "http://example.com"

The above example would allow sharing of resources from but-x for all data requests coming from the example.com domain, while all requests coming from any other domain would be rejected as per normal.

Below is an example of a simple javascript call using jQuery that could be used on your example.com website to return the current block count from but-x:

jQuery(document).ready(function($) {
  $.ajax({
    type: "GET",
    url: "http://your-but-x-url/api/getblockcount",
    cache: false
  }).done(function (data) {
    alert(data);
  });
});

Useful Scripts

Update but-x Script

Automatically download and install the newest but-x source code, update out-of-date dependencies and reload but-x with a single command. This update script can be safely run while but-x is actively running to prevent needing to manually shut down to do updates, but please note that the website may be inaccessible for a few seconds or more while but-x is being updated.

NOTE: Only but-x installations that were installed via cloning the source from git can be automatically updated. Be sure to follow the Quick Install Instructions to set up but-x for optimal use with this update script.

Update but-x with the following command:

npm run update-but-x

or (useful for crontab):

cd /path/to/but-x && /path/to/node ./scripts/update_explorer.js

NOTE: The update script also supports a couple optional parameters.

Use the following command if you want to update but-x code only, without checking for out-of-date dependencies:

npm run update-but-x "but-x-only"

or (useful for crontab):

cd /path/to/but-x && /path/to/node ./scripts/update_explorer.js "but-x-only"

Use the following command if you want to upgrade outdated dependencies only, without checking for but-x code updates:

npm run update-but-x "dependencies-only"

or (useful for crontab):

cd /path/to/but-x && /path/to/node ./scripts/update_explorer.js "dependencies-only"

Backup Database Script

Make a complete backup of a but-x mongo database and save to compressed file. A built-in locking mechanism prevents data from being updated or changed while a backup is in process. Backups can be safely created while but-x is actively running and/or while but-x is turned off. The following backup scenarios are supported:

Backup Database (No filename specified)

npm run create-backup: Backs up to the but-x/backups directory by default with the current date as the filename in the format yyyy-MMM-dd.bak

Backup Database (Partial filename specified)

npm run create-backup test: Backs up the the but-x/backups directory by default with the filename test.bak

Backup Database (Full filename specified)

npm run create-backup today.bak: Backs up the the but-x/backups directory by default with the filename today.bak

Backup Database (Full path with partial filename specified)

npm run create-backup /usr/local/bin/abc: Backs up the the /usr/local/bin directory with the filename abc.bak

Backup Database (Full path and filename specified)

npm run create-backup ~/new.bak: Backs up the the users home directory with the filename new.bak

Restore Database Script

Restore a previously saved but-x mongo database backup. ⚠️ WARNING: This will completely overwrite your existing but-x mongo database, so be sure to make a full backup before proceeding. A built-in locking mechanism prevents data from being updated or changed while a backup is being restored. Backups can be safely restored while but-x is actively running and/or while but-x is turned off.

NOTE: Older v1.x but-x database backups were compressed into tar.gz files. These older tar.gz backups can still be restored, but you must specifically add the .tar.gz suffix. Example: npm run restore-backup /path/to/old_backup.tar.gz

The following restore scenarios are supported:

Restore Database (Partial filename specified)

npm run restore-backup old: Restores the but-x/scripts/backups/old.bak file

Restore Database (Full filename specified)

npm run restore-backup working.bak: Restores the but-x/scripts/backups/working.bak file

Restore Database (Full path with partial filename specified)

npm run restore-backup /home/but-x/backup: Restores the /home/but-x/backup.bak file

Restore Database (Full path and filename specified)

npm run restore-backup ~/archive.bak: Restores the ~/archive.bak file

Delete Database Script

Wipe the but-x mongo database clean to start again from scratch. ⚠️ WARNING: This will completely destroy all data in your existing but-x mongo database, so be sure to make a full backup before proceeding. A built-in locking mechanism prevents data from being updated or changed while the database is being deleted. The process to delete the database can be executed while but-x is actively running and/or while but-x is turned off.

Delete the mongo database with the following command:

npm run delete-database


Trouble shooting

exceeding stack size

RangeError: Maximum call stack size exceeded

Nodes default stack size may be too small to index addresses with many tx's. If you experience the above error while running sync.js the stack size needs to be increased.

To determine the default setting run:

node --v8-options | grep -B0 -A1 stack-size

To run a sync with a larger stack size launch with:

node --stack-size=[SIZE] scripts/sync.js index update

Where [SIZE] is an integer higher than the default.

note: SIZE will depend on which blockchain you are using, you may need to play around a bit to find an optimal setting

Error: bind EACCES ...

This error can appear when you try to run but-x on a port number lower than 1024. There are a couple solutions to this problem which are explained in more detail in the Run Express Webserver on Port 80 section.

Donations / Support Us

If you enjoy our work, please consider supporting our continued development of this project which you can find on our github page.

Please consider supporting us with a small donation by sending us some cryptocurrency:

We also encourage submitting quality pull requests from developers to further improve but-eiquius.

Special Thanks

License

Copyright (c) 2023-2024, https://butkoin.com by miningplanet (mining@planet.ms)
Copyright (c) 2019-2022, The Exor Community
Copyright (c) 2017, The Chaincoin Community
Copyright (c) 2015, Iquidus Technology
Copyright (c) 2015, Luke Williams
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of Iquidus Technology nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

Disclaimer

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

About

Open-source mutlicoin block explorer. Regular Updates ~ Platform Independent ~ Mobile Friendly ~ Dark Theme ~ Supports Markets, Charts, Claiming Addresses, Public API's, Custom RPC Cmds, Bitcoin, Dogecoin, Heavycoin, Raptoreum, Bitoreum, zk-SNARKs ~ List Masternodes, Network Peers, Top 100 Wallets

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 59.2%
  • Pug 31.6%
  • SCSS 9.2%