Bitcoin Forum
September 25, 2016, 07:06:07 PM *
News: Due to DDoS attacks, there may be periodic downtime.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: CGI script for donations  (Read 1825 times)
grondilu
Legendary
*
Offline Offline

Activity: 1134


View Profile
November 15, 2010, 06: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.
1474830367
Hero Member
*
Offline Offline

Posts: 1474830367

View Profile Personal Message (Offline)

Ignore
1474830367
Reply with quote  #2

1474830367
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1474830367
Hero Member
*
Offline Offline

Posts: 1474830367

View Profile Personal Message (Offline)

Ignore
1474830367
Reply with quote  #2

1474830367
Report to moderator
teknohog
Sr. Member
****
Offline Offline

Activity: 410


minor developer


View Profile WWW
November 15, 2010, 09:07:24 PM
 #2

Code:
#!/usr/bin/env python

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

<html>
<body><pre>""")

# 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:password@127.0.0.1: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("</pre></body></html>")

grondilu
Legendary
*
Offline Offline

Activity: 1134


View Profile
November 16, 2010, 02:25:30 AM
 #3

Thanks !
I'm sure some people will find this useful.
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1470


View Profile
December 12, 2010, 09: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.

Jeff Garzik, bitcoin core dev team and BitPay engineer; opinions are my own, not my employer.
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
BioMike
Legendary
*
Offline Offline

Activity: 1218


View Profile
December 12, 2010, 09: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.
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652


Chief Scientist


View Profile WWW
December 12, 2010, 09: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.

How often do you get the chance to work on a potentially world-changing project?
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!