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

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.

| improve this answer | |
  • hi thanks for the reply... but i am getting Error: value is type bool, expected int – OneyesOneno Jan 25 '18 at 10:54
  • @OneyesOneno ah sorry, we might be on different versions. try: bitcoin-cli getrawtransaction <tx_id> 1 – Tony Rizko Jan 25 '18 at 11:07
  • 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 Jan 25 '18 at 12:02
  • hi @OneyesOneno, it looks like the hex string you are providing is invalid: (04e66db5c1dc6471c6e518636ed66f99cbb853a2bb3303cd0a60403d49e‌​66a4). You are missing 3 more hex digits. – Tony Rizko Jan 25 '18 at 20:10
  • wow you are absolutely right about it. Thanks you so much! – OneyesOneno Jan 26 '18 at 1:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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