Checking for confirmations using getrawtransaction and decoderawtransaction

1

1

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

OneyesOneno

Posted 2018-01-25T06:48:29.330

Reputation: 13

Answers

1

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.

Tony Rizko

Posted 2018-01-25T06:48:29.330

Reputation: 308

hi thanks for the reply... but i am getting Error: value is type bool, expected intOneyesOneno 2018-01-25T10:54:28.747

@OneyesOneno ah sorry, we might be on different versions. try: bitcoin-cli getrawtransaction &lt;tx_id&gt; 1Tony Rizko 2018-01-25T11:07:35.983

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:verboseOneyesOneno 2018-01-25T12:02:47.583

hi @OneyesOneno, it looks like the hex string you are providing is invalid: (04e66db5c1dc6471c6e518636ed66f99cbb853a2bb3303cd0a60403d49e‌​66a4). You are missing 3 more hex digits.Tony Rizko 2018-01-25T20:10:40.723

wow you are absolutely right about it. Thanks you so much!OneyesOneno 2018-01-26T01:15:00.910