Want to snag some testnet bitcoins? Solo mining is a solid way to do it. I’ve noticed that most guides floating around are pretty outdated, so I put together this one that works with the latest tools and gear.
Here’s what you’ll need:
- The latest Bitcoin Core version (v23.0 as of now)
- A special build of cgminer for solo mining, which you can find at https://github.com/cmmodtools/cgminer, plus a little tweak from this guide.
- Ideally, you'll want an ASIC miner. If you don’t have one, any miner compatible with cgminer will do, even the USB miner from GekkoScience, like the Compac F.
To keep it straightforward, I’m assuming you’ve got two machines: one for your Compac F miner and another for running Bitcoin Core. Doesn’t matter if they’re on the same computer or different ones.
Step 1: Get Bitcoin Core installed and running.
We’ll use the folder ~/bitcoin_testnet to keep everything organized, making it easy to delete later. Feel free to choose a different path if you prefer.
Inside ~/bitcoin_testnet, create a folder named data:
Download the Bitcoin Core for your operating system into ~/bitcoin_testnet/ and unpack it there.
Next up, let’s set up the config file. Create a text file called bitcoin_testnet.conf in ~/bitcoin_testnet/ and add these details:
The key thing to grasp here is that you’re configuring the Bitcoin node for testnet operation, specifying an RPC port (5000 in this instance, but it can be anything), as well as a username and password, plus whitelisting a specific IP to connect to your node (YOUR_MINER_IP). You’ll need these credentials and your Bitcoin n.
How to solo mine testnet bitcoins using cgminer, Bitcoin Core, and a Compac F
19 replies 475 views
A few blocks overnight? That means the testnet difficulty is extremely low. Exactly what was the testnet difficulty when you wrote this guide?
I'm sure this will help a bunch of people who are setting up testnet bitcoin mining farms.
The difficulty was in the millions:
But apparently testnet3 resets diff to 1 at some blocks, as those are the ones I hit:
Nicely detailed guide!
Thanks for writing this guide. Although people who currently don't have ASIC better use Signet or Regtest, unless they also want to try their luck with solo mining on Bitcoin mainnet.
Not at some blocks, but after 20 minutes since last block mined. That might be why you mine more block than @NotATether expected.
That's great to know! I wasn't aware of this rule. Will spin a Compac F up to mine some testnet BTC, then..
I've never hit a solo block, so this should be a pretty cool experience.
That was the motivation for me to do this in the first place
A couple of things you might want to do:
Keep the log of your first block:
And you can of course write something into the coinbase of the block you found, just add this option to the config file:
It's a simple text argument, the same as the btc-address argument you have to give in the config file. Just add another line with that.
Just try it out, that's the whole point of the testnet
I just posted a new guide that doesn't require an ASIC. It only uses the CPU and/or the GPU of a normal computer, so you should be able to test it.
A few recommendations and fixes:
(1) Just add datadir=/home/user/bitcoin_testnet/data to the conf file, as well. Then you won't have to specify it through CLI anymore.
(2) There is a typo here. It should be --enable-gekko; otherwise it will compile just fine, but without Gekko support and you won't even notice.
(3) Cgminer complains about the comma at the end of the last line ("failover-only" : true,); it has to be removed to work.
(4) For anyone unsure how to do this:
Nullama, your guide worked great (besides the few points I raised)! Amazing; I hadn't expected to mine multiple blocks per day.
In fact, I managed to grab almost 30 blocks in 24h. Sitting at roughly 0.9tBTC right now.
Even consecutive blocks a few times... I must have very good network latency or something. Only a single Compac F hashing at just under 300GH/s.
It was an awesome experience to solo-mine again (and hit blocks!) and I'll definitely do it again if I need testnet coins and / or for validating a miner / miner driver software.
PS: Check last 24h of blocks for hidden message!
What needs to be changed for this to work on main net? Remove testnet=1 ?
Interesting; I would have expected a CPU / GPU setup to work fine, too then. At difficulty 1, you need a fast network latency in my opinion, but also a block candidate immediately. In case the ASIC is 100x faster, that could play a bigger role than what I anticipated.
Again; I got consecutive blocks a few times, so I guess that a couple hundred GH suffice for consistent blocks rewards.
Yes It is also displayed by mempool.space.
Oddly enough; someone just sent me 0.00017893 tBTC, which was no coinbase transaction. Typo? Never happened on mainnet to me, in all these years.
I mined:
Block 2411861, Block 2411862 and Block 2411863 in a row.
Glad to see people now solo mining testnet bitcoins with this guide
That's 50,000 times faster than my CPU mining! Would you be interested to try? I still have a synced testnet blockchain running, and could give you access. At low difficulty, I wonder if I made a mistake for not getting anything in days.
It's a quad core Xeon E3-1270 V2 @ 3.50GHz. That's why I'm wondering if I did something wrong somewhere.
colddiamondHero Member
Posts: 623 · Reputation: 2467
#17Aug 14, 2021, 06:00 AM
Stale has less to do with mining and more to do with propagation. If you have all the cores screaming running the SHA did you have enough CPU power left over to do the rest and get it out to the world. It's not a lot of computing power, but if you don't have any to spare it could cause issues. The other half of stale is networking. How many nodes is your node talking to? If there is a lag there and more nodes see the other block then you loose.
Also, it could be other miners deliberately causing reorgs. I don't see the point on testnet, but if I have enough power I can just ignore some blocks figuring I will get 2 or 3 while the rest of the network gets 1. That would just be a waste, but I can see people messing around to see if they can do it.
-Dave
You found my messages! Nice! I've got to plant some more (on a new address) then..
Sure, let's do it. Sorry, only just revisited this thread again.
Usually in parallel programming (multi-thread) when one thread finds the answer it breaks out of it and sends a "signal" to other threads to break too. Which means after finding the new block at least part of CPU has to be freed to be used for the broadcasting process.
humbleledgerLegendary
Posts: 1027 · Reputation: 6554
#20Aug 17, 2021, 07:25 AM
As far as I could see, I never mined a block.
I followed Solo mine testnet bitcoins with bfgminer, Bitcoin Core, and a CPU (but somehow ended up posting in this thread).
I assume that's not a problem, Linux multitasking should be able to handle this. And I used nice for the miner.
If that would be the problem, I would have expected to see orphaned blocks, right?
Thanks! I'll PM you the details (and let's switch back to the correct thread).
Related topics
- Bitcoin Core displaying coins (UTXOs) in a new tab 13
- Ways to earn some sats by contributing to bitcoin core development 5
- What can I do to fix this Bitcoin Core error? 8
- How do you protect your Bitcoin Core wallet? 19
- issues with bitcoin core database read error 2
- Curious about the 'Services' section in the peers of Bitcoin Core 6