1

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.

1 Answer 1

1

If you have txindex=1, you can call getrawtransaction <txid> 1 to receive a decoded tx object, which will include the number of confirmations and the blockhash.

6
  • Oh! I am definitely sure there is no confirmations after you decode the hex, which get by getrawtransaction.
    – Frank AK
    Aug 1, 2018 at 9:07
  • Seems to work on chainquery. What version of Bitcoin are you running? Aug 1, 2018 at 9:10
  • I am using the V0.16.1 version. The link that you given should be processed.
    – Frank AK
    Aug 1, 2018 at 9:13
  • It also seems to be in the source. Not sure why it won't show up on your local node. Are you sure you're using getrawtransaction, and not decoderawtransaction? Aug 1, 2018 at 9:21
  • Oh! getrawtransaction only return me a hash, and I have to use decoderawtransaction to parser it.
    – Frank AK
    Aug 1, 2018 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.