0

Using importprvkey, I imported all the private keys of an Electrum wallet into a Bitcoin Core wallet (courtesy the electrum2core script; 🎩-tip: somedude). Then, in Electrum, I created a new bech32 receiving address and sent funds to it. This address then appeared in the Bitcoin Core wallet, despite my not having run an importprvkey for this address's private key.

How did the Bitcoin Core wallet know about this address?

I spent from this address using Electrum. Could've I spent from it using Bitcoin Core, or not, because I don't have its corresponding private key in Bitcoin Core?


Running getaddressinfo on the address returns

"solvable": true,

help getaddressinfo:

"solvable" : true|false,          (boolean) If we know how to spend coins sent to this address, ignoring the possible lack of private keys.

Could've I spent from that address, "ignoring the possible lack of private keys"?

1 Answer 1

1

Modern wallets will pre-generate a lot of keys instead of generating them when you ask for them. For example, you might have used 10 addresses from your wallet, but your wallet actually has 110 addresses because it pre-generated 100 of them. When you ask for a new address, it gives you the oldest one it has pre-generated, and schedules to have a replacement for that address to be generated and added to the lookahead pool at a later time.

This serves two functions. When restoring a backup, your backup may be out of date and you may have used some of the pre-generated addresses. With the pre-generated addresses, your wallet can scan the blockchain for those addresses and be able to see all of your funds.

The second is when the private keys are encrypted. When a new key is generated, it will need to be encrypted, and so your passphrase will need to be provided. With the pre-generated lookahead pool, your wallet can retrieve a pre-generated address and provide it to you without needing to enter your passphrase. Then the next time you enter your passphrase, the lookahead pool can be topped up.

With that in mind, what happened is that exporting your private keys from Electrum also exported all of the keys that are in the pre-generated lookahead pool. These were then imported to Bitcoin Core. When you asked for a new address, an address was taken from the lookahead and so Bitcoin Core was able to see the transaction because the entire lookahead was imported. If you had imported private keys, you would have been able to spend those funds.

If you keep requesting addresses from Electrum, eventually you will reach a point where the lookahead at the time of your import to Bitcoin Core is exhausted and you will start getting addresses which Bitcoin Core does not know about.

1
  • That makes sense. There were about 100 of them; I didn't ask for 100 addresses, so Electrum must've pre-generated them.
    – Geremia
    May 4 at 3:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.