1
I need to query blockchain.info with an address and determine how much is there, ignoring transactions that don't have 3 confirmations.
Can anyone give me a hint how to do this?
1
I need to query blockchain.info with an address and determine how much is there, ignoring transactions that don't have 3 confirmations.
Can anyone give me a hint how to do this?
3
Get the block count:
http://blockchain.info/q/getblockcount
Subtract 3 from that number.
Get the transactions from the address you're looking for:
http://blockchain.info/address/$bitcoin_address?format=json&limit=50&offset=0
This returns 50 transactions by default, change the 'limit' value to wherever you might need it to be. Setting 'offset' to 5 will allow you to skip the first 5 transactions. Make sure you don't set offset to something greater than the total number of transactions on a particular address, it won't ever return anything.
Then set up your code to ignore any transaction that's newer than 3 blocks ago.
2
You can do this in two API calls, plus some filtering:
http://blockchain.info/latestblockhttp://blockchain.info/address/$hash_160?format=json Rough Ruby code:
require 'open-uri'
require 'json'
require 'pp'
desired_address = '1dice7W2AicHosf5EL3GFDUVga7TgtPFn' #high traffic address good for example code!
get_transactions_with_minimum_of_n_confirmations = 3
latestblock = JSON.parse open('http://blockchain.info/latestblock').read
address = JSON.parse open("http://blockchain.info/address/#{desired_address}?format=json").read
current_block_height = latestblock["height"]
pp address["txs"].select {|tx| tx["block_height"] < (current_block_height - get_transactions_with_minimum_of_n_confirmations) }
Keep in mind that you're going to retrieve a list of ALL transactions involving that address. It'd be nice of Blockchain.info let you specify a minimum number of confirmations to limit transactions to on the address call.
What? could you rephrase? – o0'. – 2013-04-19T13:24:03.670
1
This sounds a bit like an XY problem. I'm guessing that you want to take payments, right?
– Nick ODell – 2013-04-19T17:05:57.5931
Have you read through http://blockchain.info/api?
– ripper234 – 2013-04-19T17:45:48.597