Bitcoin Cash (BCH) Node for CAS

Contents updated for v.20

This is a step-by-step guide for adding a Bitcoin Cash (BitcoinABC) node as a Hot Wallet Buy source. This guide was created based on version 0.16.2 of the BitcoinABC node software. This is only an example and not to be construed as an endorsement for any particular exchange or wallet.

BitcoinABC  runs as a daemon on your VPS (bitcoind), controlled by a simple command interface (bitcoin-cli). Understand that this is not the same as accessing a Bitcoin Cash node run by someone else. This guide is for installing and operating your own node on your own server with CAS.

The following guide is written with instructions to be executed as root. This is discouraged, but simplicity is the goal in mind - not security. You should modify these procedures to safeguard your assets as needed. You will be a target for hackers, and your Bitcoin Cash will be at risk. You are strongly encouraged to implement any and all restrictions available to you to protect your server from unauthorized access. These enhancements however, are beyond the scope of this guide.

Before you begin:

The following example is based on the presumptions:

  • you have a remote server running Ubuntu 16.04 LTS,

  • you have sudo access to that server,

  • you have completed the prior steps of CAS installation on your server, and

  • the server is online.

According to Bitcoin.org, a node requires at least:

  • 200 GB free disk space,

  • 2 GB of memory (RAM), and

  • 200 gigabytes monthly bandwidth.

Bitcoin Cash and Bitcoin Core use some of the same binaries. This means you may run into problems running both on the same server. Running both on the same CAS server is outside the scope of our supported configurations at this time. It is possible to do it, but this guide isn't intended to accomplish that end. Please submit a request to General Bytes' support if this is a critically important feature for you, and we'll try to accommodate your needs when resources permit. In the meantime, if you wish to run both, you need to choose which one will “listen” to the network on port 8333 and make the other one “deaf” on your server by adding “listen=0” to your config file.

The bitcoind documentation further suggests you allow several days for the block chain to completely download! In our testing, it took over 24 hours.

Download and install the components:

First, open a terminal window and login as root. 

  • Alternately, sudo may be used, prepend “sudo” in the following CLI instructions as necessary. 

Add PPA installation functions to your server:

apt-get install software-properties-common
  • It may already be installed. If so, great. No worries.

Download and install the Bitcoin Cash daemon on your server:

add-apt-repository ppa:bitcoin-abc/ppa
  • The following lines should result:

Bitcoin ABC More info: https://launchpad.net/~bitcoin-abc/+archive/ubuntu/ppa Press [ENTER] to continue or ctrl-c to cancel adding it
  • press <Enter> to continue.

  • The following text (with some variations) will be displayed and you will be returned to the command line prompt. The keyword to look for is the “Ok” on the last line:

Now update Ubuntu and start the installation:

  • The binary will be installed in /usr/bin and installation should normally only take a few minutes. 

Create the data directory and extract the .conf file:

Create an RPC token for CAS to communicate with BitcoinABC:

RPC is a method of communication between two programs. In this case, the two programs are CAS and BitcoinABC. The RPC token is designed to eliminate the need for hard-coded passwords in the involved configuration and script files. You will receive a password here ONCE. This password is required for CAS; it's your “RPC Password”. You must save it, preferably in a secure note file or database.

First, ensure that python is installed on your server:

Download rpcauth.py on GitHub 

Modify the file permissions to allow the script to execute:

Finally, generate the token:

  • Save the name you entered above, the resulting token, AND the generated password. You'll need it in the next step. 

  • The “AnyNameYouWantHere” is the “RPC User”, and 

  • the generated password is your “RPC Password”.

Modify the bitcoin.conf configuration file:

While you might (under certain circumstances) might want to start the daemon exclusively from a command line, we urge you to modify the following settings within bitcoin.conf and run bitcoind without parameters. Keep it simple!

Open the bitcoin.conf file:

Change or add the following settings:

  • Replace the “rpcauth” info with the token generated in the previous step.

  • THE "rpcauth=..." IS ALL ONE LINE! (It won't fit properly on this web page.)

  • Save the file with Ctrl-X, accept the defaults, and press <Enter>.

Start the BitcoinABC node:

From Bitcoin.org: “When Bitcoin Core daemon first starts, it will begin to download the block chain. This step will take at least several days, and it may take much more time on a slow Internet connection or with a slow computer. During the download, Bitcoin Core will use a significant part of your connection bandwidth.”

Type:

  • It may take several minutes for Bitcoin Cash to completely start.

You can interrupt Bitcoin Cash at any time using the following command:

  • It will resume downloading from the point where it stopped the next time you start it.

  • It may take a few minutes to completely shut down.

You will eventually want bitcoind to start automatically when the server boots. You should ensure everything works before you do this, though. To have bitcoind automatically startup at boot time, type:

  • Select “nano” (if given a choice of editors), and add the following to the end of the file:

  • Save (using the defaults) and exit (using “nano”: ctrl-x).

You may also need to configure your firewall to allow inbound connections to port 8333.

See: Configuring Server Firewalls

Now assemble the required information for CAS:

  • User: this is the “RPC User” you created earlier. For this example we'll just say it's “rpcuser”.

  • Password: is the “RPC Password” created earlier.  For this example, we'll make the password “rpcpw”.

  • Accountname: this is the account name of your wallet. An “account” is neither required nor suggested. Account usage is deprecated in bitcoind, however to view any existing accounts, type:

  • On a newly installed server, the list is normally empty and may be safely ignored.

Next, add a new crypto-currency type to CAS:

  1. Enter the “Crypto Settings” menu in the left-hand column. 

  2. Click on the “+ ADD” button. 

  3. Create a suitable description, i.e. “Bitcoin Cash USD”.

  4. Select “BTC” for the required “Crypto Currency*” setting.

  5. Set Configuration Cash Currency* to “USD” (or whatever your local currency might be).

  6. Set “Buy Rate Source” to whatever source you prefer.

  7. Set “Minimum Cash Amount Per Transaction*” to zero – this enables any sale.

  8. Select your Hot Wallet Buy source to “BitcoinABC/BitcoinClassic Cash Core”.

  9. Enter the “Parameters” for the Hot Wallet Buy source as determined in the previous step.

  • Example: “http:rpcuser:rpcpw:127.0.0.1:8332”

  1. Click on “SUBMIT” to save your settings.

Finally, test it out:

 Select “Test Hot Wallet Buy” from the RUN BTC SETTINGS TEST.

  • Presuming everything was entered correctly, you should receive confirmation of success!

  • You should also now configure the “Hot Wallet Sell” if you implement it.

UNINSTALLING BITCOIND:

Uninstallation is essentially the reverse order of installation. The following procedures will also delete any unposted transactions and is completely irreversible. Any Bitcoin in your local wallet will be lost forever.

  • THIS WILL DELETE ALL PENDING TRANSACTIONS IN YOUR LOCAL WALLET!!

  • THIS PROCEDURE MAY RESULT IN PERMANENT DATA AND/OR COIN LOSS!!

Change your Crypto settings in CAS:.

  • In CAS, navigate to “Crypto Settings” and update all settings that involve Bitcoin Cash.

Login to your terminal as root (or sudo – depending on how you installed bitcoind to begin with).

Shut down the bitcoind daemon:

Remove any startup references in crontab:

Remove bitcoind from APT:

  • If you are prompted to cleanup other dependencies, type:

Remove the PPA reference within APT:

  • Press [Enter] to confirm PPA removal, and finally update the APT repository:

You may also need to configure your firewall to deny inbound connections to port 8333.

That's it.


 Bitcoin Cash (bitcoind) has been uninstalled from your server, however the data files are left behind. This final step deletes all traces of Bitcoin Cash on your server!!

By removing your .bitcoin directory, you are also removing your wallets/addresses and access to any BTC in those wallets. When you run bitcoind, it typically creates a hidden directory in the home directory of the running user. If you followed this guide, then it should be located in: /root/.bitcoin and this line will delete the entire directory (and wallet/transactions). This may take a few minutes:

To PERMANENTLY AND IRREVERSIBLY delete the /root/.bitcoin directory:

TROUBLESHOOTING BITCOIND:

The bitcoind daemon is demanding when implementing a full node. While discouraged by the Bitcoin community and General Bytes, you may elect to run a “pruning” node by inserting:

into the bitcoin.conf file. This will significantly reduce the resource demands of bitcoind. As of this writing, the blockchain is about 155gb, and is growing by about 5gb per month. You can find the current size here:

https://blockchain.info/charts/blocks-size

A pruning node as described above is a substantial security risk when operating a BATM. Per the Bitcoin wiki at: https://en.bitcoin.it/wiki/Full_node :

“Lightweight nodes are sometimes able to be temporarily tricked into accepting transactions or blocks that are not actually valid. This could cause serious financial damage, especially for websites that automatically process Bitcoin transactions. Full nodes provide the maximum security possible, and so they should be used by all businesses, and also by regular users whenever doing so is convenient.”

Additionally, you may discover that running a full node taxes your system dramatically. The following suggestions are offered to assist you in this regard. These pitfalls have nothing to do with CAS, and are offered merely as a courtesy to our valued customers. You are strongly encouraged to run a full node, run bitcoind from a script, and implement the bitcoin.conf file located in the bitcoind directory.

Excessive server CPU load:

  • Shut down any web server. Any unnecessary programs should be eliminated.

Use “cpulimit” to throttle bitcoind's CPU usage. Download cpulimit:

and then change the bitcoind startup line in your script as follows:

  • This will throttle bitcoind to use only 20% of the normal CPU load. You can modify this as you see fit, and periodic adjustment is suggested. After the blockchain has been initialized and the database is fully synced, the CPU load will drop. At that point, you may want to adjust it upwards. Your VPS may shut you down if you abuse their “acceptable use” policy.

  • The “-z” tells cpulimit to exit when bitcoind does, and “-b” sends it to the background.

Your exposure as a Bitcoin Cash node will draw some unwanted attention. You may become the victim of targeted attacks. Some suggested ways to mitigate this:

  • Change your SSH port – attempts to hack into your server become greatly reduced.

  • Implement fail2ban – it will reduce the effects of attacks against your server.

Excessive server memory usage:

Try reducing the number of heap arenas that bitcoind allocates by default. This should have an insignificant effect upon the program's performance, but may dramatically reduce your server's memory consumption. Add the following to your bitcoind startup script:

Copyright © 2020-2024 General Bytes USA LLC