Author

Topic: offline node and my priv keys not working (Read 391 times)

hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
The reason is just keep organization clean and sane. If I have addresses I don't want to use anymore, I want to remove them from node so that they don't bother me in the future.
The address would just sit inside the wallet quietly, doubt it would bother you.  Cheesy

I use Bitcoin Core by using the request tab to generate addresses and I don't have to be confused by the addresses that were used by me. If any transactions somehow gets sent to my addresses (by accident or not), I would still be able to retrieve it.
So, because this is an HD wallet, I can only remove addresses by removing the wallet file/folder?
No, the behaviour has been this way since a long time ago. Bitcoin Core doesn't support removing addresses because its not meant to be done. If you really want to remove addresses from your wallet.dat, consider using pywallet.

Ok, I'll just le them there. Nevertheless, they bother... It's output I don't need when I use 'listlabels', 'listwallets', etc.
But I get the point about eventually sending BTC by accident into them.

How do I remove/lose/let go wallets and addresses I don't need/want anymore?
As an addition: For imported addresses, simply restore the old copy of your wallet.dat prior to the import.
Since it's an HD wallet, newer used addresses that belong to the HD seed should be restored without a problem.

Ok, thanks for now!
legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
How do I remove/lose/let go wallets and addresses I don't need/want anymore?
As an addition: For imported addresses, simply restore the old copy of your wallet.dat prior to the import.
Since it's an HD wallet, newer used addresses that belong to the HD seed should be restored without a problem.
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
The reason is just keep organization clean and sane. If I have addresses I don't want to use anymore, I want to remove them from node so that they don't bother me in the future.
The address would just sit inside the wallet quietly, doubt it would bother you.  Cheesy

I use Bitcoin Core by using the request tab to generate addresses and I don't have to be confused by the addresses that were used by me. If any transactions somehow gets sent to my addresses (by accident or not), I would still be able to retrieve it.
So, because this is an HD wallet, I can only remove addresses by removing the wallet file/folder?
No, the behaviour has been this way since a long time ago. Bitcoin Core doesn't support removing addresses because its not meant to be done. If you really want to remove addresses from your wallet.dat, consider using pywallet.
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
How do I remove/lose/let go wallets and addresses I don't need/want anymore?

You can remove wallets by simply deleting the wallet file.
But that's not recommended since you might receive more BTC at some point in the future. If you don't need them just move them into a different folder and forget about them.

Regarding addresses, you can't delete them (addresses, private keys) since it is a HD wallet (all derived from the same seed).
Is there a practical reason you want to delete them? 

The reason is just keep organization clean and sane. If I have addresses I don't want to use anymore, I want to remove them from node so that they don't bother me in the future.

So, because this is an HD wallet, I can only remove addresses by removing the wallet file/folder?
legendary
Activity: 1624
Merit: 2481
How do I remove/lose/let go wallets and addresses I don't need/want anymore?

You can remove wallets by simply deleting the wallet file.
But that's not recommended since you might receive more BTC at some point in the future. If you don't need them just move them into a different folder and forget about them.

Regarding addresses, you can't delete them (addresses, private keys) since it is a HD wallet (all derived from the same seed).
Is there a practical reason you want to delete them? 
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
-snip-
And about importprivkey, I don't want to import them. They were created in this node, so they don't need to be imported. Unless you mean to import them into another wallet/node.
Yes, in case you want to import them to another wallet or test if that private key will restore those three addresses.
You can create another wallet in the same offline machine to test that and clear your doubt.

If you can use Bitcoin-Qt, you have the option to display them in "Window->Receiving addresses"
and after you've imported the private key (add a label), it will be included there as all of three address types.

It looks like this (Imported from a single prv key):


Ohh, ok, I got that. Good point. Didn't remember that.

And I take the opportunity to ask a couple of other questions, if I'm allowed.

How do I remove/lose/let go wallets and addresses I don't need/want anymore?
legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
-snip-
And about importprivkey, I don't want to import them. They were created in this node, so they don't need to be imported. Unless you mean to import them into another wallet/node.
Yes, in case you want to import them to another wallet or test if that private key will restore those three addresses.
You can create another wallet in the same offline machine to test that and clear your doubt.

If you can use Bitcoin-Qt, you have the option to display them in "Window->Receiving addresses"
and after you've imported the private key (add a label), it will be included there as all of three address types.

It looks like this (Imported from a single prv key):
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
I'm just not aware at all where those indexes comes from and into the play regarding my full node. I mean, someone said I can use different index to generate a different address with a different PK other than the same PK that generated any of the 2 bc1 addresses I generated before. I just want to know how.

I am not completely sure, but i believe this does not work with getnewaddress in core.
Other wallets definitely offer that option (e.g. electrum), but afaik core doesn't.

Ok, no problem...


I don't have any specific reason. These 3 addresses were created back when I started learning about the bitcoin protocol. I was experimenting, testing, learning. And I always kept them but never noticed they were sharing the same PK because I've only used one of them to send payments out. The other address starting with 1, never used it and the bech32 is one of the addresses where I old some BTC, so I never used their PKs that many times to notice they were the same.

My personal recommendation would be to either 1) decide which type of addresses you want and only use that or 2) create a seperate wallet for each type of addresses.
That probably would be the easiest approach.

That's what I will probably do. I'll use option 2. A different wallet to each type of address if I need more than one address type. Thanks for the suggestion.

Why I want to save the PKs with the addresses?? Well, to know which address belongs to which address.

But is there a reason for that?
What do you need this for? If you want to spend from a specific address, your wallet can take care of it.
Same applies to signing messages from a specific address.
If you want to export the private key of a specific address, you can also do so with a simple command.

If this is for a backup, the seed or the wallet file would be a more convenient way to backing it up.

Is there any specific reason for that ?

The reason is the one I already said. I like more the ideia of a single PK per address, instead of a PK for 3 addresses. That way I will always know to which address corresponds each PK. Easier to back up, easier to organise if I have several addresses and/or several nodes, etc.
I feel more comfortable that way. That's all.

About derivation paths, I think my knowledge about the subject is enough to answer to that. In other words, I don't know what are derivation paths technically or how to get them or how to use them.

Since all private keys are derived from a single seed, a path used to do so.
It starts with the index 0 and increases for each derived private key. So, the first time you call getnewaddress you get the address from the private key at index 0, the second one at index 1, and so on..

Ok, I think I understand. This derivation path seems to be something more at the level of bitcoin core source code when generating addresses.

One more thing I might not have made clear is that I tend to avoid using too many applications. I have never user Electrum to send payments anywhere. I always try to do it from my nodes (1 online and 1 offline).
This serves, at least, 2 purposes. Some security/privacy and the learning process.
I like to think that in crypto, you should suspect of everything. But this is an whole different subject. I just want to say that I try to use the least applications possible to what I need to do. That reduces risks of malware, trojans, keyloggers, phishing and other types of intrusion and privacy violations.

I thought you are planning on creating a web application or something similar, that's why i mentioned that way of storing relevant information.

IMO you shouldn't worry too much about it.
Storing private keys together with an address doesn't make much sense. If you are planning to do something with those private keys, that obviously would be something completely different.
But for normal usage, what is the problem with only using 1 address type or using different wallets for different types or just using different types of address derived from the same private key ?

The reason I created this thread is not directly related to any web site or application. But I'm doing something on that field. But I still need to learn a lot, mostly about addresses wallets, scriptsigs and all that stuff. At least for the learning purpose. I'm still a noob in this, so one good way to learn is to get involved in some project. It makes me to search, read, ask, experiment, etc.
legendary
Activity: 1624
Merit: 2481
I'm just not aware at all where those indexes comes from and into the play regarding my full node. I mean, someone said I can use different index to generate a different address with a different PK other than the same PK that generated any of the 2 bc1 addresses I generated before. I just want to know how.

I am not completely sure, but i believe this does not work with getnewaddress in core.
Other wallets definitely offer that option (e.g. electrum), but afaik core doesn't.



I don't have any specific reason. These 3 addresses were created back when I started learning about the bitcoin protocol. I was experimenting, testing, learning. And I always kept them but never noticed they were sharing the same PK because I've only used one of them to send payments out. The other address starting with 1, never used it and the bech32 is one of the addresses where I old some BTC, so I never used their PKs that many times to notice they were the same.

My personal recommendation would be to either 1) decide which type of addresses you want and only use that or 2) create a seperate wallet for each type of addresses.
That probably would be the easiest approach.



Why I want to save the PKs with the addresses?? Well, to know which address belongs to which address.

But is there a reason for that?
What do you need this for? If you want to spend from a specific address, your wallet can take care of it.
Same applies to signing messages from a specific address.
If you want to export the private key of a specific address, you can also do so with a simple command.

If this is for a backup, the seed or the wallet file would be a more convenient way to backing it up.

Is there any specific reason for that ?



About derivation paths, I think my knowledge about the subject is enough to answer to that. In other words, I don't know what are derivation paths technically or how to get them or how to use them.

Since all private keys are derived from a single seed, a path used to do so.
It starts with the index 0 and increases for each derived private key. So, the first time you call getnewaddress you get the address from the private key at index 0, the second one at index 1, and so on..


I thought you are planning on creating a web application or something similar, that's why i mentioned that way of storing relevant information.

IMO you shouldn't worry too much about it.
Storing private keys together with an address doesn't make much sense. If you are planning to do something with those private keys, that obviously would be something completely different.
But for normal usage, what is the problem with only using 1 address type or using different wallets for different types or just using different types of address derived from the same private key ?
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
Each private key can generate those 3 types of addresses.
It is just whether or not you actually derive/use it at index X.

Is there a specific reason for you to derive all 3 types of addresses ?
And why do you want to save the private key together with the address in a database ? Couldn't you just save the derivation path together with the address ?
This would allow you to securely store the seed while still retaining the necessary information to derive the needed private key at any given time (with access to the seed).

I already understood that a single PK can derive 3 addresses.

I'm just not aware, at all, where those indexes comes from and where they come into play, regarding my full node. I mean, someone said I can use different indexes to generate a different address with a different PK. I just want to know how to do that. I don't know how to do that using my full node.

I don't have any specific reason. These 3 addresses were created back when I started learning about the bitcoin protocol. I was experimenting, testing, learning. And I always kept them but never noticed they were sharing the same PK because I've only used one of them to send payments out. The other address starting with 1, never used it and the bech32 is one of the addresses where I old some BTC, so I never used their PKs that many times to notice they were the same.

Why I want to save the PKs with the addresses?? Well, to know which address belongs to which address.
About derivation paths, I think my knowledge about the subject is enough to answer to that. In other words, I don't know what are derivation paths technically or how to get them or how to use them.
legendary
Activity: 1624
Merit: 2481
Each private key can generate those 3 types of addresses.
It is just whether or not you actually derive/use it at index X.

Is there a specific reason for you to derive all 3 types of addresses ?
And why do you want to save the private key together with the address in a database ? Couldn't you just save the derivation path together with the address ?
This would allow you to securely store the seed while still retaining the necessary information to derive the needed private key at any given time (with access to the seed).
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
Ok, I got it. So, if I want, after I created those 2 new bech32 addresses, to create 2 other addresses started with a 3 but not derived from the same PK as the 2 bech32, can it be done?

Yes.
Just use a different derivation index.

Your first address can have the index 1.
Regardless of the type of this or the next address you want to derive, use index 2 for the next address.
This requires you to keep track of all the used indexes.

But what is the reason for that ?
Are you planning on giving out or publishing private keys ? If not, there is no practical reason i can think of to complicate the derivation of your keys.

I understand what you mean. But it can be a bit confusing to be working with a few keys knowing that some of them shares the same PK and some others won't. I would rather to have a unique pair rather than this. It's easier to make a 1:1 relationship than to have to sometimes do a 1:1 and other times a 1:3.
I'm not sure I explained myself clearly.
I mean that it adds complexity to think that I have some addresses that shares PKs (1 PK : 3 addresses) and addresses that doesn't share PKs (1 PK : 1 address).

How do you set those indexes when you create addresses in your node? I mean, the 'getnewaddress' command only have 1 parameter which is the label and it is optional!
legendary
Activity: 1624
Merit: 2481
Ok, I got it. So, if I want, after I created those 2 new bech32 addresses, to create 2 other addresses started with a 3 but not derived from the same PK as the 2 bech32, can it be done?

Yes.
Just use a different derivation index.

Your first address can have the index 1.
Regardless of the type of this or the next address you want to derive, use index 2 for the next address.
This requires you to keep track of all the used indexes.

But what is the reason for that ?
Are you planning on giving out or publishing private keys ? If not, there is no practical reason i can think of to complicate the derivation of your keys.
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
I didn't understand the underlined sentence. Addresses starting with 3 and bc1 are multisig, right? Addresses starting with 1 are not muktisig, if I'm not mistaken.
Nope. Addresses starting with 3 are P2SH (Pay to Script Hash) address. It allows the user to fulfill certain criteria before a transaction involving that address is valid. bc1 is a bech32 address, aka. native segwit. Address starting with 1 are P2PKH (Pay to Public Key Hash) address.

A multisig address has to be a P2SH address while a P2SH address doesn't necessarily has to be a multisig address.
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
Anyway, coming back to the topic, so, in my offline node I cannot retrieve those 3 addresses individual private keys? I mean they must have one, no?
No, if they are indeed have the same private key, then it's their private key; you can derive all non-multisig address types from the same private key.
Try to use getaddressinfo (usage link) and see if "ismine:" for the three addresses is true.

If those addresses were derived from the same key, Bitcoin core will be able to restore them through bitcoin-cli importprivkey "prv_key" "label" false (usage link).
It will be imported as each of the three address type if you're using 0.19.1 (all three addresses at the same time), I don't know if 0.18 will do the same.


I didn't understand the underlined sentence. Addresses starting with 3 and bc1 are multisig, right? Addresses starting with 1 are not muktisig, if I'm not mistaken.
In my case, I have one non-multisig and 2 multisg, so I'm not sure what you mean when you say 'non-multisg'.

And about importprivkey, I don't want to import them. They were created in this node, so they don't need to be imported. Unless you mean to import them into another wallet/node.
legendary
Activity: 2702
Merit: 3045
Top Crypto Casino
..
Anyway, coming back to the topic, so, in my offline node I cannot retrieve those 3 addresses individual private keys? I mean they must have one, no?
They don't have individual private keys. Those three addresses are derived from the same private key.
If you want a new PK, simply create a new address from the same format (P2PKH, P2SH or Bech32).
However, again, that new created PK can be used to create two other addresses from other formats. This is basically why a wallet such as Electrum requires to provide the type of the address you want to generate when importing a private key.

legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
Anyway, coming back to the topic, so, in my offline node I cannot retrieve those 3 addresses individual private keys? I mean they must have one, no?
No, if they are indeed have the same private key, then it's their private key; you can derive all non-multisig address types from the same private key.
Try to use getaddressinfo (usage link) and see if "ismine:" for the three addresses is true.

If those addresses were derived from the same key, Bitcoin core will be able to restore them through bitcoin-cli importprivkey "prv_key" "label" false (usage link).
It will be imported as each of the three address type if you're using 0.19.1 (all three addresses at the same time), I don't know if 0.18 will do the same.
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
And another question. Once I import one of those 3 keys to an online wallet like Electrum or so, that private key will be exposed to the internet and therefore all three address can be generated and bitcoins stolen, right? Even if I have never used the other 2 addresses online, right?
Unless there's a security problem, Electrum shouldn't expose any of it's private keys to the internet. But indeed, if you use 1 key for 3 addresses, all addresses can be emptied if someone would get their hands on the private key.
If you want your private keys to remain cold storage, you shouldn't use them on an online computer. If you want to use Electrum, you can import the address on an online computer, create a transaction, copy the transaction to an offline computer, and sign it there using the private keys in Electrum. It doesn't hurt to decode the signed transaction before continuing to ensure it does what you want. Then, copy the signed transaction to an online computer and broadcast the transaction.
It's a hassle, but doable. Disclaimer: this was a short description, make sure you understand what you're doing before doing it.

Well, I use a similar approach.
But the deal here is not to create transactions. I just wanted to retrieve the individual PKs of these 3 adresses I have instead of that same PK.

The approach I use, because I don't have an offline computer, is that I created a virtual machine and removed all internet devices such as network cards etc so that it has no communication with the internet whatsoever, and this is an encrypted virtual volume. So, it's in this offline virtual machine that I run my offline node and create my addresses.

And the thing is that I didn't want to use my PKs anywhere other than in this offline node unless I'm going to spend all the BTC in those addresses.
Like, I use this rule of thumb that when I use one of my addresses PK to send some transaction out of my address, this address will be shortly left and forgotten as soon as I empty it. I don't want to use an address for much time after I used it for the first time. You know what I mean?

Anyway, coming back to the topic, so, in my offline node I cannot retrieve those 3 addresses individual private keys? I mean they must have one, no?
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
And another question. Once I import one of those 3 keys to an online wallet like Electrum or so, that private key will be exposed to the internet and therefore all three address can be generated and bitcoins stolen, right? Even if I have never used the other 2 addresses online, right?
Unless there's a security problem, Electrum shouldn't expose any of it's private keys to the internet. But indeed, if you use 1 key for 3 addresses, all addresses can be emptied if someone would get their hands on the private key.
If you want your private keys to remain cold storage, you shouldn't use them on an online computer. If you want to use Electrum, you can import the address on an online computer, create a transaction, copy the transaction to an offline computer, and sign it there using the private keys in Electrum. It doesn't hurt to decode the signed transaction before continuing to ensure it does what you want. Then, copy the signed transaction to an online computer and broadcast the transaction.
It's a hassle, but doable. Disclaimer: this was a short description, make sure you understand what you're doing before doing it.
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
But why these 2 addresses are created with different PKs and the other ones I have, all have the same PK? I can't see the reason why.
Also, what you suggest to do with Electrum is to import those 3 addresses I have that are giving out the same PK?
Every private key can generate three kinds of address. The generated address can be legacy (starts with 1), nested segwit (starts with 3), native segwit (starts with bc1).
The two new private keys you have can generate other kinds of addresses too.

Let's say you have a legacy HD wallet with 20 different addresses.
You have 20 different legacy addresses and 20 different private keys.

These 20 private keys can generate 20 native segwit addresses and 20 nested segwit addresses too.

Ok, I think I understand. But I don't want that to happen. I want a different private key each time I add a new address to my node... Can that be done?

And another question. Once I import one of those 3 keys to an online wallet like Electrum or so, that private key will be exposed to the internet and therefore all three address can be generated and bitcoins stolen, right? Even if I have never used the other 2 addresses online, right?
legendary
Activity: 2380
Merit: 5213
But why these 2 addresses are created with different PKs and the other ones I have, all have the same PK? I can't see the reason why.
Also, what you suggest to do with Electrum is to import those 3 addresses I have that are giving out the same PK?
Every private key can generate three kinds of address. The generated address can be legacy (starts with 1), nested segwit (starts with 3), native segwit (starts with bc1).
The two new private keys you have can generate other kinds of addresses too.

Let's say you have a legacy HD wallet with 20 different addresses.
You have 20 different legacy addresses and 20 different private keys.

These 20 private keys can generate 20 native segwit addresses and 20 nested segwit addresses too.
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
I have tried the dumpprivkey for one address starting with 1, and then repeated the command for an address starting with 3 and finallyrepeated the command dumpprivkey for an address starting with bc1. So I got 3 outputs. That output, which is the private key, was the same for the 3 times I used the dumpprivkey  for each of the 3 addresses.
I don't think this is a problem. You have 3 addresses, all derived from the same private key. You can try importing them in Electrum (on an offline computer that won't get a internet connection without wiping it):
Private key for SegWit addresses
A private key can be used to create SegWit addresses (starting with "3" or "bc1"). You can import them into Electrum by adding "p2wpkh-p2sh:" or "p2wpkh:" respectively in front of the private key (source and details).

But why these 2 addresses are created with different PKs and the other ones I have, all have the same PK? I can't see the reason why.
Also, what you suggest to do with Electrum is to import those 3 addresses I have that are giving out the same PK?
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
I have tried the dumpprivkey for one address starting with 1, and then repeated the command for an address starting with 3 and finallyrepeated the command dumpprivkey for an address starting with bc1. So I got 3 outputs. That output, which is the private key, was the same for the 3 times I used the dumpprivkey  for each of the 3 addresses.
I don't think this is a problem. You have 3 addresses, all derived from the same private key. You can try importing them in Electrum (on an offline computer that won't get a internet connection without wiping it):
Private key for SegWit addresses
A private key can be used to create SegWit addresses (starting with "3" or "bc1"). You can import them into Electrum by adding "p2wpkh-p2sh:" or "p2wpkh:" respectively in front of the private key (source and details).
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
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.

You mean to create 2 new addresses and check their private keys?
If you aren't getting any error when you dump the priv key, it would appear that there isn't an issue with the commands given.

To clarify, when you mean any address, you mean when you use any 2 different addresses from the same type? Ie, You're querying 2 different bc1 addresses, 2 different P2PWSH or 2 different legacy addresses? Does the address start with 5, K or L?

I'm sorry I wasn't clear.
I have tried the dumpprivkey for one address starting with 1, and then repeated the command for an address starting with 3 and finallyrepeated the command dumpprivkey for an address starting with bc1. So I got 3 outputs. That output, which is the private key, was the same for the 3 times I used the dumpprivkey  for each of the 3 addresses.


I'll create 2 new addresses, bc1 ones and will check the private keys. I'll do it from within this wallet.

And now, is it still possible to get each address private key individually?

You can derive all 3 kinds of addresses (legacy, p2sh, bech32) from the same private key.
And i think this is what happened here.

You can try what ranochigo mentioned. Create a second address from any type. This private key will be different.

Which would be the commands I need to use to get the individual addresses private keys?



Edited;

Ok, I just created 2 new addresses in this same wallet and privkeys are different.

So now the question is how do I retrieve my other addresses individual private keys???
legendary
Activity: 1624
Merit: 2481
You can derive all 3 kinds of addresses (legacy, p2sh, bech32) from the same private key.
And i think this is what happened here.

You can try what ranochigo mentioned. Create a second address from any type. This private key will be different.
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
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.

You mean to create 2 new addresses and check their private keys?
If you aren't getting any error when you dump the priv key, it would appear that there isn't an issue with the commands given.

To clarify, when you mean any address, you mean when you use any 2 different addresses from the same type? Ie, You're querying 2 different bc1 addresses, 2 different P2PWSH or 2 different legacy addresses? Does the address start with 5, K or L?
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
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.
Code:
bitcoind

and

Code:
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:
Code:
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.
Code:
bitcoin-cli -rpc-wallet=wallet-name-here walletpassphrase password-here 180

Then I get the address I want to dump the private key using:
Code:
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:
Code:
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=legacy
Code:
cUKHjYsDHDotrZMuiMGewq7KDU9YRdMPDbKCcaVQ9fF6cHtQZj5A 2020-05-23T04:05:48Z
reserve=1 # addr=mhbNXxRD1NySfJ8p7ehbF3hfXVKQcm5z6B hdkeypath=m/0'/0'/1'

Wallet started with -addresstype=p2sh-segwit
Code:
cUKHjYsDHDotrZMuiMGewq7KDU9YRdMPDbKCcaVQ9fF6cHtQZj5A 2020-05-23T04:05:48Z
reserve=1 # addr=2My3QdbSW5dyiz8ccJMjvH8RWdT9fzaKeiQ hdkeypath=m/0'/0'/1'

Wallet started with -addresstype=bech32
Code:
cUKHjYsDHDotrZMuiMGewq7KDU9YRdMPDbKCcaVQ9fF6cHtQZj5A 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.
legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
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=legacy
Code:
cUKHjYsDHDotrZMuiMGewq7KDU9YRdMPDbKCcaVQ9fF6cHtQZj5A 2020-05-23T04:05:48Z
reserve=1 # addr=mhbNXxRD1NySfJ8p7ehbF3hfXVKQcm5z6B hdkeypath=m/0'/0'/1'

Wallet started with -addresstype=p2sh-segwit
Code:
cUKHjYsDHDotrZMuiMGewq7KDU9YRdMPDbKCcaVQ9fF6cHtQZj5A 2020-05-23T04:05:48Z
reserve=1 # addr=2My3QdbSW5dyiz8ccJMjvH8RWdT9fzaKeiQ hdkeypath=m/0'/0'/1'

Wallet started with -addresstype=bech32
Code:
cUKHjYsDHDotrZMuiMGewq7KDU9YRdMPDbKCcaVQ9fF6cHtQZj5A 2020-05-23T04:05:48Z
reserve=1 # addr=bcrt1qzmrzv53lfccgaajpc9m2fvu5tadxz4n9wwjwcf hdkeypath=m/0'/0'/1'

If not through -addresstype=, there is surely a problem.
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
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?
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
Hello.

I run an offline node just for creating addresses and basically avoid exposing my newest addresses private keys. And sometimes I use this node to run some commands to learn about them.
I'm running this node in an offline and encrypted Debian Buster virtual machine andd running Bitcoin Core Daemon version v0.18.1.

Anyways, the situation is this:
I have a wallet I created with this node, let's call it my-wallet just to name things an to be the most clear I can.
I created some addresses (1, 3 and bc1) from this wallet. They were all created from this wallet.
Then I have locked down the wallet with the encryptwallet command.

But now, when I try to dump my addresses private key, node tells me the same private key for all addresses.

Why is this happening?
Jump to: