Author

Topic: [PHP] How to get the address from a private key? (Read 1272 times)

hero member
Activity: 699
Merit: 501
sr. member
Activity: 475
Merit: 254
How can I calculate the public address if I only have the private key with PHP only?

For example I have
5K2YUVmWfxbmvsNxCsfvArXdGXm7d5DC9pn4yD75k2UaSYgkXTh
and want
1HKqKTMpBTZZ8H5zcqYEWYBaaWELrDEXeE

Does anyone have a working PHP code without using bitcoind or any other API/tools?


5K2YUVmWfxbmvsNxCsfvArXdGXm7d5DC9pn4yD75k2UaSYgkXTh
          vvvvvvvvvvvvv
https://github.com/Bit-Wasp/bitcoin-lib-php/blob/master/src/BitcoinLib.php#L568
          vvvvvvvvvvvvv
https://github.com/Bit-Wasp/bitcoin-lib-php/blob/master/src/BitcoinLib.php#L430
          vvvvvvvvvvvvv
https://github.com/Bit-Wasp/bitcoin-lib-php/blob/master/src/BitcoinLib.php#L389
          vvvvvvvvvvvvv
1HKqKTMpBTZZ8H5zcqYEWYBaaWELrDEXeE
hero member
Activity: 854
Merit: 503
|| Web developer ||
Well you can use a ready PHP library to do this , I didn't ever saw how it work and how Bitcoin address are hashed !
You can check this library and you will probably understand how it work and make your own ` easy code ` .

https://github.com/Bit-Wasp/bitcoin-lib-php


Kind Of Respect ,
Bitcoin Boy .
full member
Activity: 124
Merit: 100
Hello, alex1s,

We had almost the same issue and we used the following answer on stackoverflow
http://stackoverflow.com/questions/19233053/hashing-from-a-public-key-to-a-bitcoin-address-in-php

However we do not know its behaviour in a case of multiple senders. For example if you need to retrieve the addresses of those, who sent you some coins, f.ex using walletnotify.
legendary
Activity: 3248
Merit: 1072
legendary
Activity: 1442
Merit: 1189
A lot will depend on what PHP extensions you have installed on your server. If you're on shared hosting (like many are) your hosting provider controls what version of PHP is ran and which extensions. Echo out phpinfo(); to see what you have installed. Ones that I have seen you'll need bcrypt, bmath, and an ECC library as well. So I usually just end up using a 3rd party API to do key generation.

Maybe give this one a try, it doesn't have many requirements.

https://github.com/BitcoinPHP/BitcoinECDSA.php

hero member
Activity: 714
Merit: 500
How can I calculate the public address if I only have the private key with PHP only?

For example I have
5K2YUVmWfxbmvsNxCsfvArXdGXm7d5DC9pn4yD75k2UaSYgkXTh
and want
1HKqKTMpBTZZ8H5zcqYEWYBaaWELrDEXeE

Does anyone have a working PHP code without using bitcoind or any other API/tools?


Maybe try this source on gitHub: https://github.com/RobKohr/PHP-Bitcoin-Address-Creator  or http://gobittest.appspot.com/Address
legendary
Activity: 4298
Merit: 1317
It really depends on what you are asking, but this may be useful:
https://bitcointalksearch.org/topic/php-library-1008030


legendary
Activity: 1120
Merit: 1002
How can I calculate the public address if I only have the private key with PHP only?

For example I have
5K2YUVmWfxbmvsNxCsfvArXdGXm7d5DC9pn4yD75k2UaSYgkXTh
and want
1HKqKTMpBTZZ8H5zcqYEWYBaaWELrDEXeE

Does anyone have a working PHP code without using bitcoind or any other API/tools?

just  import the private key into your wallet , and you've got the public key.
newbie
Activity: 1
Merit: 0
How can I calculate the public address if I only have the private key with PHP only?

For example I have
5K2YUVmWfxbmvsNxCsfvArXdGXm7d5DC9pn4yD75k2UaSYgkXTh
and want
1HKqKTMpBTZZ8H5zcqYEWYBaaWELrDEXeE

Does anyone have a working PHP code without using bitcoind or any other API/tools?
Jump to: