Possible Duplicate:
How can I accept bitcoins on my website?

I have a few websites I am working on, but is there an open source code I can use that will allow people to deposit bitcoins on my site to where each user would have a unique deposit address?

  • Are you trying to figure out if there's open source code to setup something like mybitcoin? I'm guessing you want to have just one wallet, but have people be able to deposit/withdraw just their bitcoins? Some clarification on your question would help.
    – tysat
    Sep 8 '11 at 23:14

In the past, I've implemented this just by asking the standard Bitcoin client to generate a few thousand addresses and then just have the web site give them out one by one. It's a bit slow generating the addresses, but if you let it run overnight, you'll have a virtually unlimited supply.

Don't forget to backup the wallet immediately after doing this!

  • Also there's a Lazy API which seems like an easy way to get going.
    – Ian Purton
    Sep 9 '11 at 13:25

Combine the suggestion from @David of pregenerating lots of address with Bitcoin Notify and you can build a system that knows when someone has sent you bitcoins (as part of a checkout process, etc).


This is an excellent service for precisely what you're seeking: http://www.bitcoinpayflow.com/


You will need bitcoin-python: https://github.com/toomanysecrets0/bitcoin-python

You will also need MySQLdb

Here's something that should work on a LAMP(ython) server I would sanitize the inputs before putting this in production use though:

#!/usr/bin/env python    

import MySQLdb
import bitcoin
import cgi

DbHost   = "localhost"
DbDatabase = "database name"
DbUser   = "database user"
DbPassword = "database password"

def getAddress(idnumber):

    db = MySQLdb.connect(host=DbHost, user=DbUser, passwd=DbPassword ,db=DbDatabase)


    c.execute("SELECT * FROM `address` WHERE idnumber=" + "'" + str(idnumber) + "'")

    address = c.fetchone()

    if  address != None:
        returnaddress = address[1]

        c.execute("SELECT username,idnumber FROM `address` where idnumber=" + "'" + str(idnumber) + "'")
        user = c.fetchone()    
        if  user != None:
            userid = user[0]
            #Generate a new bitcoin address
            newaddress = generateAddress(userid)
            returnaddress = newaddress

            c.execute("INSERT INTO address(idnumber,receiving_address,username) VALUES(" + str(idnumber) + "," + "'" + str(newaddress) + "'" + "," + str(userid) + ")")
        return "Invalid userid"

return returnaddress

Not the answer you're looking for? Browse other questions tagged or ask your own question.