chronokings/huntercoin — pull request #5 by rampa069 (2014-02-13 03:08:20+00:00)
Title: Added listsinceblock and modified WalletTxToJSON

The command is needed to detect the newblock in an easy way.

As a reference. this is the snippet of ruby code that detects new blocks in our pool.

begin
aTransactions = coinClient.listsinceblock lastHash
rescue
shell.error " * Error conecting with #{coin.symbol} daemon!"
end

if aTransactions.nil? or aTransactions['transactions'].nil?
shell.say " > No new transactions"
else
aTransactions['transactions'].each do |transaction|
if transaction['category'] == 'generate' or transaction['category'] == 'immature'
newBlock = coinClient.getblock transaction['blockhash']

oldBlock = coin.blocks.first(:hash => transaction['blockhash'])
if oldBlock
oldBlock.confirms = transaction['confirmations']
if (transaction['confirmations'] > confRequired)
oldBlock.confirmed = true
end
if oldBlock.save
shell.say " - Updated block #{oldBlock.hash[1..10]}... "\
"#{transaction['confirmations']} "\
"confirms (#{oldBlock.confirmed})"
else
shell.say " * ERROR updating block!"