Does bitcoind store timestamp at which private key was imported?

1

2

If we import a private key using bitcoin-cli importprivkey <key>, is there anyway to find out when the import was done?

I am hoping a timestamp is included.

Jus12

Posted 2019-01-21T03:58:01.237

Reputation: 1 243

Answers

1

No, bitcoind does not. bitcoind does store a timestamp for keys however this timestamp is used to determine when to start rescanning. importprivkey does not allow you to specify this timestamp, so in order to be sure to not miss any transactions, the timestamp is set to 1 indicating that the entire blockchain will be rescanned.

The importmulti command allows you to specify the timestamp which by default is the time at which you imported the key. However, as mentioned earlier, since the timestamp is needed for rescanning, if it is not set to be early enough, the automatic rescan done at import time will not catch all of the transactions the key is involved in.

If you want to see the timestamps, you can use getaddressinfo to get the information for the address corresponding to the private key you imported. getaddressinfo will give you the timestamp in unix time.

Andrew Chow

Posted 2019-01-21T03:58:01.237

Reputation: 40 910

We can assume address was added at the time of private key import.. Will it tell me how to get that timestamp? Even if there is no command, I can write my own parser for wallet.dat outside of bitcoind, as long as the data is stored.Jus12 2019-01-21T06:39:40.810

As I said, the timestamp that it stores is not the timestamp of the import. The timestamp of the import is not stored, only the key "birthdate" is stored, and that depends on the import call used and what you specified in the import. It might be the timestamp of the import if you used importmulti.Andrew Chow 2019-01-21T06:48:14.987

It was a fresh wallet and I had used importprivkey. What about the timestamp of the corresponding address that I get from getaddressinfo? Will that be approximately equal to the timestamp (Unix time) of the private key import?Jus12 2019-01-21T12:35:04.517

No, it will not. There is only one timestamp that is stored for each key (and thus address). That timestamp is the same one I described in my answer and comments.Andrew Chow 2019-01-21T17:42:44.427