2

calling bitcoin-cli dumpwallet returns wallet private keys and addresses.

Example

L34D2hAS9KBJQzJkHtmNt1bdSJ18cQUvfSnJEqPKH2oUj6sBxvXt 2017-11-23T05:11:13Z reserve=1 # addr=1D2mnuj9qeRAzmw8mjLDciyvqzQiiYZCfE hdkeypath=m/0'/0'/1030'

Importing this private key to wallet using importprivkey command returns null on success.

How to get bitcoin address related to this private key? or is there's any way get this private key details like balance or addresses?

2
  • You could use an online wallet like blockchain.info/wallet/#.
    – l1b3rty
    Commented Nov 28, 2017 at 10:20
  • Thanks but i'm looking for a solution on bitcoin-core. if you got any idea how blockchain is getting these info it would be great.
    – Tailer
    Commented Nov 28, 2017 at 11:20

2 Answers 2

2

the private key is a Private Key WIF Compressed, 52 characters base58, and can be used to convert into (compressed or uncompressed) public keys. These pub keys are usually hex codes, and can be converted into bitcoin addresses: 1D2mnuj9qeRAzmw8mjLDciyvqzQiiYZCfE and 1KWvNZB4Gf2Kars88aGR2cedUb81Q6gZKC. There is no easy way I am aware of to do this in bitcoin client.

Looking at the line you provided, the bitcoin address is behind the comment sign (#), and is part of a HD key, which complicates things even more, if I had to explain it. To understand the whole idea behind keys, you may want to read bitcoin.org or the book af Andreas "Mastering Bitcoin" (online available).

Looking then at e.g. blockchain.info, you can provide the addresses or the keys, and see that there is no value.

Hint: never ever (!) use this key again to transfer values. It has been disclosed, and people are only waiting to snipe the values from this address! - me too :-)

5
  • So is it possible to generate more than one address using same private key?
    – Tailer
    Commented Nov 28, 2017 at 12:12
  • yes. A priv key alone can already generate two pubkeys (compressed and uncompressed). And HD wallets: just a short extract from the book: "HD wallets contain keys derived in a tree structure, such that a parent key can derive a sequence of children keys, each of which can derive a sequence of grandchildren keys, and so on, to an infinite depth". Commented Nov 28, 2017 at 12:17
  • Thanks for your answer, I would be happy to get this book!
    – Tailer
    Commented Nov 28, 2017 at 12:20
  • here: chimera.labs.oreilly.com/books/1234000001802 and there is somewhere already the second edition (don't have the link ...) Commented Nov 28, 2017 at 12:20
  • unglueit-files.s3.amazonaws.com/ebf/…
    – Tailer
    Commented Nov 28, 2017 at 12:34
0

using PHP and Bitcoin-PHP library, we can do the following to get Bitcoin address of any private key:

        try {
            $master = PrivateKeyFactory::fromWif($key);
        } catch (\Exception $e) {
            echo "Invalid Address";
        }

        $BitcoinAddress = $master->getPublicKey()->getAddress()->getAddress();

        echo $BitcoinAddress;

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