Bitcoin Forum
November 09, 2024, 07:02:11 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to get or calculate inputs's prev_out tx hash using script ?  (Read 416 times)
btctousd81 (OP)
Sr. Member
****
Offline Offline

Activity: 434
Merit: 270


View Profile WWW
September 29, 2017, 02:24:06 AM
 #1

i am looking at tx json output at blockchain.info

here is simple tx for ref. using 1 input and 1 output.

https://blockchain.info/tx/727b2cd08e728aeb08580333207c52d0ddf3ba47f85bd59241c3d92436f5fdd5


Code:
{
   "ver":2,
   "inputs":[
      {
         "sequence":4294967295,
         "witness":"",
         "prev_out":{
            "spent":true,
            "tx_index":188897912,
            "type":0,
            "addr":"3KeMARg9fppMVGytgyVJpc37oAXWyRbRuv",
            "value":272135,
            "n":0,
            "script":"a914c4f11390a7b4fcb4ffc4bd7e756596c706d6098887"
         },
         "script":"00483045022100af349f6a1d70f7d179559ea054cbd7869537f303915e2368b29a51041307562b022025b849a291dbaccfeafdb7e6678f586793c365a38d0c1685410b875e0f541611014730440220210616dd589181b0194ab73f0b7a6aac15c5b17c9c80621397bafbf0060ef56a0220247e5bca72de61be853027bcb2cfa3ceff1912e7019e7fa8573665fc559eb998014c69522102def45a0229881116d6000bc99921426c35a3a8bb92e1d4485679a23c93799f512102ef970eabc8e92f7dc357a93ded039e63137718df0bcd19b3e74f7f1a9ad870e621037d811aa90fcb399985f79699f4e92044b663e01456f22bbc50888eccaffb742f53ae"
      }
   ],
   "weight":1360,
   "relayed_by":"0.0.0.0",
   "out":[
      {
         "spent":false,
         "tx_index":286831175,
         "type":0,
         "addr":"1NjTJADyoBLpqvM6kbc9VSMS9DnqUhMZ7R",
         "value":236548,
         "n":0,
         "script":"76a914ee6210015c3768052078a9802b5a648b7991bfb188ac"
      }
   ],
   "lock_time":0,
   "size":340,
   "double_spend":false,
   "time":1506651576,
   "tx_index":286831175,
   "vin_sz":1,
   "hash":"727b2cd08e728aeb08580333207c52d0ddf3ba47f85bd59241c3d92436f5fdd5",
   "vout_sz":1
}


how can i get/calculate input's tx_hash. i mean prev_out input's tx hash. from the available info in current json ?
i.e. from this
Code:
      {
         "sequence":4294967295,
         "witness":"",
         "prev_out":{
            "spent":true,
            "tx_index":188897912,
            "type":0,
            "addr":"3KeMARg9fppMVGytgyVJpc37oAXWyRbRuv",
            "value":272135,
            "n":0,
            "script":"a914c4f11390a7b4fcb4ffc4bd7e756596c706d6098887"
         },
         "script":"00483045022100af349f6a1d70f7d179559ea054cbd7869537f303915e2368b29a51041307562b022025b849a291dbaccfeafdb7e6678f586793c365a38d0c1685410b875e0f541611014730440220210616dd589181b0194ab73f0b7a6aac15c5b17c9c80621397bafbf0060ef56a0220247e5bca72de61be853027bcb2cfa3ceff1912e7019e7fa8573665fc559eb998014c69522102def45a0229881116d6000bc99921426c35a3a8bb92e1d4485679a23c93799f512102ef970eabc8e92f7dc357a93ded039e63137718df0bcd19b3e74f7f1a9ad870e621037d811aa90fcb399985f79699f4e92044b663e01456f22bbc50888eccaffb742f53ae"
      }

i want to get this

Code:
626ce1cc231f67c6895d92ee28aa4a595e86ffc7ba22de0d5a4469178ee84719



achow101
Moderator
Legendary
*
Offline Offline

Activity: 3542
Merit: 6886


Just writing some code


View Profile WWW
September 29, 2017, 03:35:35 AM
 #2

Use a different api. Blockchain.info's api is not giving you the information that you want even though the previous transaction id and output index is included in the transaction itself.

btctousd81 (OP)
Sr. Member
****
Offline Offline

Activity: 434
Merit: 270


View Profile WWW
September 29, 2017, 03:40:45 AM
 #3

Use a different api. Blockchain.info's api is not giving you the information that you want even though the previous transaction id and output index is included in the transaction itself.

how about this one ?

https://chain.so/tx/BTC/727b2cd08e728aeb08580333207c52d0ddf3ba47f85bd59241c3d92436f5fdd5

edit: got it.


https://chain.so/api/v2/tx/BTC/727b2cd08e728aeb08580333207c52d0ddf3ba47f85bd59241c3d92436f5fdd5


thanks



Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!