Mining with Bitcoin Core
The Bitcoin Core wallet has built-in capabilities for mining; therefore, it is really easy to use the wallet to mine on your machine. The wallet will use your CPU to mine. As you might recall, mining is basically hashing of a candidate block over and over again until the result is smaller than the current difficulty threshold.
To mine with your CPU and Bitcoin Core, open up the wallet software:
Now click on the Help menu and select Debug Window.
Then click on the Console tab—the console will appear. Remember, to see a list of all available commands, type
help
and press Enter.
The command to mine with your wallet is setgenerate
. The syntax of the command is as follows:
setgenerate <true|false> <number of cores to be used>
To start mining with only 1 core, type setgenerate true 1
:
To make sure that your wallet is mining, you can go to your Task Manager in Windows, Activity Monitor in Mac OS, or System Monitor in Linux and see if one core is working at 100%.
As you can see, one core is always working at 100% capacity. You can try running setgenerate
with more than one core to verify that additional cores will be working at 100%. To stop the mining process, type in the following into the Bitcoin Core wallet console:
setgenerate false
To see additional information about the setgenerate
command or any other command in the Bitcoin Core software, you can type in help
followed by the command name. For example, typing in: help setgenerate
will give you the following output:
Note
In older Bitcoin Core clients, it was possible to see how fast your wallet was mining using the gethashespersec
command. Since wallet-mining is no longer popular, that command has been removed and is no longer available. It is worth noting that the gethashespersec
command is still available in some alt-coins wallets.
Since alt-coins are, for the most part, forks of Bitcoin, most of the discussion here regarding the Bitcoin Core wallet also translates to alt-coin wallets. So if you are really interested in seeing the number of hashes your CPU is generating, you can do that in an alt-coin wallet if you have one installed. If you do not have one, don't worry; we will show you another way to measure your CPU's hashing performance.
Note
Definition
An alt-coin is another type of cryptocurrency that was created by copying and modifying Bitcoin's code. The most popular alt-coins are Litecoin, Dogecoin, and Namecoin. For a list of the biggest (by market capitalization) cryptocurrencies see http://coinmarketcap.com/.
Mining software
The most popular software to mine with your CPU is called CPUMiner. You can find the source code on GitHub at https://github.com/pooler/cpuminer. Precompiled binaries can be downloaded from https://sourceforge.net/projects/cpuminer/files/.
Once you have downloaded and extracted the software, the next step is to configure it. The easiest way to mine is to sign up for a mining pool, then you connect to the pool with your mining software and you're done. There are literally hundreds of mining pools. We recommend that you pick a well known pool that has been in existence for a little while. For our purpose, we will use a multipool.
Note
A multipool is a pool that mines multiple coins, that is, it is not dedicated to one type of coin. These pools calculate which coin is the most profitable to mine and automatically switch your miner to mine that coin. We registered an account on a multipool with the URL: https://www.multipool.us for demonstration purposes.
The next step on any pool is to create a worker. A worker is simply a way to identify your hardware. If you are using two computers to mine, you would create two workers. Once you have your pool account and worker info set up on the pool, you are ready to start mining.
To see all the options of CPUMiner, do the following. In a terminal window, navigate to the directory from which you extracted CPUMiner; there is a file called minerd
. Run the following command ./minerd --help
which will result in the following output:
Let's start mining
To connect CPUMiner to a pool, you will need the following information:
The URL of your pool
The port number of the pool server
Your mining pool username
Your worker's name
Your worker's password
Once you have all this information, you can run CPUMiner with the following options:
./minerd --url <poolurl:port> --userpass <USERNAME.WORKER:PASSWORD> -a<algorithm>
As a concrete example, we will connect to the multipool, as shown:
./minerd --url stratum+tcp://us-west.multipool.us:9999 -a sha256d --userpass bit.miner:x
If you have connected to your pool successfully, your screen will look similar to the following screen:
You can see that our 4-core CPU can do about 5400 kilohashes per second (KH/s) on each core. In total, that is roughly 21000 KH/s or 21 megahashes per second (MH/s), 0.021 gigahashes per second (GH/s), or 0.000021 terahashes per second (TH/s). As you can imagine, that is a very small amount when compared to the total Bitcoin network hashing power. Currently, (at block # 391770) the network hashing power is 955,300 TH/s. Solo mining Bitcoin with a CPU will statistically take a long time before a block can be solved; however, there is a chance that you can get lucky and solve a block.