Bitcoin Forum
April 19, 2024, 03:39:44 PM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: CGI script for donations  (Read 2218 times)
grondilu (OP)
Legendary
*
Offline Offline

Activity: 1288
Merit: 1076


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.

1713541184
Hero Member
*
Offline Offline

Posts: 1713541184

View Profile Personal Message (Offline)

Ignore
1713541184
Reply with quote  #2

1713541184
Report to moderator
Unlike traditional banking where clients have only a few account numbers, with Bitcoin people can create an unlimited number of accounts (addresses). This can be used to easily track payments, and it improves anonymity.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713541184
Hero Member
*
Offline Offline

Posts: 1713541184

View Profile Personal Message (Offline)

Ignore
1713541184
Reply with quote  #2

1713541184
Report to moderator
1713541184
Hero Member
*
Offline Offline

Posts: 1713541184

View Profile Personal Message (Offline)

Ignore
1713541184
Reply with quote  #2

1713541184
Report to moderator
1713541184
Hero Member
*
Offline Offline

Posts: 1713541184

View Profile Personal Message (Offline)

Ignore
1713541184
Reply with quote  #2

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

Activity: 519
Merit: 252


555


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>")

world famous math art | masternodes are bad, mmmkay?
Every sha(sha(sha(sha()))), every ho-o-o-old, still shines
grondilu (OP)
Legendary
*
Offline Offline

Activity: 1288
Merit: 1076


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: 1596
Merit: 1091


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, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
BioMike
Legendary
*
Offline Offline

Activity: 1658
Merit: 1001


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
Merit: 2216


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:  

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