Bitcoin Forum
November 11, 2024, 11:05:26 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: How do I generate Bitcoin addresses on my website? $$  (Read 2549 times)
b!z (OP)
Legendary
*
Offline Offline

Activity: 1582
Merit: 1010



View Profile
August 05, 2013, 08:24:16 AM
Last edit: August 05, 2013, 10:15:31 AM by b!z
 #1

I need an address for me to receive coins to be generated and displayed when a user clicks a button. That's it. I don't need QR codes or any fancy stuff. What's the easiest way to do so (with code examples, since I'm quite clueless)?

Will tip btc.
kseistrup
Hero Member
*****
Offline Offline

Activity: 566
Merit: 500


Unselfish actions pay back better


View Profile WWW
August 05, 2013, 08:30:36 AM
 #2

The code used on https://www.bitaddress.org/ can be downloaded from https://github.com/pointbiz/bitaddress.org

Klaus Alexander Seistrup
Kiwi7
Newbie
*
Offline Offline

Activity: 50
Merit: 0



View Profile
August 05, 2013, 08:37:56 AM
 #3

Or, you can install bitcoind on the server and:
<?php
echo exec("bitcoind getnewaddress");
?>
MA5H3D
Member
**
Offline Offline

Activity: 99
Merit: 10


View Profile
August 05, 2013, 09:39:38 AM
 #4

It kinda depends what you want the address for..

Kseistrup mentioned bitaddress, but that will generate the address clientside with javascript. That might be ok, but it's no good for generating payment addresses because the client can get the private key.

Kiwi17 recommended installing bitcoind, this might be a bit overkill for just generating addresses.

If you just want to generate addresses so that people can pay you, the best option would be to use a serverside script like "PHPCoinAddress". That generates addresses for almost all coins, so just rip out the code for the coins you don't need and you're ready to go. You might want to build on it a bit to generate QR codes, but there are loads of scripts for that on github.
https://github.com/zamgo/PHPCoinAddress
b!z (OP)
Legendary
*
Offline Offline

Activity: 1582
Merit: 1010



View Profile
August 05, 2013, 09:40:15 AM
 #5

Would it be easier to use the coinbase or blockchain api? I am not the ownerof the server so it might not be wise to run bitaddress or bitcoind. How can i use the apis.? Or is there a better way.
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1086


Ian Knowles - CIYAM Lead Developer


View Profile WWW
August 05, 2013, 09:48:36 AM
 #6

If you are not the owner of the server and can't be 100% of its security then you would not want to be generating key pairs on it and even APIs are going to be problematic in regards to keeping your "API keys" safe (although I think many APIs might have different keys for creating addresses vs. spending BTC so you should be fairly safe with those).

Another approach might be to generate 1000's of keypairs (or more depending upon the expected frequency of usage) from an offline computer using bitcoind or vanitygen and then import just the "public" keys of the key pairs into a DB (as a public key pool).

When the pool gets near to running out you would just replenish with more.

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
Cyberdyne
Hero Member
*****
Offline Offline

Activity: 630
Merit: 500



View Profile
August 05, 2013, 09:57:10 AM
Last edit: August 05, 2013, 11:27:10 AM by Cyberdyne
 #7

Maybe the OP was too specific in his wording when he said 'generate' and doesn't need to generate them on the fly, but rather, just display btc addresses to his customers.

In that case, pre-generating a list of addresses using bitaddress.org, and then loading those public addresses into a table on your server is a perfect solution. Then keep the private keys offline for later spending.

Incidentally this is how my kamikaze games have been set up - Players' deposits never get sent to the game server at any point.
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1086


Ian Knowles - CIYAM Lead Developer


View Profile WWW
August 05, 2013, 10:02:19 AM
 #8

In that case, pre-generating a list of addresses using bitaddress.org, and then loading those public addresses into a table on your server is a perfect solution. Then keep the private keys offline for later spending.

Yup - pretty much what I said - I think whether you would use bitaddress or vanitygen probably comes down to just how many addresses you want to generate (under 1000 probably bitaddress is easiest but over 10,000 and I think vanitygen would be better - it would also depend upon what sort of tools the OP is comfortable working with).

