1

I am using the ZMQ interface of my node to keep track of wallet activity like incoming transactions. I want to know the number of confirmations of my transaction but, to do that, I would need to know in which block the tx is included and calculate from that block onwards.

I was thinking that I could watch for the ZMQ channel hashblock but there is not much documentation about these channels. Is this hashblock a merkle root hash?

1 Answer 1

2

As the name suggests, it is the block hash, not the merkle root hash. It is the hash of the block header which includes the merkle root hash. To learn whether your tx is included in a block, you will need to fetch the block with that hash and then search for your transaction within that block. You can do this by using the getblock RPC after receiving the ZMQ message. You could also use the rawblock ZMQ channel and receive the entire block in full, but that will also mean that you need to implement block parsing.

Even if you could just get the merkle root, the merkle root itself does not contain sufficient information to determine whether a particular transaction is included in that block. You still need to get the full block and search the transactions list for your transaction.

0

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.