Pages:
Author

Topic: [Guide] Solo mine testnet bitcoins with bfgminer, Bitcoin Core, and a CPU/GPU - page 2. (Read 980 times)

hero member
Activity: 952
Merit: 938
I managed to compile it after spending some time to find the name of the dependency on my OS. bfgminer doesn't support Bech32 address, but otherwise i didn't experience other problem.

I do not run my computer 24/7, so let's see how much block i mined after 3-7 days.

Ah, yes, I mentioned it in the previous guide but forgot to mention it here again as bfgminer also expects a legacy address:

If you don't have a testnet btc address yet, note that Bitcoin Core now doesn't generate a wallet by default any more so you will need to create one. You can read about it in createwallet. Then you should be able to getnewaddress. Make sure to use the legacy format as that's what cgminer is expecting. You address should start with n or m.

Good luck hitting some blocks with a CPU/GPU!, it worked for me but it's noticeably less frequent than using an ASIC, even a tiny USB one like the Compac F.
legendary
Activity: 2856
Merit: 7410
Crypto Swap Exchange
I managed to compile it after spending some time to find the name of the dependency on my OS. bfgminer doesn't support Bech32 address, but otherwise i didn't experience other problem.

I do not run my computer 24/7, so let's see how much block i mined after 3-7 days.
hero member
Activity: 952
Merit: 938
Following my previous guide about how to solo mine testnet bitcoins with an ASIC and cgminer I'm now presenting a guide on how to do the same but without the need of an ASIC. That means that you'll be able to mine testnet bitcoins with any computer that has a CPU and/or a GPU.

This should work on pretty much any laptop or desktop, even those with the new M1 chips from Apple. Of course the faster the CPU/GPU, the better chances you'll have to hit some blocks.

You might be wondering how is this even possible. The answer is that the difficulty in testnet3 reverts to 1 after 20 minutes have passed with no one finding a block. A difficulty of 1 is so low that any CPU or GPU is capable of hitting a block. Note that this was the difficulty of Bitcoin in the beginning(2009). More details about this can be read here: https://bitcoin.stackexchange.com/questions/18554/how-can-i-find-the-real-difficulty-on-testnet

OK, so let's make it happen. First, you need to setup Bitcoin Core in the same way as with the other guide. Here's a copy of it for simplicity:

Step 1: Install and run Bitcoin Core

We're going to use the folder ~/bitcoin_testnet to save everything so that it's easy to remove once you're done and to keep things simple. You can of course use a different path if you want.

Inside ~/bitcoin_testnet create a folder called data:

Code:
mkdir -p ~/bitcoin_testnet/data

Download the Bitcoin Core for your platform into ~/bitcoin_testnet/ and extract it there.

Now let's prepare the configuration file. Create a text file named bitcoin_testnet.conf in ~/bitcoin_testnet/ and put these content in it:

Code:
testnet=1
txindex=1
server=1
[test]
rpcport=5000
rpcallowip=YOUR_MINER_IP
rpcuser=YOUR_RPC_USER
rpcpassword=YOUR_RPC_PASSWORD
rpcbind=0.0.0.0

The thing that you need to understand here is that you're setting up the Bitcoin node to run in testnet, and you're defining an RPC port(5000 in this case, can be anything), user and password, and whitelisting a specific IP to connect to your node(YOUR_MINER_IP). You'll need these details and your Bitcoin node IP later when connecting from bfgminer.

You can now start running your Bitcoin node by doing the following(make sure to change user to your actual user):

Code:
/home/user/bitcoin_testnet/bitcoin-23.0/bin/bitcoind -conf=/home/user/bitcoin_testnet/bitcoin_testnet.conf -datadir=/home/user/bitcoin_testnet/data

If you want, you can keep this running in the background with screen:

Code:
screen -dm -S bitcoin_testnet /home/user/bitcoin_testnet/bitcoin-23.0/bin/bitcoind -conf=/home/user/bitcoin_testnet/bitcoin_testnet.conf -datadir=/home/user/bitcoin_testnet/data

You can then see what's happening with:

Code:
screen -r bitcoin_testnet

To detach the screen, simply press Ctrl-A and then Ctrl-D. You'll be back in the console, and the command will continue running in the background.

Step 2: Install and run bfgminer

Since cgminer removed the CPU/GPU functionality a long time ago, we're going to use bfgminer. You need to compile it from source code to activate these features, so that's what we're going to do. First let's install some dependencies:

Code:
sudo apt-get install build-essential autoconf automake libtool pkg-config libcurl4-gnutls-dev libjansson-dev uthash-dev libncursesw5-dev libudev-dev libusb-1.0-0-dev libevent-dev libmicrohttpd-dev libhidapi-dev libsensors-dev

Now we're ready to get, configure, and make bfgminer with support for CPU and GPU mining. Also note that we need to update the git: sources to https: in the .gitmodules file, otherwise it won't work. I'm using sed here to do this, but you can of course do it manually if you prefer.

Code:
cd ~/bitcoin_testnet/
git clone https://github.com/luke-jr/bfgminer
cd bfgminer
sed -i 's/git:/https:/g' .gitmodules
./autogen.sh
./configure --enable-opencl --enable-cpumining
make

After it finished the build, you can now simply start mining your testnet bitcoins:

Code:
~/bitcoin_testnet/bfgminer/bfgminer -S opencl:auto -S cpu:auto -o http://YOUR_BITCOIN_CORE_IP:5000 -u YOUR_RPC_USER -p YOUR_RPC_PASSWORD --generate-to YOUR_TESTNET_BTC_ADDRESS --coinbase-sig "Whatever you want to write"

And that's it. Your computer should now be mining with the CPU and the GPU using OpenCL. Leave it overnight and you'll probably see some testnet bitcoins in your address.

Some questions you might have:

Q: Can I use only the GPU?

A: You can use one or the other instead of both by simply not adding it to the command (i.e. just use -S opencl:auto for GPU only or just use -S cpu:auto for CPU only).

Q: Why are there two(or more) pools in the dashboard?

A: If you are running another instance of Bitcoin Core in the local machine bfgminer will try to mine there as well. If you don't want that to happen, simply add --no-local-bitcoin to the command.

Q: Can I use a Raspberry Pi?

A: Actually yes, it should work with CPU mining, but extremely slow. You might get lucky though.
Pages:
Jump to: