I am currently working on a tool parsing every transaction of the bitcoin blockchain, using the getrawtransaction
RPC call in verbose mode.
My goal is to store them all in a database, while keeping some useful information about them (i.e., not everything that is given by the RPC call).
Something I am having trouble to understand though is how to precisely "tag" an input with a type? The outputs all have a "type" string that allows me to tag them as P2SH, P2PK, P2WSH, etc, but the inputs don't.
What I tried up to now is to parse the content of the scriptSig attribute of the inputs. For example, to know if an input is P2PK, I read somewhere that the ASM code of the scriptSig of the input should start with 30. When I compare with some online tools that have already tagged every transaction inputs/outputs, it looks like it's accurate, but I don't have any proof that what I am doing is right.
Is there some kind of online resources with precise specifications allowing me to identify an input? I cannot manage to find any.
Another idea I had is that each output is, obviously, linked to an output. Could I suppose that the type of input is the same as the one of the output it is linked to?
It would make sense to me, but I would rather not jump to conclusions; I still have a lot to learn about Bitcoin.
Thank you very much!