Author

Topic: CGI script for donations (Read 2256 times)

legendary
Activity: 1652
Merit: 2311
Chief Scientist
December 12, 2010, 04:44:43 PM
#6
You don't want to generate a new address for each web page hit.  That's a lot of useless addresses stored in your wallet.
Change "getnewaddress(label)"  to "getaccountaddress(label)" and you'll get the same address over and over, until somebody donates.  Then you'll get a different one.
legendary
Activity: 1658
Merit: 1001
December 12, 2010, 04:41:12 PM
#5
MyBitcoin seems to generate a new address for each payment when using the Bitcoin client (as in not through a MyBitcoin account). Just put a button for that on your site.
legendary
Activity: 1596
Merit: 1100
December 12, 2010, 04:38:00 PM
#4
You don't want to generate a new address for each web page hit.  That's a lot of useless addresses stored in your wallet.
legendary
Activity: 1288
Merit: 1080
November 15, 2010, 09:25:30 PM
#3
Thanks !
I'm sure some people will find this useful.
sr. member
Activity: 520
Merit: 253
555
November 15, 2010, 04:07:24 PM
#2
Code:
#!/usr/bin/env python

print("""Content-type: text/html


""")

# module installed via svn from http://json-rpc.org/wiki/python-json-rpc
from jsonrpc import ServiceProxy

from os import uname

hostname = uname()[1]

s = ServiceProxy("http://user:[email protected]:8332/")

label = "web donations on " + hostname

address = s.getnewaddress(label)

print(address + "\n")

donated = s.getreceivedbylabel(label)
if donated > 0:
    print("Donations so far: BTC " + str(donated))
print("Thank you for your support :)")

print("
")
legendary
Activity: 1288
Merit: 1080
November 15, 2010, 01:08:27 PM
#1

I know that one of the good things whith bitcoins, is that you don't need a complex code into your website in order to accept donations.  Basically all you need is to display a bitcoin address.

However, I wonder if using a single fixed unique address is a good idea.  Because it could allow anyone, including the tax-humgry government, to know exactly how many bitcoins you have received.

I'm not concerned about this, because I don't maintain any website.  But I might be in the future.  Therefore I'd like to suggest to publish a small CGI script that would create a new bitcoin-address for every visitor who would like to make donation.

I suck a CGI programming, but at least I know that any programming language can be used to do that.  So I guess a simple "bitcoind getnewaddress SOMELABEL" could be used, where SOMELABEL would be any string the donator would like to enter.

I'd appreciate if someone could post an example of such a script.
Jump to: