How to create Bitcoin Address in PHP

0 votes

I would like to generate a Bitcoin-address (public/private key) in PHP but I don't understand the parameters. For example in the below lines of code:

$mpk = '675b7041a347223984750fe3ab229df0c9f960e7ec98226b7182a2cb1990e39901feecf5a670f1d788ab29f626e20de424f049d216fc6f4c6ec42506763fa28e';

for ($i = 0; $i < 10; $i++) {
    print addr_from_mpk($mpk, $i) . "\n";
}

 Is $mpk the private key? If I change a single char in $mpk, I get an error.

Is there a working way to generate a Bitcoin-Address in PHP?

Aug 28, 2018 in Blockchain by sabby
• 4,390 points
5,073 views

1 answer to this question.

0 votes

You need to understand that Bitcoin address and public/private key are not the same. Address is basically a representation of your public key. In your code $mpk is a master public key. You do not need an mpk to make a bitcoin address. An MPK is for a deterministic wallet, and is a serialized [x, y] point. So you will get an error if you pass a point that's not on the curve.

You could refer to the following PHP code that has created key-pair the right way:  https://github.com/RobKohr/PHP-Bitcoin-Address-Creator

Hope it helps!

Join our Blockchain course today to learn more about it.

Thanks.

answered Aug 28, 2018 by Perry
• 17,100 points

Related Questions In Blockchain

0 votes
0 answers

hd wallet bip44 in js - how to create an address for a chain other than bitcoin?

I have a small script basically taken ...READ MORE

Mar 2, 2022 in Blockchain by Aditya
• 7,680 points
839 views
0 votes
1 answer

How to create address in BitcoinLib.

Regarding this specific library and assuming that ...READ MORE

answered Aug 21, 2018 in Blockchain by digger
• 26,740 points
921 views
0 votes
1 answer

How to use bitcoin price as place holder in php?

You can do it by providing an ...READ MORE

answered Aug 21, 2018 in Blockchain by digger
• 26,740 points
543 views
0 votes
1 answer

How to generate Bitcoin address in Ruby?

In your generate_address_from_public_key_hash method, the checksum should be over ...READ MORE

answered Aug 22, 2018 in Blockchain by slayer
• 29,350 points
2,323 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,740 points
44,013 views
0 votes
1 answer

How to get current value of bitcoin?

You can use json_decode to transform it ...READ MORE

answered Aug 20, 2018 in Blockchain by digger
• 26,740 points
582 views
0 votes
1 answer

Cant make transactions in bitcoind.

Fist you should encrypt your wallet: bitcoin-cli encryptwallet ...READ MORE

answered Aug 23, 2018 in Blockchain by slayer
• 29,350 points
547 views
+1 vote
1 answer

Is there a way to send funds from a specific bitcoin address in a wallet?

I'll answer my own question, It was unbelievably ...READ MORE

answered Sep 3, 2018 in Blockchain by Perry
• 17,100 points
1,247 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP