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 27, 2018 in Blockchain by sabby
• 4,370 points
645 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

answered Aug 27, 2018 by Perry
• 17,090 points

Related Questions In Blockchain

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,600 points
66 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,600 points
54 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,240 points
913 views
+2 votes
1 answer
+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,600 points
5,175 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,600 points
63 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,240 points
66 views
0 votes
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,090 points
92 views