Pages:
Author

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

hero member
Activity: 1176
Merit: 647
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: 2394
Merit: 5531
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: 2954
Merit: 4158
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: 1176
Merit: 647
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: 1176
Merit: 647
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: 2394
Merit: 5531
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: 1176
Merit: 647
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: 1176
Merit: 647
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: 1176
Merit: 647
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: 2954
Merit: 4158
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: 1176
Merit: 647
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: 2506
Merit: 2832
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: 2394
Merit: 5531
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: 1176
Merit: 647
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: 1176
Merit: 647
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?
Pages:
Jump to: