Are you generating all 3 types of addresses? By default, Bitcoin Core only generates native segwit. Did you modify the conf file to generate legacy address?
How are you extracting the private key exactly? A single private key can be used to derive all 3 address types. Could you try dumping 2 different bc1 addresses and check the private keys?
Yes, I used the proper commands to generate '1', '3' and 'bc1' addresses.
What I do to try to get the private keys are:
start the deamon. Note: I tried to start it in 2 ways just to rule out any possibility.
and
bitcoind -wallet=wallet-name-here
The difference is only that if I use the first command, I have to load the wallet with bitcoin-cli and always use "-rpcwaller=wallet-name-here" before issuing any command.
I'll assume here that I use the 1st method using -rpcwallet before any command.
Then, after the deamon is running I load the wallet with:
bitcoin-cli loadwallet wallet-name-here
Then I unlock the wallet for 3 minutes (just as an example), because I locked it when I created it.
bitcoin-cli -rpc-wallet=wallet-name-here walletpassphrase password-here 180
Then I get the address I want to dump the private key using:
bitcoin-cli -rpc-wallet=wallet-name-here listlabels
bitcoin-cli -rpc-wallet=wallet-name-here getaddressesbylabel
and finally I try to dump the private key for the address I want:
bitcoin-cli -rpc-wallet=wallet-name-here dumpprivkey "address here"
But I'm always getting the same privkey for any address I have.
I have tried the same for the default address where there is also an address that I actually don't use, and the privkey is different. I can't understand why it gives me the same privkey in this wallet that I'm trying to do it.
Could you try dumping 2 different bc1 addresses and check the private keys?
You mean to create 2 new addresses and check their private keys?
Then I have locked down the wallet with the encryptwallet command.
This only changed the HD seed of your wallet for the new addresses, created another set of keys in your keypool while keeping the old keys.
So there shouldn't be any problem with the previously created keys.
I think this is not the issue.
I created some addresses (1, 3 and bc1) from this wallet. They were all created from this wallet.
Did you created those addresses using
getnewaddress "" "address-type"; or set a start parameter/config file?
Because if you used the latter, Bitcoin Core will derive the selected address type from the same keypool.
Like my test (regtest):
Wallet started with
-addresstype=legacycUKHjYsDHDotrZMuiMGewq7KDU9YRdMPDbKCcaVQ9fF6cHtQZj5A 2020-05-23T04:05:48Z
reserve=1 # addr=mhbNXxRD1NySfJ8p7ehbF3hfXVKQcm5z6B hdkeypath=m/0'/0'/1'
Wallet started with
-addresstype=p2sh-segwitcUKHjYsDHDotrZMuiMGewq7KDU9YRdMPDbKCcaVQ9fF6cHtQZj5A 2020-05-23T04:05:48Z
reserve=1 # addr=2My3QdbSW5dyiz8ccJMjvH8RWdT9fzaKeiQ hdkeypath=m/0'/0'/1'
Wallet started with
-addresstype=bech32cUKHjYsDHDotrZMuiMGewq7KDU9YRdMPDbKCcaVQ9fF6cHtQZj5A 2020-05-23T04:05:48Z
reserve=1 # addr=bcrt1qzmrzv53lfccgaajpc9m2fvu5tadxz4n9wwjwcf hdkeypath=m/0'/0'/1'
If not through
-addresstype=, there is surely a problem.
No, I've created them all by command getnewaddress and address-type.