Bitcoin Forum
May 04, 2024, 08:45:31 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to generate Bitcoin-addressess with PHP?  (Read 1279 times)
flydrones (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
December 03, 2015, 02:56:15 PM
 #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!
1714812331
Hero Member
*
Offline Offline

Posts: 1714812331

View Profile Personal Message (Offline)

Ignore
1714812331
Reply with quote  #2

1714812331
Report to moderator
1714812331
Hero Member
*
Offline Offline

Posts: 1714812331

View Profile Personal Message (Offline)

Ignore
1714812331
Reply with quote  #2

1714812331
Report to moderator
1714812331
Hero Member
*
Offline Offline

Posts: 1714812331

View Profile Personal Message (Offline)

Ignore
1714812331
Reply with quote  #2

1714812331
Report to moderator
No Gods or Kings. Only Bitcoin
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714812331
Hero Member
*
Offline Offline

Posts: 1714812331

View Profile Personal Message (Offline)

Ignore
1714812331
Reply with quote  #2

1714812331
Report to moderator
1714812331
Hero Member
*
Offline Offline

Posts: 1714812331

View Profile Personal Message (Offline)

Ignore
1714812331
Reply with quote  #2

1714812331
Report to moderator
cr1776
Legendary
*
Offline Offline

Activity: 4032
Merit: 1299


View Profile
December 03, 2015, 03:19:03 PM
 #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.
jonnybravo0311
Legendary
*
Offline Offline

Activity: 1344
Merit: 1023


Mine at Jonny's Pool


View Profile WWW
December 03, 2015, 03:32:42 PM
 #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);

Jonny's Pool - Mine with us and help us grow!  Support a pool that supports Bitcoin, not a hardware manufacturer's pockets!  No SPV cheats.  No empty blocks.
flydrones (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
December 03, 2015, 04:04:39 PM
 #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.
cakir
Legendary
*
Offline Offline

Activity: 1274
Merit: 1000


★ BitClave ICO: 15/09/17 ★


View Profile WWW
December 03, 2015, 04:08:53 PM
 #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.


                  ,'#██+:                 
              ,█████████████'             
            +██████████████████           
          ;██████████████████████         
         ███████:         .███████`       
        ██████               ;█████'      
      `█████                   #████#     
      ████+                     `████+    
     ████:                        ████,   
    ████:    .#              █     ████   
   ;███+     ██             ███     ████  
   ████     ███'            ███.    '███, 
  +███     #████           ,████     ████ 
  ████     █████ .+██████: █████+    `███.
 ,███     ███████████████████████     ████
 ████     ███████████████████████'    :███
 ███:    +████████████████████████     ███`
 ███     █████████████████████████`    ███+
,███     ██████████████████████████    #███
'███    '██████████████████████████    ;███
#███    ███████████████████████████    ,███
████    ███████████████████████████.   .███
████    ███████████████████████████'   .███
+███    ███████████████████████████+   :███
:███    ███████████████████████████'   +███
 ███    ███████████████████████████.   ███#
 ███.   #██████████████████████████    ███,
 ████    █████████████████████████+   `███
 '███    '████████████████████████    ████
  ███;    ███████████████████████     ███;
  ████     #████████████████████     ████ 
   ███#     .██████████████████     `███+ 
   ████`      ;██████████████       ████  
    ████         '███████#.        ████.  
    .████                         █████   
     '████                       █████    
      #████'                    █████     
       +█████`                ██████      
        ,██████:           `███████       
          ████████#;,..:+████████.        
           ,███████████████████+          
             .███████████████;            
                `+███████#,               
flydrones (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
December 03, 2015, 04:37:06 PM
 #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"?
cakir
Legendary
*
Offline Offline

Activity: 1274
Merit: 1000


★ BitClave ICO: 15/09/17 ★


View Profile WWW
December 03, 2015, 05: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.


                  ,'#██+:                 
              ,█████████████'             
            +██████████████████           
          ;██████████████████████         
         ███████:         .███████`       
        ██████               ;█████'      
      `█████                   #████#     
      ████+                     `████+    
     ████:                        ████,   
    ████:    .#              █     ████   
   ;███+     ██             ███     ████  
   ████     ███'            ███.    '███, 
  +███     #████           ,████     ████ 
  ████     █████ .+██████: █████+    `███.
 ,███     ███████████████████████     ████
 ████     ███████████████████████'    :███
 ███:    +████████████████████████     ███`
 ███     █████████████████████████`    ███+
,███     ██████████████████████████    #███
'███    '██████████████████████████    ;███
#███    ███████████████████████████    ,███
████    ███████████████████████████.   .███
████    ███████████████████████████'   .███
+███    ███████████████████████████+   :███
:███    ███████████████████████████'   +███
 ███    ███████████████████████████.   ███#
 ███.   #██████████████████████████    ███,
 ████    █████████████████████████+   `███
 '███    '████████████████████████    ████
  ███;    ███████████████████████     ███;
  ████     #████████████████████     ████ 
   ███#     .██████████████████     `███+ 
   ████`      ;██████████████       ████  
    ████         '███████#.        ████.  
    .████                         █████   
     '████                       █████    
      #████'                    █████     
       +█████`                ██████      
        ,██████:           `███████       
          ████████#;,..:+████████.        
           ,███████████████████+          
             .███████████████;            
                `+███████#,               
jonnybravo0311
Legendary
*
Offline Offline

Activity: 1344
Merit: 1023


Mine at Jonny's Pool


View Profile WWW
December 03, 2015, 10: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.

Jonny's Pool - Mine with us and help us grow!  Support a pool that supports Bitcoin, not a hardware manufacturer's pockets!  No SPV cheats.  No empty blocks.
flydrones (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
December 05, 2015, 05: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
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!