i am currently parsing blockchain transaction data from the raw hex blk00000.dat files downloaded by Bitcoin core. In order to validate, i compare my results with blockchain.info from time to time.
While the major part of my parsing is already correct, i came accross a problem with the conversion of the output script to the corresponding address.
Many of the addresses are already correctly parsed, as well, however there are some exceptions where the results are not the same as listed on blockchain.info. In my mind, it seems to be a problem with the transaction type. Apparently, for a transaction different from P2PKH, the output script will look differently, such that i cannot run the script through the same function that converts to the address all the time.
I think to have figured out that the public keys in P2PKH-transactions scripts begin with 76 all the time, is that enough to determine the type as P2PKH?
Furthermore, i came across some few transactions that begin with 4104 and end with ac. For those ones, I have to use a different function to convert to the address, then it works.
Lastly, i wanted to ask, what other transaction types i could come across? I need to parse every transaction script to an address 100% correctly, thus i need to cover all possible cases.
When searching on the web for pre-written code, i found many partly useful, but also false or maybe old snippets. What i am searching for is a general function that i can parse the output script (or the complete raw transaction string) to and that delivers the output addresses and values of BTC / Satoshi sent to these.
Of course, if you can recommend an overall python parser for the rawtx hex strings from the .dat-files, i would be also glad :) The main info i need for each transaction: - the hash of the corresponding block - transaction time (block time) - number of inputs and outputs - inputs [(block index (vout), txid), (...)] - outputs [(value, address), (...)] - the overall transaction hash
Thank you.