How to solo mine testnet bitcoins using bfgminer, Bitcoin Core, and your CPU/GPU

19 replies 169 views
WildGuruFull Member
Posts: 77 · Reputation: 559
#1May 15, 2025, 09:42 AM
After sharing my last guide on solo mining testnet bitcoins with an ASIC and cgminer, I’m back with a new one that shows you how to do it without needing an ASIC. This means you can mine testnet bitcoins using any computer that has a CPU or GPU. You should be able to run this on pretty much any laptop or desktop, including those with Apple’s new M1 chips. Of course, the faster your CPU or GPU, the better your odds of mining some blocks. You might be curious about how this works. Well, the trick is that the difficulty level in testnet3 drops back to 1 if no blocks are found within 20 minutes. A difficulty of 1 is so low that pretty much any CPU or GPU can find a block. Just for context, this was the same difficulty level Bitcoin had back in its early days (2009). If you want more details on this, check it out here: https://bitcoin.stackexchange.com/questions/18554/how-can-i-find-the-real-difficulty-on-testnet Alright, let’s get started. First up, you need to set up Bitcoin Core just like in the other guide. I’ll give you a quick recap for ease of use: Step 1: Install and run Bitcoin Core We’ll be using the folder ~/bitcoin_testnet to keep things organized and easy to delete later. You can choose a different path if you prefer. Create a folder named data inside ~/bitcoin_testnet: Download the Bitcoin Core for your system into ~/bitcoin_testnet/ and extract it there. Now, let’s get the configuration file ready. Make a text file called bitcoin_testnet.conf in ~/bitcoin_testnet/ and add this content to it:
6 Reply Quote Share
hash_bossLegendary
Posts: 1166 · Reputation: 5261
#2May 15, 2025, 01:23 PM
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.
4 Reply Quote Share
WildGuruFull Member
Posts: 77 · Reputation: 559
#3May 17, 2025, 05:27 PM
Ah, yes, I mentioned it in the previous guide but forgot to mention it here again as bfgminer also expects a legacy address: 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.
4 Reply Quote Share
darkguruHero Member
Posts: 849 · Reputation: 4147
#4May 17, 2025, 11:42 PM
You really should mention that by design the Testnet coins have ZERO monetary value. Purchase and sale of them is strongly discouraged as Testnet and its coins are for testing software -- not making money... Mining them and holding them is also pretty pointless because the Testnet chain is periodically forked to render previously mined Testnet coins unusable. After a development project is over it is expected that all Testnet coins mined during testing are to be donated back to the Faucets.
0 Reply Quote Share
WildGuruFull Member
Posts: 77 · Reputation: 559
#5May 18, 2025, 02:26 AM
Yeah, I didn't mention it because I thought that was well known for the people reading the Development & Technical Discussion forum. It's basically for people that don't want to depend on faucets to test their projects. Once you know how to do it you can mine some testnet bitcoin for yourself overnight, even if there's no faucets available. But you're right, it might be worth noting it for people that come here from the outside through a search or a link. Yes, testnet bitcoins are only useful for testing, they don't have any other value, and they can even disappear at any time. That's also why I didn't mention any kind of security for the wallet, because it doesn't matter.
0 Reply Quote Share
hash_bossLegendary
Posts: 1166 · Reputation: 5261
#6May 18, 2025, 03:51 AM
After almost 4 days, i managed to mine 4 blocks. But due to relative slow internet connection, 2 of them become stale. Overall it's good experience and i got about ~0.05 tBTC, which probably will be used to try few different OPCODES on scripting or simply donate it to tBTC faucet. On a side note, on 3rd day i tried to mine only with 1 thread CPU since the goal to mine block with difficulty 1. But when i shutdown my PC, i got this error message with >100K occurrence. Quick search on google shows it's due continuous CPU usage for long time, although i'm not 100% sure it's due to bfgminer.
0 Reply Quote Share
eric.maxiMember
Posts: 35 · Reputation: 232
#7May 18, 2025, 08:54 AM
I tried to repeat the procedure, but I ran into some issues. Note that MYUSER, MYPASS and MYADDR are replaced by their actual values when running the below commands I'm able to access the node using So it seem to be able to connect, but if I try with bfgminer   While I'm running the above command I observe the following on the console of my node: Running on the node itself it seem to connect: Also running cpuminer from the remote computer on the LAN seem to work Does this mean that cpuminer is working as expected while bfgminer does not. I will leave it running for a few days and see if I'm able to solve a block on the test network.
4 Reply Quote Share
WildGuruFull Member
Posts: 77 · Reputation: 559
#8May 20, 2025, 03:34 PM
You're running bfgminer with different options than what I wrote here. Check those first. In particular, you're disabling getwork and stratum connectivity: Try running it without those options
0 Reply Quote Share
eric.maxiMember
Posts: 35 · Reputation: 232
#9May 20, 2025, 08:43 PM
Thank you, but I did that deliberately. I was pointed to this thread from  https://bitcointalk.org/index.php?topic=5418942.0 entitled What is a good reference for a getblocktemplate based solo miner. Hence I was expecting bfgminer could serve that purpose, which does not seem to be the case. But on the other hand it appears that cpuminer might serve the purpose.
3 Reply Quote Share
humbleledgerLegendary
Posts: 1027 · Reputation: 6554
#10May 20, 2025, 11:30 PM
Thanks for the tutorial, I'm mining Testnet now! It's CPU only, on a server. Let's see if it catches a block. The only problem I ran into was at this step: The error came down to this: And the solution was easy:
4 Reply Quote Share
vault2019Member
Posts: 57 · Reputation: 212
#11May 21, 2025, 05:07 AM
Also, I've noticed that bfgminer isn't creating proof with more than 8 zeros. Is there a way to modify so it creates proof with more than 8 zeros? example: Proof: 0000000074f7267c7ed96843de88967a43728be514fee31a6b5dc623bb688291 Target: 00000000000000000007f5900000000000000000000000000000000000000000 TrgVal? no (false positive; hash > target) I looked in bfgminer/miner.c but couldn't manage to change anything to create 19 leading zero proof
1 Reply Quote Share
vault2019Member
Posts: 57 · Reputation: 212
#12May 21, 2025, 05:22 AM
hey OP, this works: ...for cgminer usage on AMD GPU - valid 22 december 2022
4 Reply Quote Share
humbleledgerLegendary
Posts: 1027 · Reputation: 6554
#13May 21, 2025, 07:07 AM
It's been 4 days, and at 6.33Mh/s, I haven't found a single block. Maybe I did something wrong, or maybe CPU mining is still too slow even when the difficulty is 1. Either way, I gave up for now, and killed the miner. It seems like a waste of CPU. I'll keep Bitcoin Core Testnet running for a while.
0 Reply Quote Share
humbleledgerLegendary
Posts: 1027 · Reputation: 6554
#14May 21, 2025, 08:15 AM
I killed it after a week. I started it again (this morning), and gave n0nce access. Let's see if I missed something.
3 Reply Quote Share
hodlg4ngSenior Member
Posts: 129 · Reputation: 853
#15May 21, 2025, 10:34 AM
Rough numbers: At 300GH/s and difficulty of 1, I should in theory mine one valid block in 3ps (picoseconds), meanwhile at 6MH/s it would take 166ns (nanoseconds). However, in a difficulty=1 scenario, the difference of 165997ps should make no difference at all. Network latency to other nodes will probably be in the single to double-digit ms range. For reference: 1ms (which is a really good network latency) are a million ns. There is a chance that your CPU is overloaded with all cores mining and no core ready to push that packet out to the network asap. Another idea would be making sure that this old CPU miner code doesn't wait for e.g. a whole set of nonce values before returning a valid block or something silly like that. It should return as soon as a block meets the difficulty, but I wouldn't rule out that it waits longer for whatever (legacy?) reason. I will definitely have a look at your bfgminer config and the bfgminer code, too.
3 Reply Quote Share
humbleledgerLegendary
Posts: 1027 · Reputation: 6554
#16May 21, 2025, 11:46 AM
Who decides on those 20 minutes anyway? In Bitcoin, there's no need for exact timestamps. Is this different in testnet? I checked a few of the latest testnet blocks, and found times between blocks of: 2418404 > 2418405: 20 minutes and 3 seconds. 2418410 > 2418411: 20 minutes and 5 seconds. 2418407 > 2418408: 20 minutes and 8 seconds. I checked the last 2 days, and to my surprise only 115 blocks per day get mined. I'm surprised because the total block height is much higher than for Bitcoin. I'm also surprised that several people here have mined several blocks per day at difficulty 1, which means that only a few dozen people can do that per day. I'd expect much more people to be mining testnet.
4 Reply Quote Share
hash_bossLegendary
Posts: 1166 · Reputation: 5261
#17May 21, 2025, 04:34 PM
This is good question. On Bitcoin Wiki, 20 minutes only mentioned since early 2013[1]. But afterwards i found out Gavin Andresen propose this[2] and create pull request some time later[3]. Mining difficulty on testnet keep rising which discourage some people to perform mining, where people with CPU/GPU only expect to earn tBTC from 1 difficulty after 20 minutes. Probably because now we have separate testing network dedicated for newer Bitcoin feature (e.g. signet and segnet) and in past people attempt to attack/stress Bitcoin testnet by mining with tons of ASIC. [1] https://en.bitcoin.it/w/index.php?title=Testnet&oldid=35502 [2] https://bitcointalk.org/index.php?topic=50223.msg627957#msg627957 [3] https://github.com/bitcoin/bitcoin/pull/686
3 Reply Quote Share
hodlg4ngSenior Member
Posts: 129 · Reputation: 853
#18May 21, 2025, 10:24 PM
Did you monitor your CPU miner a bit? I just catched an instance where the last block was 20 minutes ago and bfgminer never adjusted the difficulty setting from its '125M' value. Does it take a bit longer to adjust or what is the cause? Or is it just not reflected in the user interface? I expected it to drop to 1 as soon as the 20 minute mark passed, even if it may not end up being first at submitting something to the network. But it simply didn't budge. This is Loyce's machine with 7 threads hashing and 1 core free to submit a block quickly. One thing I just realized is that in the screenshot, the I value (BTC per hour) is set to a question mark. So maybe it did quickly submit a block candidate and was waiting to see if it got accepted by the network? Can you post a log screenshot of what it looks like when bfgminer finds a valid block (whether it is accepted by the network or not - you mention 2 stale blocks)?
6 Reply Quote Share
hodlg4ngSenior Member
Posts: 129 · Reputation: 853
#19May 22, 2025, 03:31 AM
With log, I mean the bfgminer log output as shown here. I am wondering whether it logs / shows whether it found a block at diff 1 here. Trying to work out whether the software even realizes that 20 minutes have passed, reduces the difficulty to 1, hashes a block candidate and tries to submit it or whether this all doesn't even happen. Even just seeing how a successfully mined block is shown in this log, would help, since I can only reference my experience with cgminer whose output looks very different.
3 Reply Quote Share
humbleledgerLegendary
Posts: 1027 · Reputation: 6554
#20May 22, 2025, 06:29 AM
It sounds like this could be the reason it doesn't mine any blocks: if it never knows the difficulty is low, it won't find a block at low difficulty. From your screenshot: I'm starting to think difficulty=1 doesn't mean it takes picoseconds to mine a block: That would explain why ASICs still beat any CPU miner as it would take me about a second, while it takes the ASICs a fraction of a millisecond.
1 Reply Quote Share

Related topics