It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
# you have a SQL table `addresses` with columns user, time, address
# and a table `spends` with columns user, time, amountSpent
def getAddress(username):
address = sqlQuery("select address from addresses where user=% order by time desc limit 1", username)
if address is null or bitcoindQuery("getreceivedbyaddress % 0", address) is not 0:
address = bitcoindQuery("getnewaddress")
sqlQuery("insert into addresses values (%, NOW(), %)", username, address)
return address
def logUserSpend(username, amount):
sqlQuery("insert into spends values (%, NOW(), %)", username, amount)
def getBalance(username, minConfirmations):
balance = 0
for address in sqlQuery("select address from addresses where user=%", username):
balance += bitcoindQuery("getreceivedbyaddress % %", address, minConfirmations)
totalSends = sqlQuery("select sum(amountSpent) from spends where user=%", username)
return balance - totalSends
# The above is conceptually how you do it, but you may want to
# add something to avoid so many calls to bitcoindQuery, which is
# a slow operation. As written, this doesn't scale to hundreds of
# addresses per user. For example, you may want to store balances
# for old addresses and assume that the user will not reuse them,
# or poll bitcoind's listsinceblock looking for addresses for
# whom you should update the balances in your database.
def exampleBuyItem(phase, user):
if phase is entry:
print "Please pay to %", getAddress(user)
elif phase is registerPayment:
sqlQuery("set transaction isolation level serializable")
sqlQuery("start transaction")
if getBalance(user, 6) >= price:
sendUserTheItem()
logUserSpend(user, price)
else:
print "Not enough money"
sqlQuery("commit")