I'm currently working on accepting Bitcoins on my website. To do this I create a new address for every sale. I know I can get the amount of bitcoins that were paid into this address by using
./btcoind getreceivedbyaddress <the-address> 0 or
conn.getreceivedbyaddress(localAddress, 0) when using the python binding for bitcoin. So far so good.
I now also want to get and display the amount of confirmations to the customer. So I made this:
highestConfirmCount = None for i in count(): received = btcConn.getreceivedbyaddress(localAddress, i) if received >= amountExpected: highestConfirmCount = i else: break print highestConfirmCount
This works fine, but it's pretty slow for incoming payments which have been a while ago. Also, I would presume there would be a better and more efficient built in function for this, but I can't find anything like it.
Does anybody know what the best way is for getting confirmations for incoming payments to a specific address?