Closed digitalik closed 5 years ago
got it. it is not possible to get address from pubkey
I'm also having the same problem. I didn't get this. How come we can't get address from pubkey? Address is calculated from pubkey right?
Blockchain shows address for the same tx: https://www.blockchain.com/btc/tx/0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098
But this program gives out empty...
I'm also having the same problem. I didn't get this. How come we can't get address from pubkey? Address is calculated from pubkey right?
Blockchain shows address for the same tx: https://www.blockchain.com/btc/tx/0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098
But this program gives out empty...
An address is calculated from a public key, but an address actually indicates a specific type of locking script, so it's not just an encoding of the public key.
For example, the address 1AdNarz1b5Dckx31xVmwQQqVk4uUWbZRtj
corresponds to the following P2PKH locking script:
OP_DUP OP_HASH160 699a1fbaff30ec1231bfe9bdd1ea227d02bf7095 OP_EQUALVERIFY OP_CHECKSIG
So if you look at a P2PK locking script, even though it has a public key inside it, it wouldn't be accurate to return an address for it because that would be indicating a P2PKH locking script.
Nonetheless, it seems that some blockchain explorers (e.g. blockchain.info) actually allow you to search for the "addresses" of these P2PK locking scripts (even thought they don't technically have one).
Seeing as this might be useful, I've added an option to the script to return the corresponding "address" for the public key inside P2PK locking scripts:
$ bitcoin-utxo-dump -p2pkaddresses
This might be useful for working with other APIs, but it's important to remember that P2PK locking scripts do not have addresses.
Hope this helps.
Take a look at tx 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098 (block 1). All elements are there except address:
[root@tmp-1-fra bin]# cat utxodump.csv | grep 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098 36012933,0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098,0,5000000000,p2pk, [root@tmp-1-fra bin]#