API Help [FHMW]
Documentation on the API and other useful things about managing the platform.
Click here to read the API Documentation.
Cronjobs
All of the cronjob files are located in the /cron folder in the project root. They are visible on the Cronjobs page of the admin panel. You can force a cronjob to run from there, and see if the cron is currently running or when it was last running.
For details on how to set up a cronjob consult your hosting provider as it is beyond the scope of this script.
Adding new cronjobs
Create the PHP file in the cron folder e.g. /cron/newcron.php and add your custom code.
My cron is stuck in “Running now”
Each time a cron is run while it’s still running it will show a counter in brackets. When this reaches 10 the counter will reset and the cron will force itself to run again. This value can be set in the config.json file under cron_reset_count.
API Access Crontrol List
Access Control is used to restrict IP address access to each API key. For example if you host multiple sites and need to use multiple servers, you can put the server IP in each one to be most secure. Each API Key supports unlimited IPs in ACL list.
Adding an IP to the ACL
Access the database table api_keys and add the IPs separated by the | character to the field allowed_ips. By default it’s empty, which means no ACL and all IPs are allowed to perform commands. An example ACL configuration for the database looks like this: 1.2.3.4|5.4.3.2|65.87.221.194.
Compiling and running a Wallet Daemon
This guide was written in November 2019. At some point it’s going to become out of date and might no longer be accurate.
Getting a server
The first requirement is to get a server with enough space and power to store the coin’s blockchain. Bitcoin for example has an ever increasing blockchain and at present the recommended space is 250GB. SSD will make the wallet perform better than HDD. This wallet cannot be hosted on your local PC.
To get a good server head over to Hosting for BTC Blog for good Bitcoin servers and VPS deals.
Note This guide uses an Ubuntu 18.04 VPS. We recommend sticking to this for the simplicity of the guide. This guide does not cover how to configure and setup the VPS, how to use the VPS, or how to connect to the VPS.
Obtaining the source code for your coin
After your server is configured and setup, you need to obtain the source code for the wallet. In this case we will be using Bitcoin’s source code on Github. Most coins have a Github providing their source code and instructions on how to compile and install them.
Find the doc folder in the source code’s files list, then look for a file resembling the name build-unix.md. This contains the instructions on how to compile the wallet for Unix based systems like Ubuntu Linux.
Compile the wallet
Issue the command git clone https://github.com/bitcoin/bitcoin on the server’s terminal. This will download the source code to your server ready to compile.
Change into the Bitcoin project directory by issuing cd bitcoin. You can then run ls to see the content of the directory and make sure you are in the correct folder to begin compiling.
Open the build-unix.md and follow the build instructions. Different coins have slightly different build requirements, hence why the best way to build and compile is to read the document.
If you run into a build/compilation error
Compilation of code is not always flawless and depending on the server in use and the libraries and versions, you may come across any number of errors. We won’t be listing any of them here, and the best method to move forward is googling the error and finding someone else with the same compilation error, and reading what they did to resolve the issue.
After you have compiled the wallet you should have run the make install or sudo make install to install the wallet. This makes the command bitcoind and bitcoin-cli available. Do not run the command yet.
Configuring and securing the wallet
Create an account on the server dedicated to running the wallet. We will name the account bitcoin. Create the account with sudo adduser bitcoin and follow the instructions. Login to the account with su bitcoin.
We can now proceed to configure and secure the wallet’s RPC access. Make the configuration folder for Bitcoin by running mkdir ~/.bitcoin. Then edit the configuration file with nano ~/.bitcoin/bitcoin.conf.
Below is a template for configuration to enable RPC access in a secure way.
server=1
daemon=1
rpcuser=YOURRPCUSERNAMEHERE
rpcpassword=YOURRPCPASSWORDHERE
rpcallowip=127.0.0.1
rpcallowip=163.172.22.146
rpcport=YOURRPCPORTNUMBER
paytxfee=0.0006
mintxfee=0.00007
fallbackfee=0.0001
txconfirmtarget=30
Your webserver’s IP is 163.172.22.146 and has been filled in the above template. This allows RPC access from the webserver to the wallet while dissallowing access to any other IPs.
Running and testing the wallet
Run the wallet with bitcoind and if it’s successful you should see Bitcoin server starting. You can access the wallet from the server’s terminal by running bitcoin-cli -getinfo, which returns a JSON response with data about the wallet or an error.
You can now add the wallet under the Wallets section entering the basic details and the RPC details. Your wallet connection will be checked at the point of adding and if a successful connection is made your wallet will be successfully installed, running and configured.