Pages:
Author

Topic: How do I generate Bitcoin addresses on my website? $$ (Read 2520 times)

legendary
Activity: 1498
Merit: 1000
If you want me to do this for you, it would legit take me like an hour or so and I only charge like $20 in BTC to do.
newbie
Activity: 9
Merit: 0
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)

Go to include.php and change $mysql_password.
hero member
Activity: 630
Merit: 500
You really shouldn't be using mysql_* functions, at the very least use mysqli_* or PDO Smiley

Thanks, I hadn't read about that until today.

Personally I use more abstracted methods in a framework, but that might have made my example more complicated instead of less...    $db->query()
b!z
legendary
Activity: 1582
Merit: 1010
Also coinbase supplies a new coinbase address per payment which is nice Smiley

Can you help me setup Coinbase on my site? I might rent your hosting service  Cheesy
cp1
hero member
Activity: 616
Merit: 500
Stop using branwallets
Armory can generate public addresses in its watching only mode without exposing private keys, you could probably use their scripts to do it.
full member
Activity: 137
Merit: 100
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
legendary
Activity: 1890
Merit: 1078
Ian Knowles - CIYAM Lead Developer
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.
sr. member
Activity: 252
Merit: 250
Also coinbase supplies a new coinbase address per payment which is nice Smiley
sr. member
Activity: 252
Merit: 250
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.
b!z
legendary
Activity: 1582
Merit: 1010
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)
full member
Activity: 126
Merit: 100
@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
legendary
Activity: 1890
Merit: 1078
Ian Knowles - CIYAM Lead Developer
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).
hero member
Activity: 630
Merit: 500
@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.
member
Activity: 99
Merit: 10
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:
https://coinbase.com/checkouts/4d4b84bbad4508b64b61d372ea394dad">Pay With Bitcoin
vip
Activity: 1316
Merit: 1043
👻
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

Button Text
b!z
legendary
Activity: 1582
Merit: 1010
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
legendary
Activity: 1890
Merit: 1078
Ian Knowles - CIYAM Lead Developer
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).
hero member
Activity: 630
Merit: 500
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.
legendary
Activity: 1890
Merit: 1078
Ian Knowles - CIYAM Lead Developer
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.
b!z
legendary
Activity: 1582
Merit: 1010
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.
Pages:
Jump to: