Each transaction creates at least one output that contains two things: (1) amount field which indicates how much bitcoin is being locked up and (2) the script which is the lock indicating how these coins can be unlocked or spent.
These outputs don't have an explicit field for their index, the index is the order inside the transaction output array itself.
Each UTXO (that's not a null value UTXO like an OP_RETURN), has a value, scriptPubKey (hereafter referred to as a "locking script"), and index (hereafter referred to as "n").
This means
all outputs have the two fields (value and scriptpub) including OP_RETURN outputs.
Each input of a transaction spending a UTXO has to address them by providing the (1) transaction ID of the tx containing the output being spent (2) index of the output being spent (3) the unlocking script which can be scriptsig or witness depending on the UTXO type and (4) a 4 byte sequence.
In order to spend a UTXO, you have have to supply an unlocking script which contains a signature from the address possessing the UTXO (this proves that the spender actually has the private key for the address), and the UTXO owner's public key so the signature can be verified.
This means what you provide when spending UTXOs, what you provide depends on their type. It can contain one signature and one public key, it can contain multiple signatures and public keys, it can contain more complex scripts like a locktime or execution branches, etc.
I made this diagram to show what I believe a bitcoin transaction spend to look like:
https://imgur.com/a/titAoheClearly I don't grasp the entire structure of a BTC transaction as indicated by the fact that I put several "IDK"s in the diagram. Can someone fill in the gaps in my knowledge?
This is one of the oldest and simplest scripts known as P2PKH or pay to pubkey hash.
In the outputs the first value that is being pushed to the stack after the OP_HASH160 is the hash160 digest of the public key.
In the inputs (scriptsig) there is no value field anymore since it is already present in the output that is being addressed and the signature (last value pushed to the stack or the first inside the script) is the ECDSA signature created using the private key that created the address.
The new outputs this new transaction creates is the same as before.
This page can be helpful to see more scripts and the standard one you used here:
https://en.bitcoin.it/wiki/Script#Script_examples