title: How to differentiate change transaction from actual transaction in bitcoin raw transaction template?
body: <p>I'm trying to create my own display of the blockchain and I encounter an understanding problem. I'm using txindex=1 in bitcoin.conf to have access to non-wallet information on transactions but when I decode a rawtransaction I cannot make the difference between the change and the amount of the transaction.</p>
  
  <p>Here a random example (with change) from the testnet:</p>
  
  <pre><code>"txid" : "979e9c84a9ce7e18e38b883eaba4078cd21e26ef5d13eba15aebeb355d42f5d5",
      "version" : 1,
     "locktime" : 0,
     "vin" : [
      {
          "txid" : "593b3c92ca20a789fadbfe563139c3cc89824e05557c68e247418b13ddd6e5ed",
          "vout" : 1,
          "scriptSig" : {
              "asm" : "304402202b6be66d4a4ac12ea93f678cb66903ba266c8f74bfccd0c01cd6ad2225d180d002200f9daf5c7a96cbddaa74d9fc449bec7a5f9ed6d61091d35148adad72e930214e01 04280cf692411203d1e133789692f7121735dabe290a5e626d6d16c6aa9b44950628ae448dcdf9e0f19fd3859df8f3a1cb947b2be5091a93edbe37bb4c99b160c5",
              "hex" : "47304402202b6be66d4a4ac12ea93f678cb66903ba266c8f74bfccd0c01cd6ad2225d180d002200f9daf5c7a96cbddaa74d9fc449bec7a5f9ed6d61091d35148adad72e930214e014104280cf692411203d1e133789692f7121735dabe290a5e626d6d16c6aa9b44950628ae448dcdf9e0f19fd3859df8f3a1cb947b2be5091a93edbe37bb4c99b160c5"
          },
          "sequence" : 4294967295
      }
  ],
  "vout" : [
      {
          "value" : 40.00000000,
          "n" : 0,
          "scriptPubKey" : {
              "asm" : "OP_DUP OP_HASH160 f35a10d09c9a09bbce7aacdd0888c151866affcf OP_EQUALVERIFY OP_CHECKSIG",
              "hex" : "76a914f35a10d09c9a09bbce7aacdd0888c151866affcf88ac",
              "reqSigs" : 1,
              "type" : "pubkeyhash",
              "addresses" : [
                  "n3hgPYQArNYj8fkxW369qT16k7i3r9oSrQ"
              ]
          }
      },
      {
          "value" : 9.89980000,
          "n" : 1,
          "scriptPubKey" : {
              "asm" : "OP_DUP OP_HASH160 f5dbc72c2b7170e51469b8b46700567d1e2eee5e OP_EQUALVERIFY OP_CHECKSIG",
              "hex" : "76a914f5dbc72c2b7170e51469b8b46700567d1e2eee5e88ac",
              "reqSigs" : 1,
              "type" : "pubkeyhash",
              "addresses" : [
                  "n3vw8VmfuEwWuVsD9KoWiNzCX7EsrjRVr7"
              ]
          }
      }
  ]
  </code></pre>
  
  <p>Is there an easy way to find out which one is the "good" one ? 40 BTC or 9.9 BTC ? I tried to display recursively the "vin" transaction id to find out more information but never found a clue to help me. May be am I missing something.</p>