1

I've created two addresses using the nodejs javascript library 'bitcoinjs-lib' version 5.2.0. In both cases if I enter them into blockchain.com, they show a zero balance with zero transactions. I would expect no result to come back at all, and if I change one character in the middle of the address I get what I would have expected from the beginning, 'no address found'. Is this library compromised?

Code snippet for the curious:

 const bitcoin = require('bitcoinjs-lib');

// Generate a new key pair
const keyPair = bitcoin.ECPair.makeRandom();
const privateKey = keyPair.toWIF();
const { address } = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey });

console.log('Private Key:', privateKey);
console.log('Address:', address);
Murch
  • 71,155
  • 33
  • 180
  • 600
nunya07
  • 11
  • 2
  • I’ve voted to close this question as a duplicate, because the other one is asking about exactly the same conundrum but is older, has a more speaking title, and has more comprehensive answers. – Murch Aug 22 '23 at 12:27

1 Answers1

2

When you generate an address offline, it will be a valid (= correct checksum) address, which you have the private key to.

If you enter that address in a block explorer, it'll notice it's a valid address, search its database for transactions, not find any, and tell you so. It doesn't know or care whether anyone has the private key to this address, all it knows is the address is valid, and is not involved in any transactions.

If you change a character in the address, it becomes invalid (you've invalidated its checksum), which the block explorer can detect and tell you.

Pieter Wuille
  • 98,249
  • 9
  • 183
  • 287