Breaking down a raw transaction: Complete example:


  0100000001186f9f998a5aa6f048e51dd8419a14d8a0f1a8a2836dd734d2804fe65fa35779000000008b483045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e381301410484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adfffffffff0260e31600000000001976a914ab68025513c3dbd2f7b92a94e0581f5d50f654e788acd0ef8000000000001976a9147f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a888ac00000000




Breakdown:

Version (4-byte):

01000000



Number of inputs (variable size but in this case it is 1-byte):

01



Previous transaction ID byte swapped (32-byte):

186f9f998a5aa6f048e51dd8419a14d8a0f1a8a2836dd734d2804fe65fa35779



prev_out_index (4-byte):

00000000



scriptSig length (variable size but in this case it is 2-byte which represents 139-bytes for the following scrtiptSig):

8b



scriptSig (variable size but in this case it’s 139-byte):

483045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e381301410484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adf



Sequence number: (4-byte):

ffffffff



Don’t know what this is:

02



Value to send (8-byte byte-swapped):

60e3160000000000



Output 1 – Receiving address for amount above:

19 76 a9 14ab68025513c3dbd2f7b92a94e0581f5d50f654e7 88 ac



Value for change (8-byte byte-swapped)

d0ef800000000000



Output 2- Change address for amount above:

19 76 a9 147f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a8 88 ac



LockTime (4-byte):

00000000



Question:

The bit where I wrote Don’t know what this is, which has the value 02.  I don't know what the purpose of that value is.  What's the purpose of that value?
The bolded byte in the following raw transaction is the number of outputs (two in this transaction):


  0100000001186f9f998a5aa6f048e51dd8419a14d8a0f1a8a2836dd734d2804fe65fa35779000000008b483045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e381301410484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adfffffffff0260e31600000000001976a914ab68025513c3dbd2f7b92a94e0581f5d50f654e788acd0ef8000000000001976a9147f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a888ac00000000


The Bitcoin.org Developer Documentation has an extended description of the raw transaction format if you'd like more information.