BTW - QR codes can easily be generated in javascript (so that shouldn't be your major concern either way) - code to do so is in both bitaddress.org and brainwallet.org (and probably plenty of other websites).

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
b!z (OP)
Legendary
*
Offline Offline

Activity: 1582
Merit: 1010



View Profile
August 05, 2013, 10:14:17 AM
 #9

I need an address for me to receive coins to be generated and displayed when a user clicks a button. That's it. I don't need QR codes or any fancy stuff. What's the easiest way to do so (with code examples, since I'm quite clueless)?

@Cyberdyne and CIYAM Open, is there any code examples I can use to import public keys I have and display one every time a button is pressed? Thanks a lot.  Smiley
🏰 TradeFortress 🏰
Bitcoin Veteran
VIP
Legendary
*
Offline Offline

Activity: 1316
Merit: 1043

👻


View Profile
August 05, 2013, 10:16:08 AM
 #10

I need an address for me to receive coins to be generated and displayed when a user clicks a button. That's it. I don't need QR codes or any fancy stuff. What's the easiest way to do so (with code examples, since I'm quite clueless)?

If you're OK with using Inputs:

Quote
<script src='https://inputs.io/js/buttons.js'></script>
<a href='https://inputs.io/pay?to=yourusername' class='inputsio' data-to='yourusername' >Button Text</a>
MA5H3D
Member
**
Offline Offline

Activity: 99
Merit: 10


View Profile
August 05, 2013, 10:19:28 AM
 #11

Aaah.. if you don't need to actually "generate" the addresses then CIYAM's solution is perfect. But, to be fair the coinbase and blockchain apis are also perfectly safe and probably an easier solution..

just check out: https://coinbase.com/docs/merchant_tools/payment_buttons it's all well documented there.

Example:
<a class="coinbase-button" data-code="4d4b84bbad4508b64b61d372ea394dad" href="https://coinbase.com/checkouts/4d4b84bbad4508b64b61d372ea394dad">Pay With Bitcoin</a>
<script src="https://coinbase.com/assets/button.js" type="text/javascript"></script>
Cyberdyne
Hero Member
*****
Offline Offline

Activity: 630
Merit: 500



View Profile
August 05, 2013, 11:12:05 AM
 #12

@Cyberdyne and CIYAM Open, is there any code examples I can use to import public keys I have and display one every time a button is pressed? Thanks a lot.  Smiley

Are you familiar with PHP/Mysql? Here's something to start with if it helps:

Code:
			
@mysql_query("UPDATE addresses SET used=NOW(), address=(@addr:=address) WHERE used IS NULL LIMIT 1;");
$result = mysql_query(SELECT @addr AS depositaddress;");
$row = mysql_fetch_assoc($result);
$deposit_address = $row['depositaddress'];

The above code will mark an address as used, and then retrieve the one that was just marked.

If you do it the other way around (retrieve one, and then mark it as used), it's technically possible to accidentally give 2 customers the same address, if they both request an address in the exact same microsecond.

Edit: Okay I just re-read your post and see that you probably need more code than that. Perhaps someone can expand on the above. Let us know how you go.
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1086


Ian Knowles - CIYAM Lead Developer


View Profile WWW
August 05, 2013, 11:17:57 AM
 #13

I think that if you don't already know how to code the use of a pool of unused addresses then you would find it much easier to use an API as some of the other responders have mentioned (just make sure that the key used for the API call to generate an address is not the same one for being able to spend BTC).

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
dudeami
Full Member
***
Offline Offline

Activity: 126
Merit: 100



View Profile
August 05, 2013, 11:23:18 AM
 #14

@Cyberdyne and CIYAM Open, is there any code examples I can use to import public keys I have and display one every time a button is pressed? Thanks a lot.  Smiley

Are you familiar with PHP/Mysql? Here's something to start with if it helps:

Code:
			
@mysql_query("UPDATE addresses SET used=NOW(), address=(@addr:=address) WHERE used IS NULL LIMIT 1;");
$result = mysql_query(SELECT @addr AS depositaddress;");
$row = mysql_fetch_assoc($result);
$deposit_address = $row['depositaddress'];

The above code will mark an address as used, and then retrieve the one that was just marked.

If you do it the other way around (retrieve one, and then mark it as used), it's technically possible to accidentally give 2 customers the same address, if they both request an address in the exact same microsecond.

Edit: Okay I just re-read your post and see that you probably need more code than that. Perhaps someone can expand on the above. Let us know how you go.

You really shouldn't be using mysql_* functions, at the very least use mysqli_* or PDO Smiley

Put your heart on the line, it determines your fate.
BTC: 1DUDEAMiV54PFJFSe5fen3wr1e71unkaGj
b!z (OP)
Legendary
*
Offline Offline

Activity: 1582
Merit: 1010



View Profile
August 05, 2013, 12:37:14 PM
Last edit: August 05, 2013, 01:16:03 PM by b!z
 #15

I think that if you don't already know how to code the use of a pool of unused addresses then you would find it much easier to use an API as some of the other responders have mentioned (just make sure that the key used for the API call to generate an address is not the same one for being able to spend BTC).


Thank you for the advice. I will look at the blockchain.info receive API php example and see if I can figure out how to make it work.

EDIT: I failed somehow, can someone show me what I did wrong or show me an easier API? setup.php of https://github.com/blockchain/receive_payment_php_demo gives this error:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in /home/a1011100/public_html/receive_payment_php_demo-master/setup.php on line 8
10 Invalid connect: Access denied for user 'root'@'localhost' (using password: YES)
johnnyfla123
Sr. Member
****
Offline Offline

Activity: 252
Merit: 250


View Profile WWW
August 05, 2013, 01:31:13 PM
 #16

use coinbase. i use coinbase for my webhosting stuff it works great. I also use it to offer my ios beta slots. an example can be here for that:

http://aztecgaming.org/l/

It auto calculates the exchange rate. I set the value to USD and it calculates the current exhancge for the bitcoin payment. If you also want to see it on my hosting you can make a dummy order to see the system.

http://codingagency.com

On my hosting site it calls back as paid after 3 orders, on coinbase it provides transaction numbers that both me and the client recieve as well as a confermation number. sort of like a paypal payment setup. Also the exchange rates on coinbase are awsome. When i cash out I ushually get the money in my bank within 24 hours. The fee is a awsome 1% which beats almost any place. buying is also 1% but it takes 4 days to proccess when you buy. You can get a greendot bank account using the moneypak system and use that to handle he transacations. jsut be mindful that coinbase flags major buys and sells. each transaction i make are always less then a network of $500 to make sure that their system doesnt reject the transaction. I read somewhere where people have reported that coinbase rejects transactiosn it deems as unsafe or sketch.

codingagency.com anonymous and offshore vps and webhosting!
johnnyfla123
Sr. Member
****
Offline Offline

Activity: 252
Merit: 250


View Profile WWW
August 05, 2013, 01:33:10 PM
 #17

Also coinbase supplies a new coinbase address per payment which is nice Smiley

codingagency.com anonymous and offshore vps and webhosting!
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1086


Ian Knowles - CIYAM Lead Developer


View Profile WWW
August 05, 2013, 01:36:24 PM
 #18

EDIT: I failed somehow, can someone show me what I did wrong or show me an easier API? setup.php of https://github.com/blockchain/receive_payment_php_demo gives this error:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in /home/a1011100/public_html/receive_payment_php_demo-master/setup.php on line 8
10 Invalid connect: Access denied for user 'root'@'localhost' (using password: YES)

That just looks as though you didn't pass a correct (or any) password to MySQL.

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
stevenh512
Full Member
***
Offline Offline

Activity: 137
Merit: 100



View Profile
August 06, 2013, 05:07:29 AM
 #19

There's also Electrum. Install the Electrum wallet on your own PC and let the server generate a virtually endless supply of addresses from your master public key. No risk of private keys on the server and no third-party risk of having a payment processor handle your money for you (although so far inputs, coinbase and bitpay have all handled a lot of money with no major issues). Electrum comes with a Python script to generate addresses from your master public key, and there's also some working PHP and Ruby code at:
github.com/prusnak/addrgen

That's the way I'd do it, just give the server a single public key and let the money come straight to your wallet

This signature intentionally left blank.
cp1
Hero Member
*****
Offline Offline

Activity: 616
Merit: 500


Stop using branwallets


View Profile
August 06, 2013, 05:11:50 AM
 #20

Armory can generate public addresses in its watching only mode without exposing private keys, you could probably use their scripts to do it.

Guide to armory offline install on USB key:  https://bitcointalk.org/index.php?topic=241730.0
Pages: [1] 2 »  All
  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!