BHD Mining Tutorial(Linux )

BHD 1
9 min readFeb 16, 2023

Install wallet

1. Download the Linux package from BHD official website and unpack all the files from the package. Copy the files manually to /usr/local/bin . Note: If you are not the root user, you will need to add prefix sudo to your copy command in order to enhance your privileges. As shown below:

2. Type btchd-miner — help will display basic instructions for the mining program which means the installation is success. You also can run btchd-qt to open the wallet with GUI interface. If you prefer to use your wallet with GUI interface, the following sections will show you how to config it as a mining node.

3. You also need to create configuration file config.json to config miner before mining. Please check the following sections to learn how to do it.

Run a VDF program

What is VDF program and why I should run it? New BHD consensus contains both Proof-of-Space and Proof-of-Time. Plots are required to generate Proof-of-Space, and the proof will be included to the new block. Proof-of-Time is also required to be included to the new block as well cause it enhances the security of the whole BitcoinHD block chain. Proof-of-Time is calculated by the program called VDF(Verifiable Delay Function). To obtain the Proof-of-Time, you should run the VDF program on your local computer from BitcoinHD node. BitcoinHD node will also send a P2P request to obtain the Proof-of-Time. When the proof is ready, the result will be sent back from the node who is running the VDF program. Because of the network latency, we are highly recommend you to run the VDF program on your local computer although the VDF program is not required for mining procedure. P2P network is not that stable to ensure that you can always obtain a valid proof. When the Proof-ofTime is not received, you will not be able to produce a new block even you have the best quality of Proof-of-Space.

Build your own VDF program

VDF program can be found from Chia network’s repository called chiavdf. You can visit the repository and find the compile instructions. Before you start the compiling procedure, please ensure the package gmp and boost-asio are both installed on your local computer also the linux compiler toolkits. The following command is used to produce VDF program.

After the execution of compiling ends, a program named vdf_client can be found from path chiavdf/src/

Download it from BHD official website If you don’t want to compile vdf_client by your own, BHD community is provided a compiled VDF program for you. Please find the package and download it from BHD official website. Unpack vdf_client to any path you like

Start wallet/node with VDF program Since vdf_client is ready, we now can start the wallet/node by adding two arguments: — timelord , — timelord-vdf_client . Here is an example:

Writing a mining configuration file Before you can start mining, you need to write a simple configuration file that specifies some basic information related to the mining process.

Initializing the configuration file We use btchd-miner to do mining-related work, and initialising an empty configuration file is one of its functions. You can also initialize the file without using it, by copying the written file into the directory where you normally start mining. We will need to specify the location of this file when we start the mining program later. Use the following command to initialise an empty configuration file: btchd-miner generate-config This file can be edited using any editor. For information on how to modify this file, please consult the in the next sub-section.

Filling in the configuration The configuration file format is Json text, named “config.json” by default, and an example is shown below. Your configuration file will also look similar to the one below. “testnet” When its value is true, testnet network is used. Otherwise the official network is used. not using “noproxy” When its value is true, a network proxy is not used to connect to the wallet. Keep this option at true if there is no special need for a proxy. BHD reward address “reward” This is your address for receiving mining rewards in the BHD network. Note that before you can use this address you need to ensure that you have bound it to the Farmer public key associated with your Chia’s Plot files. To learn how to do this, please refer to the section “Binding FarmerId”.

Chia wallet mnemonic “seed”

When you initialise the hard disk space, Chia will ask you for a private key, which consists of this string called “Seed”, which is a combination of words. We will need this private key to sign the block when we generate the BHD block to authenticate your identity. Please paste this “Seed” into this. This private key is only used for signing and is only stored locally and will not be uploaded to the BHD’s chain or network.

Plot file directory “plotPath” Here you need to specify your Plot file directory, this registration item is an array and you can simultaneously register multiple Plot file directories at the same time.

RPC connection to the local wallet “rpc” The RPC connection to the local wallet can be specified here if you are using a login user name and password. By default we use a “.cookie” file to authenticate the communication with the wallet, so here you only need to register the “host” entry.

8. Introduction of Basic Parameters

9. Node program “btchdd”

parameters

⦁ “-testnet”: start the node program of the testnet, without this parameter it means start the node program of the official network

⦁ “-server”: start an RPC server to receive other clients, including mining connections and commands from clients

⦁ “-timelord”: start proof-of-time

⦁ “-timelord-vdf_client”: when the “-timelord” parameter is specified, it is necessary to add this parameter to specify the path to “vdf_client

