I am running my bitcoind
with -zmqpubhashtx
optional, and I receive notification once a new transaction has broadcast to public chain! I can also parser it by getrawtransaction
and decoderawtransaction
. But I couldn't validated if a transaction is confirmed.
Additionally, there are also exists an optional name as -zmqpubhashblock
, I can also parser it by getblock
and read its all transactions, compare it all with my MySQL data, if it's exists with the same txid
, I'll update my column (confirmations to plus one), but it's a little bit ineffective.
Let's say, After I ran getblock <hash>
, and then give me a tons of transaction. and I have to check each something like:
UPDATE t_unspent_tx
SET confirmations = confirmations + 1
WHERE addr in (addresses)
BTW, Can I trust the block hash from notification? Is it may not be the longest on the chain?
PS, I don't want to check confirmation from the blockchain.info or some other site else.