1
I've previously been using bitcoin-cli decoderawtransaction to get human readable bitcoin transaction data but am just learning that it's not only decoding the raw transaction but also adding extra derived fields (e.g. txid, hash) that aren't explicitly stated within the transaction held in the blockchain.
Purely as a means of education I want to be able to interact with exactly the transaction data that's stored by bitcoin in blocks/mempool with no extra extrapolated data.
What's the best way to get this data?
thanks - I'm accepting as the answer, but how did you generate that - via a library or with your own code? If it's the latter, any pseudocode you could share for decoding would be very helpful. – d3wannabe – 2019-07-19T07:09:46.060
@d3wannabe By hand! With the raw hex and the serialization spec you can sort it all out byte by byte. – pinhead – 2019-07-19T13:41:36.113
thanks @pinhead - so "field size" is literally # of characters/bytes? If so, the wiki says version is 4, but you knew to take 8 - how? Also a field like tx_in count (which has a size of 1+) - how do you know it wasn't 018 instead of 01? Think I might be misunderstanding the idea of field size – d3wannabe – 2019-07-22T04:31:49.023
@d3wannabe You might be mistaking bytes for hex characters. For example,
01234567is a hex string that represents 4 bytes. – pinhead – 2019-07-22T04:42:35.010