i think you may have been thrown off because of SIGHASHes and you may benefit from looking at what a transaction looks like.
a transaction is like this:
version
txin_count(3)
[input_0]:txid | index | scriptsig | sequence
[input_1]:txid | index | scriptsig | sequence
[input_3]:txid | index | scriptsig | sequence
txout_count(2)
[output_0]:amount | scriptpub
[output_1]:amount | scriptpub
locktime
forget about SegWit and SIGHAH for now.
to sign or verify the signature of this transaction you look at each input. they all have a "reference" to what they are spending. using the txid and the index you can find that transaction. so lets say the input_0 is this (from
this transaction:
txid= 7f920a59108b7434a77af8c392a940e51d50db998280969ab80d9428a80d8448
index = 1
now the node is going to get the transaction that is being spent by having its hash and then look among its txouts at index 1 and it can get this:
OP_DUP OP_HASH160 <0148352b01e7b93c6af2aa134d3a59a1bfbf3fd8> OP_EqualVerify OP_CheckSig
now that you have the scriptpub you can start serializing the transaction in a way to be hashed and then signed.
the way it works for this type is to set the scriptsig of the txin you are signing to this scriptpub and setting every other scriptsig to empty.
up to this point is the same steps used no matter what the SIGHASH is.now if the SIGHASH is ALL you sign the entire thing.
version
txin_count(3)
[input_0]:txid | index | scriptpub | sequence
[input_1]:txid | index | empty | sequence
[input_3]:txid | index | empty | sequence
txout_count(2)
[output_0]:amount | scriptpub
[output_1]:amount | scriptpub
locktime
if it is NONE then you sign everything except outputs:
version
txin_count(3)
[input_0]:txid | index | scriptpub | sequence
[input_1]:txid | index | empty | 0
[input_3]:txid | index | empty | 0
txout_count(0)
locktime
if it is SINGLE then you sign a single "input" (your own input) and the outputs
version
txin_count(3)
[input_0]:txid | index | scriptpub | 0
[input_1]:txid | index | empty | 0
[input_3]:txid | index | empty | 0
txout_count(1)
[output_0]:amount | scriptpub
locktime
and if any of the above has ANYONECANPAY only one input is being signed. there are also some more details that i skipped.
now that you are done with first input (input_0) you move to the next input (input_1) and repeat the same thing for that:
look at its txid:index, get the scriptpub, build the serialization, hash, sign/verify.
for example for ALL:
version
txin_count(3)
[input_0]:txid | index | empty | sequence
[input_1]:txid | index | scriptpub | sequence
[input_3]:txid | index | empty | sequence
txout_count(2)
[output_0]:amount | scriptpub
[output_1]:amount | scriptpub
locktime