Note: The parameters related to timelord can only be run under Linux and you need to compile the chiavdf project. The “timelord” parameter is used to calculate and obtain the proof of time locally. For information on proof of time, you can refer to the section on VDF in the new BHD white paper. Also, as there is no Windows version of VDF calculations yet, a Linux operating system is required to run VDF. Since each time a block is mined, a PoT needs to be obtained for the current PoS, running VDF locally ensures that you receive the correct proof answer the first time. If you do not run the proof of time locally, then you need to send the proof request over the network to a node that can calculate the proof, and then send it back locally once the node has obtained the answer. We encourage nodes to run proof of time locally, as this is beneficial to the miners themselves and to the network as a whole.

10. Mining program “btchd-miner” The parameters of the mining program consist of two parts: the “main command” and the “command parameters”. The “main command” specifies the type of work to be done at the moment. The “command parameter” completes the parameters for the current operation.

List of commands

When executing a mining program, using the parameter “ — help” will display the help documentation. Below are some important commands

⦁ “mining”: start mining

⦁ “bind”: bind FarmerId

⦁ “deposit”: stake amounts

⦁ “withdraw”: withdraw the stake amounts

11. Binding FarmerId Before mining, you need to bind your BHD receiving reward address to the FarmerId. As you need to do a signature, you need to write the correct configuration file first and fill in your correct “Seed” and BHD reward address and then use the command below to do the binding.

⦁ “bind” is the main command

12. Querying the binding When the binding has been completed, the binding record can be queried via “bind — check”.

The information retrieved for the bound transaction includes: the transaction hash “txid”, “height”, the address of the mined block “address” and chia’s “farmer” public key. It also includes the validity “valid” and whether it is active or not.

13. Staking BHD Stake the BHD to the network for the full rewards of the block, using the following command: btchd-miner deposit — amount staking amounts — term [noterm, term1, term2, term3]

⦁ “deposit” is the main command

⦁ “ — amount”: specify the total amount of staking

⦁ “ — term”: specify the duration of the lock, where: “noterm” is the expiry date, “term1”,

“term2”, “term3” are different types of locking periods

After a successful stake, “btchd-miner” will display a hash value which is the “transaction hash”. Please save it for future use if you need to withdraw your staking or rebind your staking address

14. Transfer of staking

The BHD staked on the chain will not be fully retrieved within the agreed time period, but can be transferred to another miner’s address.

btchd-miner retarget — txid transaction hash — address

⦁ “retarget” is the main command

⦁ “ — txid”: specify the transaction hash that will be rebinded

⦁ “ — address”: specify the new address to be bound

To prevent frequent re-binding of a particular staking within a short period of time, there is a time interval for the binding operation. The number of blocks between this binding and the staking or the last binding must not be less than a set value. On the testnet 3, this value is 10, while on the official network it is around 7 weeks. A stake that has been rebinded can be rebinded again with the same command format as described above, which requires specifying the hash of the last rebinded transaction. In addition, only the owner of the staking can do the transfer.

15. Querying the staking

You can query the staking associated with the current account by using the command “deposit — check”. With this command you can find out the relevant txid and use it for the staking command. On the command line is displayed as a json text, as shown in the example below, you can see the transaction hash, amount, block height, type, etc.

The above is the result of a search on a test machine that yielded a total of four valid staking records, with the items respectively:

⦁ block height, the block in which the stake transaction is packaged

⦁ the type of stake, with point indicating an untransferred stake and retarget indicating a stake that has been transferred one or more times

⦁ transaction hash, which can be copied for staking transfers

⦁ miner address, the address of the block mined with the staking

⦁ the amount and type of staking, the total amount of this stake and the type of lock of the stake are: noterm — none, term1 — lock type 1, term2 — lock type 2, term3 — lock type 3

16. Quit staking

Once the lock-up period for the staking amount has been reached, miners can withdraw the staking amount. Use the following command:

btchd-miner withdraw — txid transaction hash

⦁ “withdraw” is the main command

⦁ “ — txid”: specify the “transaction hash”. This “transaction hash” will be displayed after the previous successful use of the “deposit” command.

17. Start mining

Starting the node program

The node program is the core of BitcoinHD and is used to download, verify and generate blocks. It also manages the local wallet, private keys, signs blocks, maintains the P2P network and other important work. To handle network transactions, including block downloads, verification and mining, the node program needs to be running at all times. To start the node program, use the command below:

btchdd -testnet -server

⦁ “-testnet”: indicates the node program that starts the testnet, or without this parameter starts the node program for the official network

⦁ “-server”: open RPC server for later communication with the mining program

Starting the mining program

When everything is ready, including the nodes having synchronised all the blocks, the mining program can be started. Use the following command to start: btchd-miner mining

⦁ “mining” is the main command

--

--

BHD 1

BHD1 Community is a spontaneously community organization officially certified by BHD1 foundation, which is committed to creating BHD 1ecological entrance.