<p>The <code>decoderawtransaction</code> RPC call oddly omits the <code>confirmations</code> field in the resulting JSON output. Instead of using <code>decoderawtransaction</code>, try this:</p>

<pre><code>$ bitcoin-cli getrawtransaction &lt;tx_id&gt; true
</code></pre>

<p>(Notice the "true" at the end, which means "output as json")</p>

<p>This will return JSON that has a "confirmations" field in the top level of the returned object.</p>

CC BY-SA 3.0
2018-01-25T10:54:28.747Z
hi thanks for the reply... but i am getting Error: value is type bool, expected int
OneyesOneno
CC BY-SA 3.0
2018-01-25T11:07:35.983Z
@OneyesOneno ah sorry, we might be on different versions. try: `bitcoin-cli getrawtransaction <tx_id> 1`
Tony Rizko
CC BY-SA 3.0
2018-01-25T12:02:47.583Z
hii... its me again.. i try 1 , it return 
￼
parameter 1 must be hexadecimal string (not '04e66db5c1dc6471c6e518636ed66f99cbb853a2bb3303cd0a60403d49e66a4') (code -8) .. then it try getrawtransaction (tx_id) verbose = it return Error: Error parsing JSON:verbose
OneyesOneno
CC BY-SA 3.0
2018-01-25T20:10:40.723Z
hi @OneyesOneno, it looks like the hex string you are providing is invalid: (04e66db5c1dc6471c6e518636ed66f99cbb853a2bb3303cd0a60403d49e‌​66a4). You are missing 3 more hex digits.
Tony Rizko
CC BY-SA 3.0
2018-01-26T01:15:00.910Z
wow you are absolutely right about it. Thanks you so much!
OneyesOneno
CC BY-SA 3.0
2018-01-25T09:07:05.590Z
2018-01-25T09:07:05.590Z
Tony Rizko
<p>I am trying to check if a transaction is confirmed or not via RPC commands. At first I tried to use <code>gettransaction</code>, but it doesn't work.</p>

<p>Then I use <code>getrawtransaction</code> and decode it:</p>

<pre><code>{
   "lock_time":0,
   "size":192,
   "inputs":[
      {
         "prev_out":{
            "index":1,
            "hash":"5352d8186b825128a7d4a0df0a8c105da70c81ec763209271566a512fee14cee"
         },
         "script":"483045022100fae0b1dbe08f79a92debde8f3a8e955bcff9ce928b86fb217cfd830af6937386022072386b28a288408bad05426704b55f14a4ad4bf3927ac053facda4478c467eae0121034756f0f954f40ed7dabcaa80c4212a240e4b2c1eee7532bd06cac58c173faf3f"
      }
   ],
   "version":1,
   "vin_sz":1,
   "hash":"931d220f622a9b029cea3e09ca7a9c11f3714c68f9bd272ca97cd915b518050d",
   "vout_sz":1,
   "out":[
      {
         "script_string":"OP_DUP OP_HASH160 0f14a815e42dcdff9c8239a7393b2a9a63a8b68d OP_EQUALVERIFY OP_CHECKSIG",
         "address":"12Njt85fc9Kr7s8tr3Eug4tvkZQUhcGXfz",
         "value":100000000,
         "script":"76a9140f14a815e42dcdff9c8239a7393b2a9a63a8b68d88ac"
      }
   ]
}
</code></pre>

<p>And I got the above result. But I don't understand what is written, how can I know if it has been confirmed without relying on Blockexplorer? </p>

<p>Thanks</p>

<json-rpc>
Checking for confirmations using getrawtransaction and decoderawtransaction
OneyesOneno
# Checking for confirmations using getrawtransaction and decoderawtransaction

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

I am trying to check if a transaction is confirmed or not via RPC commands. At first I tried to use `gettransaction`, but it doesn't work.

Then I use `getrawtransaction` and decode it:

```
{
   "lock_time":0,
   "size":192,
   "inputs":[
      {
         "prev_out":{
            "index":1,
            "hash":"5352d8186b825128a7d4a0df0a8c105da70c81ec763209271566a512fee14cee"
         },
         "script":"483045022100fae0b1dbe08f79a92debde8f3a8e955bcff9ce928b86fb217cfd830af6937386022072386b28a288408bad05426704b55f14a4ad4bf3927ac053facda4478c467eae0121034756f0f954f40ed7dabcaa80c4212a240e4b2c1eee7532bd06cac58c173faf3f"
      }
   ],
   "version":1,
   "vin_sz":1,
   "hash":"931d220f622a9b029cea3e09ca7a9c11f3714c68f9bd272ca97cd915b518050d",
   "vout_sz":1,
   "out":[
      {
         "script_string":"OP_DUP OP_HASH160 0f14a815e42dcdff9c8239a7393b2a9a63a8b68d OP_EQUALVERIFY OP_CHECKSIG",
         "address":"12Njt85fc9Kr7s8tr3Eug4tvkZQUhcGXfz",
         "value":100000000,
         "script":"76a9140f14a815e42dcdff9c8239a7393b2a9a63a8b68d88ac"
      }
   ]
}

```

And I got the above result. But I don't understand what is written, how can I know if it has been confirmed without relying on Blockexplorer?

Thanks

**Tags:** json-rpc


---

## 1 answers

### Answer by username_1 on 2018-01-25. Score: 2 | Accepted answer

The `decoderawtransaction` RPC call oddly omits the `confirmations` field in the resulting JSON output. Instead of using `decoderawtransaction`, try this:

```
$ bitcoin-cli getrawtransaction <tx_id> true

```

(Notice the "true" at the end, which means "output as json")

This will return JSON that has a "confirmations" field in the top level of the returned object.

> **Comments:**
> **username_0**: hi thanks for the reply... but i am getting Error: value is type bool, expected int  
> **username_1**: @username_0 ah sorry, we might be on different versions. try: `bitcoin-cli getrawtransaction <tx_id> 1`  
> **username_0**: hii... its me again.. i try 1 , it return  ￼ parameter 1 must be hexadecimal string (not '04e66db5c1dc6471c6e518636ed66f99cbb853a2bb3303cd0a60403d49e66a4') (code -8) .. then it try getrawtransaction (tx_id) verbose = it return Error: Error parsing JSON:verbose  
> **username_1**: hi @username_0, it looks like the hex string you are providing is invalid: (04e66db5c1dc6471c6e518636ed66f99cbb853a2bb3303cd0a60403d49e‌​66a4). You are missing 3 more hex digits.  
> **username_0**: wow you are absolutely right about it. Thanks you so much!  

---

