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

CC BY-SA 4.0
2018-08-01T09:07:53.503Z
Oh! I am definitely sure there is no `confirmations` after you decode the `hex`, which get by `getrawtransaction`.
Frank AK
CC BY-SA 4.0
2018-08-01T09:10:38.730Z
[Seems to work on chainquery](http://chainquery.com/bitcoin-api/getrawtransaction/b13b4765e46228f3239858c9f18e766b72bed24a56c52b9692e7f021c376e7ce/1). What version of Bitcoin are you running?
Raghav Sood
CC BY-SA 4.0
2018-08-01T09:13:18.947Z
I am using the `V0.16.1` version. The link that you given should be processed.
Frank AK
CC BY-SA 4.0
2018-08-01T09:21:07.580Z
[It also seems to be in the source](https://github.com/bitcoin/bitcoin/blob/master/src/rpc/rawtransaction.cpp#L132). Not sure why it won't show up on your local node. Are you sure you're using `getrawtransaction`, and not `decoderawtransaction`?
Raghav Sood
CC BY-SA 4.0
2018-08-01T09:22:34.960Z
Oh! getrawtransaction only return me a hash, and I have to use `decoderawtransaction` to parser it.
Frank AK
CC BY-SA 4.0
2018-08-01T09:23:08.503Z
`getrawtransaction` has a verbose mode, as described in my answer, use that instead
Raghav Sood
CC BY-SA 4.0
2018-08-01T08:47:33.143Z
2018-08-01T08:47:33.143Z
Raghav Sood
<p>I am running my <code>bitcoind</code> with <code>-zmqpubhashtx</code> optional, and I receive notification once a new transaction has broadcast to public chain! I can also parser it by <code>getrawtransaction</code> and <code>decoderawtransaction</code>. But I couldn't validated if a transaction is confirmed. </p>

<p>Additionally, there are also exists an optional name as <code>-zmqpubhashblock</code>, I can also parser it by <code>getblock</code> and read its all transactions, compare it all with my MySQL data, if it's exists with the same <code>txid</code>, I'll update my column (confirmations to plus one), but it's a little bit ineffective. </p>

<p>Let's say, After I ran <code>getblock &lt;hash&gt;</code>, and then give me a tons of transaction. and I have to check each something like:</p>

<pre><code>UPDATE t_unspent_tx
SET confirmations = confirmations + 1
WHERE addr in (addresses)    
</code></pre>

<p>BTW, Can I trust the block hash from notification? Is it may not be the longest on the chain?</p>

<p><strong>PS</strong>, I don't want to check confirmation from the blockchain.info or some other site else.</p>

<blockchain><bitcoind><confirmations>
How do I know one transaction has confirmed?
Frank AK
# How do I know one transaction has confirmed?

(Asked by: username_0 on 2018-08-01)

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.

**Tags:** blockchain, bitcoind, confirmations


---

## 1 answers

### Answer by username_1 on 2018-08-01. Score: 1 | Accepted answer

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.

> **Comments:**
> **username_0**: Oh! I am definitely sure there is no `confirmations` after you decode the `hex`, which get by `getrawtransaction`.  
> **username_1**: [Seems to work on chainquery](http://chainquery.com/bitcoin-api/getrawtransaction/b13b4765e46228f3239858c9f18e766b72bed24a56c52b9692e7f021c376e7ce/1). What version of Bitcoin are you running?  
> **username_0**: I am using the `V0.16.1` version. The link that you given should be processed.  
> **username_1**: [It also seems to be in the source](https://github.com/bitcoin/bitcoin/blob/master/src/rpc/rawtransaction.cpp#L132). Not sure why it won't show up on your local node. Are you sure you're using `getrawtransaction`, and not `decoderawtransaction`?  
> **username_0**: Oh! getrawtransaction only return me a hash, and I have to use `decoderawtransaction` to parser it.  
> **username_1**: `getrawtransaction` has a verbose mode, as described in my answer, use that instead  

---

