I'm trying to get bitcoin-cli to work with testnet3, and I'm using bitcoin-qt (knots 29).
My testnet3 is fully synced. In the Linux terminal, I use:
Here's what I get:
In my ./bitcoin/bitcoin.conf file, I have this:
When I run bitcoin-cli on the main blockchain, it works perfectly. So there's definitely something off with the testnet3. The .cookie is present in the /testnet3 folder, but it seems like it's not being read or something. The error message is pointing to a missing testnet3/bitcoin.conf file, so I went ahead and created one there with the same settings:
But I'm still getting the same error. I noticed that it’s not even loading that file in testnet3 because I tried changing the par1 in the /.bitcoin/ folder and par=4 in the /.bitcoin/testnet3 folder, but when I start bitcoin-qt with -testnet=1, it uses par=1. This suggests it's reading the config from the main folder instead. The debug.log file indicates:
It appears to be using par=1, which is also reflected in the GUI. I actually found a line that shows it's just pulling the config from the regular /.bitcoin/bitcoin.conf file.
I thought there was just a single global bitcoin.conf file in /.bitcoin/ that was used across all data directories, but now I'm unsure if you can have different bitcoin.conf files for each data directory due to this error. Regardless, I’m puzzled why this isn't working. The cookie is created in testnet3, and it works fine when launching on mainnet, so unless testnet requires different settings in bitcoin.conf, I'm at a loss.
bitcoin-cli issues in testnet mode
4 replies 417 views
-datadir should be the mainnet datadir, not the testnet one. When you're in testnet mode, it always uses the testnet3 subdirectory of whatever is specified in -datadir.
Would have never guessed that. It works:
So as far as bitcoin.conf files, you are supposed to only have one file on /.bitcoin/ and not have separate in /testnet3/ or /testnet4/ etc?
Thing is, on the GUI in datadir it says:
/home/takuma/software/.bitcoin/testnet3
So assumed it would have it's own bitcoin.conf file too, and require that path when you use -datadir, but I don't remember reading it automatically adds /testnet3/ when running testnet.
Btw, if you wanted to not have to type the path each time you use bitcoin-cli, what would be a solution?
Should I add "datadir=/home/takuma/software/.bitcoin" in the bitcoin.conf file? I have .desktop files with different arguments for the executables. So one file runs bitcoin-qt normally and another adds -testnet=1. Considering that you said if you run in testnet mode it automatically adds the subdirectory of whatever chain you are adding, then adding that in bitcoin.conf should be safe? I just don't want my blockchain files overwritten, I mean I don't want the testnet blockchain overwritting the normal blockchain files if it reads that it literally should be using "datadir=/home/takuma/software/.bitcoin/" from the bitcoin.conf file, but I assume it always adds the subdirectory. Well the idea is to not need to type the path eachtime you use ./bitcoin-cli so im looking to tell bitcoin-cli to always use the datadir I want by default. I assume this can be done like this or either add -datadir=path to the .desktop entries.
yes
Added but to run ./bitcoin-cli it still requires that I add the -datadir=path arg everytime I run the command.
Related topics
- bitcoin-qt sync issues and slow speeds 6
- Recovering a Bitcoin wallet and address 8
- Pending Transaction Issues 19
- Memory Issues with RPC API REST /rest/block/ 19
- Affordable quiet mini PC for running a Bitcoin node and blockchain explorer 19
- Using two different Bitcoin versions without messing up blockchain data 3