Author

Topic: How to generate Bitcoin-addressess with PHP? (Read 1300 times)

newbie
Activity: 4
Merit: 0
December 05, 2015, 12:35:02 PM
#9
 Smiley

Thanks for all the good advices! Thanks!
I got some pretty good codes now. I'll be soon back with more questions (be prepared!) - as soon as I get thru all this stuff  Smiley
legendary
Activity: 1344
Merit: 1024
Mine at Jonny's Pool
December 03, 2015, 05:00:03 PM
#8
If you want to create fresh btc addresses (in bulk) you can use bitcoin core (Without syncing).
on the bitcoin.conf file just add this:
keypoolsize=10000
this will create 10k btc addresses.

Sounds great. Thank you very much!
But where is "bitcoin.conf"? I'm running a Bitcoin Core on OSX... Sorry, I'm not good on these things  Roll Eyes


then you can dump this wallet and get these 10k address & priv keys.
I get that, thanks, but what do you mean with "...& priv keys"?
To answer your earlier question... bitcoin daemon is just the bitcoin process (to start it in linux you type: bitcoind).  Since you're on a Mac, I can certainly help you there Smiley.  By default using the Bitcoin application on a Mac does not create a bitcoin.conf file.  You create your own.  When you first start up your Bitcoin application (assuming of course the standard Bitcoin Core software downloaded from bitcoin.org), it creates a directory here:
Code:
~/Library/Application Support/Bitcoin
It is in that directory that you want to create the bitcoin.conf file.
legendary
Activity: 1274
Merit: 1000
★ BitClave ICO: 15/09/17 ★
December 03, 2015, 12:49:59 PM
#7
If you want to create fresh btc addresses (in bulk) you can use bitcoin core (Without syncing).
on the bitcoin.conf file just add this:
keypoolsize=10000
this will create 10k btc addresses.

Sounds great. Thank you very much!
But where is "bitcoin.conf"? I'm running a Bitcoin Core on OSX... Sorry, I'm not good on these things  Roll Eyes


then you can dump this wallet and get these 10k address & priv keys.
I get that, thanks, but what do you mean with "...& priv keys"?
Sorry I use windows, don't know Mac, but you can find it here:
https://en.bitcoin.it/wiki/Running_Bitcoin#Bitcoin.conf_Configuration_File

I need to correct something. it's not keypoolsiz, it's "keypool=10000"

When you dump your wallet it gives you all the created bitcoin addresses and private keys;
For instance:
Code:
#this dump created on the date 03.12.2015
1address1 5privatekey
1address2 5privkey2
1adddres3 5privkey3

Make sure that you import only the public addresses. You should keep the private keys private.
newbie
Activity: 4
Merit: 0
December 03, 2015, 11:37:06 AM
#6
If you want to create fresh btc addresses (in bulk) you can use bitcoin core (Without syncing).
on the bitcoin.conf file just add this:
keypoolsize=10000
this will create 10k btc addresses.

Sounds great. Thank you very much!
But where is "bitcoin.conf"? I'm running a Bitcoin Core on OSX... Sorry, I'm not good on these things  Roll Eyes


then you can dump this wallet and get these 10k address & priv keys.
I get that, thanks, but what do you mean with "...& priv keys"?
legendary
Activity: 1274
Merit: 1000
★ BitClave ICO: 15/09/17 ★
December 03, 2015, 11:08:53 AM
#5
If you want to create fresh btc addresses (in bulk) you can use bitcoin core (Without syncing).
on the bitcoin.conf file just add this:
keypoolsize=10000

this will create 10k btc addresses. then you can dump this wallet and get these 10k address & priv keys.
newbie
Activity: 4
Merit: 0
December 03, 2015, 11:04:39 AM
#4
Thank you for the answers. Thanks!

Creating the addresses in advance with my Electrum wallet is not impossble but kind of - somhow - not so fancy... Propably I have to do it like that. First creating 50,000 addresses, then copy them half-manually to MySQL and >boom!< it works  Grin

Have your website make a call back to your bitcoin daemon to get a new address.

Allright, I don't have the slightest clue what "bitcoin daemon" is  Huh

If found this -> https://github.com/Bit-Wasp/bitcoin-lib-php and it should be able to create addresses from the BIP32 MPK. Unfortunatelly it's way too complicated for me now. Have to do some toughtfull reading.

I can't believe it is this hard to create addresses with PHP from BIP32! Big obstacle for me and many others, heh hee. I wish I hade a 64base MPK and could forget all this.
legendary
Activity: 1344
Merit: 1024
Mine at Jonny's Pool
December 03, 2015, 10:32:42 AM
#3
Have your website make a call back to your bitcoin daemon to get a new address.  If you want to keep track of your customers (i.e. they've logged in and you know their user name) you can make a call like this:
Code:
$bitcoin->getnewaddress($username);
legendary
Activity: 4228
Merit: 1313
December 03, 2015, 10:19:03 AM
#2
One option is to just generate them in bulk - e.g. 50000 at a time on a different computer with bitcoin core or something - and then just reference the public keys from php.  Marking them as used as you go along (so you don't reuse them).   This also avoid exposing the private key to a web connected machine which could be considered a security risk.

You can also use bitcoin core as a backend and generate them there using php.  

It is difficult to code your own correctly due to the ease of introducing bugs (e.g. in the PRNG or elsewhere).  Sometimes it is more efficient and safer to use code that has been well tested.
newbie
Activity: 4
Merit: 0
December 03, 2015, 09:56:15 AM
#1
Hello Everyone  Smiley

I'm a total newbie with Bitcoin so forgive me if I'm asking stupid things. All help needed!

My plan is to implement a way to pay with Bitcoins in my webshop.
My problem is to generate bitcoin-adresses with PHP. How should I do that?

I already managed to use addrgen.php (from https://github.com/prusnak/addrgen) but that needs a MPK in 64base. When I use Electrum or Bitcoin Core I do not have an 64base MPK, I have something else like this, these are examples:

Example (Electrum): xpub662MyMwAqRbcH1h5aJpdem6aJ4CVaWaab2vC8tv25aJpdeyKKsBpfeBPJjLwHdqcsxdHnVc4A9X aUDvfBzhfKJwYAaNTEHyTviwjwP2nCt2
or example (Bitcoin Core): L4zMahdeJLLsYNenP5XN9baV5bYKB2aiF9tTeHWrsYNenP9zBQGR


Any ideas how to:
 a) convert Electrum or Bitcoin Core private keys to 64base so that I can use this addrgen.php?
 b) some other PHP code sample that I can modify to produce limitless Bitcoin-adresses?
 c) some other idea?

All hints and ideas are welcome!
BIG thanks in advance!
Jump to: