Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

importprivkey unsets labels set with importaddress and importpubkey #13087

Closed
harding opened this issue Apr 26, 2018 · 4 comments · Fixed by #13381
Closed

importprivkey unsets labels set with importaddress and importpubkey #13087

harding opened this issue Apr 26, 2018 · 4 comments · Fixed by #13381

Comments

@harding
Copy link
Contributor

harding commented Apr 26, 2018

Expected behavior:

  1. importaddress or importpubkey a watching-only address or pubkey with a label
  2. Receive a transaction to that address; observe that the label has been applied to that transaction
  3. importprivkey the private key for that address without specifying any change to the label
  4. Have the previous label still applied to the transaction after the import.

Observed behavior on 0.15 and current master:

Steps 1-3 the same.
4. Previous label is replaced with the default empty label ("")

Problem seems to have occurred on 0.15 and affects the latest master (see subsequent details). I'd suspect all versions are affected, i.e. it's not a regression.

Steps to reproduce

## For testing
ADDRESS=2N6Y2wdhd91mQnZ8qCeH6hT5aZZygXFnNjP
PRIVKEY=cQriWp98xU9ghRvDKbzkRcgcecQLezjYwtPUjLNN5kzT8GbdnxQt

## Starting a fresh regtest (i.e. ~/.bitcoin/regtest/ previously deleted)
$ bitcoind -daemon -regtest
Bitcoin server starting

## Import the address with a label and no rescan
$ bitcoin-cli -regtest importaddress $ADDRESS "Watch-only test" false

## Mine a generation tx to the address (regular spending works too)
$ bitcoin-cli -regtest generatetoaddress 1 $ADDRESS > /dev/null

## Bury the generation tx so it shows up in the wallet
$ bitcoin-cli -regtest generate 100 > /dev/null

## See that the address label was applied to the tx
$ bitcoin-cli -regtest listunspent | jq .[].label
"Watch-only test"

## Import the private key.  Note the 'label' parameter is not explicitly passed
$ bitcoin-cli -regtest importprivkey $PRIVKEY

## See that the address label has been set to empty :-(
$ bitcoin-cli -regtest listunspent | jq .[].label

Same thing happens if importpubkey is substituted for importaddress. I haven't tested importmulti for either address/pubkey or privkey import, nor have I tested using named parameters.

Use case

I was watching-only addresses from my cold wallet, then moved my coins to new addresses and (after some confirmations) imported the old private keys so that I could sell fork coins. I didn't realize until now when I was trying to do some bookkeeping that all my old cold wallet labels were reset (happily, I have backups, so nothing is lost but time).

Possibly related issues

@promag
Copy link
Contributor

promag commented Jun 1, 2018

IIUC this is the intended behaviour:

importprivkey "privkey" ( "label" ) ( rescan )
...
2. "label"            (string, optional, default="") An optional label

Are you suggesting to change the default behaviour: default=current label if watch only address otherwise ""?

@harding
Copy link
Contributor Author

harding commented Jun 2, 2018

@promag that's a good argument for it being the intended behavior, so perhaps this should be considered a feature request rather than a bug. However, it does seem undesirable to me for key import to destroy possibly-important metadata previously entered by the user.

@promag
Copy link
Contributor

promag commented Jun 2, 2018

Yes, either way it should have a way to preserve the current label.

@marcoagner
Copy link

I'm trying to address this on #13381
Could you, please, check if the approach seems reasonable and the behavior is an improvement for the expected use case? Thanks.

jonasschnelli added a commit that referenced this issue Nov 13, 2018
…ivkey

a6b5ec1 rpc: creates possibility to preserve labels on importprivkey (marcoagner)

Pull request description:

  Closes #13087.

  As discussed in the issue, this is a feature request instead of a bug report since the behaviour was as intended (i.e. label with default: `''`). With this, the old behaviour is kept while the possibility to achieve the preservation of labels, as expected in the open issue, is added.

Tree-SHA512: b33be50e1e7f62f7ddfae953177ba0926e2d848961f9fac7501c2b513322c0cb95787745d07d137488267bad1104ecfdbe800c6747f94162eb07c976835c1386
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Munkybooty pushed a commit to Munkybooty/dash that referenced this issue Jan 26, 2022
…mportprivkey

a6b5ec1 rpc: creates possibility to preserve labels on importprivkey (marcoagner)

Pull request description:

  Closes bitcoin#13087.

  As discussed in the issue, this is a feature request instead of a bug report since the behaviour was as intended (i.e. label with default: `''`). With this, the old behaviour is kept while the possibility to achieve the preservation of labels, as expected in the open issue, is added.

Tree-SHA512: b33be50e1e7f62f7ddfae953177ba0926e2d848961f9fac7501c2b513322c0cb95787745d07d137488267bad1104ecfdbe800c6747f94162eb07c976835c1386
Munkybooty pushed a commit to Munkybooty/dash that referenced this issue Feb 4, 2022
…mportprivkey

a6b5ec1 rpc: creates possibility to preserve labels on importprivkey (marcoagner)

Pull request description:

  Closes bitcoin#13087.

  As discussed in the issue, this is a feature request instead of a bug report since the behaviour was as intended (i.e. label with default: `''`). With this, the old behaviour is kept while the possibility to achieve the preservation of labels, as expected in the open issue, is added.

Tree-SHA512: b33be50e1e7f62f7ddfae953177ba0926e2d848961f9fac7501c2b513322c0cb95787745d07d137488267bad1104ecfdbe800c6747f94162eb07c976835c1386
Munkybooty pushed a commit to Munkybooty/dash that referenced this issue Feb 24, 2022
…mportprivkey

a6b5ec1 rpc: creates possibility to preserve labels on importprivkey (marcoagner)

Pull request description:

  Closes bitcoin#13087.

  As discussed in the issue, this is a feature request instead of a bug report since the behaviour was as intended (i.e. label with default: `''`). With this, the old behaviour is kept while the possibility to achieve the preservation of labels, as expected in the open issue, is added.

Tree-SHA512: b33be50e1e7f62f7ddfae953177ba0926e2d848961f9fac7501c2b513322c0cb95787745d07d137488267bad1104ecfdbe800c6747f94162eb07c976835c1386
Munkybooty pushed a commit to Munkybooty/dash that referenced this issue Mar 6, 2022
…mportprivkey

a6b5ec1 rpc: creates possibility to preserve labels on importprivkey (marcoagner)

Pull request description:

  Closes bitcoin#13087.

  As discussed in the issue, this is a feature request instead of a bug report since the behaviour was as intended (i.e. label with default: `''`). With this, the old behaviour is kept while the possibility to achieve the preservation of labels, as expected in the open issue, is added.

Tree-SHA512: b33be50e1e7f62f7ddfae953177ba0926e2d848961f9fac7501c2b513322c0cb95787745d07d137488267bad1104ecfdbe800c6747f94162eb07c976835c1386
Munkybooty pushed a commit to Munkybooty/dash that referenced this issue Mar 8, 2022
…mportprivkey

a6b5ec1 rpc: creates possibility to preserve labels on importprivkey (marcoagner)

Pull request description:

  Closes bitcoin#13087.

  As discussed in the issue, this is a feature request instead of a bug report since the behaviour was as intended (i.e. label with default: `''`). With this, the old behaviour is kept while the possibility to achieve the preservation of labels, as expected in the open issue, is added.

Tree-SHA512: b33be50e1e7f62f7ddfae953177ba0926e2d848961f9fac7501c2b513322c0cb95787745d07d137488267bad1104ecfdbe800c6747f94162eb07c976835c1386
gades pushed a commit to cosanta/cosanta-core that referenced this issue Dec 1, 2023
…mportprivkey

a6b5ec1 rpc: creates possibility to preserve labels on importprivkey (marcoagner)

Pull request description:

  Closes bitcoin#13087.

  As discussed in the issue, this is a feature request instead of a bug report since the behaviour was as intended (i.e. label with default: `''`). With this, the old behaviour is kept while the possibility to achieve the preservation of labels, as expected in the open issue, is added.

Tree-SHA512: b33be50e1e7f62f7ddfae953177ba0926e2d848961f9fac7501c2b513322c0cb95787745d07d137488267bad1104ecfdbe800c6747f94162eb07c976835c1386
gades pushed a commit to piratecash/pirate that referenced this issue Dec 9, 2023
…mportprivkey

a6b5ec1 rpc: creates possibility to preserve labels on importprivkey (marcoagner)

Pull request description:

  Closes bitcoin#13087.

  As discussed in the issue, this is a feature request instead of a bug report since the behaviour was as intended (i.e. label with default: `''`). With this, the old behaviour is kept while the possibility to achieve the preservation of labels, as expected in the open issue, is added.

Tree-SHA512: b33be50e1e7f62f7ddfae953177ba0926e2d848961f9fac7501c2b513322c0cb95787745d07d137488267bad1104ecfdbe800c6747f94162eb07c976835c1386
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants