3

I'm currently running bitcoind -testnet. I ran bitcoin-cli dumpwallet ~/wallet-output just to explore the output and it looks like it created 102 private/public key pairs that I assume are just sort of pre-generated just for the convenience of having them on hand.

However, I'm surprised they all seem to be somehow "recognized" as part of the testnet blockchain already, even though they've never been used. For example, when I search for one of these addresses in Block Explorer I see an address with zero transactions and a 0 BTC balance: https://testnet.blockexplorer.com/address/mxwDTWg556BDzZhEWvJ1EeYwSYxG42wKZC. This is different from addresses I've created "outside" of the bitcoin tools (e.g., https://www.bitaddress.org). For example, Block Explorer "can't find" this address: 1XitCFAkFhNR6PoJsPcxjsFzkMegx4Ky5. I would expect that to happen to all of the addresses pre-generated in my wallet until I actually use them.

Why did bitcoind "register" these addresses on the testnet blockchain? And how exactly did it do that? Is that a special transaction type?

  • Could you please edit the answer part out of your question and post it as an answer instead? It shouldn't be in the question. – Murch Jul 15 '17 at 16:54
  • I rolled back to the previous revision, you can find your self-answer in the edit history. – Murch Jul 15 '17 at 17:23
1

Bitcoin doesn't "register" addresses on the blockchain. The reason I was having trouble looking up arbitrarily-generated public addresses on the testnet Block Explorer website is because I was searching for mainnet addresses, not testnet addresses. For example, addresses generated using the above https://bitaddress.org website are by default meant for mainnet, and are invalid on the testnet blockchain. If you use add ?testnet=true to the URL you will generate valid testnet addresses.

The exact differences between testnet and mainnet addresses are documented in numerous places online. Among them, the Testnet page on the Bitcoin wiki, which states:

A different value of ADDRESSVERSION field ensures no testnet Bitcoin addresses will work on the production network. (0x6F rather than 0x00)

0

Addresses are not registered. You don't register addresses on the blockchain. How addresses work is that they correspond to the hash of a public key. Since all possible public keys and all possible hashes of those are known, you can look up the "balance" of any arbitrary address. It's quite simple since all transactions are known, so you can easily tell if an address was used or not by looking at every transaction in the blockchain.

The vast majority of wallets do this as it is more efficient. It allows the wallet to give you an address easily when the wallet is locked. It also means that the wallet does not need to generate a new key every single time you want a new address as it pre-generates several keys (Bitcoin Core defaults to 100) and can then later batch generate more when needed.

  • The original reason for pregenerating keys was because of backups. It meant that you didn't need to create a new backup after every new key you generated, as your future 100 keys are already in the wallet file. This is partially mitigated now that we use HD derivation for keys in wallets. – Pieter Wuille Jul 15 '17 at 18:09

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.