2

I am currently looking into the structure of bitcoin transactions. As an example, I took the hex dump of this transaction:

010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff5403df550a1b4d696e656420627920416e74506f6f6c373138fd004702c13ba070fabe6d6d6d9986fd3aedb9f8b00fab3c74c2e1d399fd0e6bc1d964aa57a08f78ac2d648002000000000000001eb50000c1377c00ffffffff04653c3a2a000000001976a91411dbe48cc6b617f9c6adaf4d9ed5f625b1c7cb5988ac0000000000000000266a24aa21a9ede0721e21cc17367eb4fcccf94c7e6ebc54757a693515f809307d4d6a31e0c8500000000000000000266a24b9e11b6d6eab9aaf2ccdc3cb05fb15989c512b84c8ef5f498559cd4d66e6104de8f9cdb100000000000000002b6a2952534b424c4f434b3a93320d7a461a95b953bd18e40aa031b5470d6258ccd82011999a5b290031529c0120000000000000000000000000000000000000000000000000000000000000000000000000

Looking at the JSON format, the transaction version should be 1.

I've read that the first 4 bytes of a transaction encode the version number (source).

2 hex characters are one byte, so 4 bytes are 8 hex characters. So the version is 01000000. But that would be 16777216, not 1.

What am I doing wrong?

5

From https://en.bitcoin.it/wiki/Protocol_documentation#Transaction_Verification we learn :

Almost all integers are encoded in little endian. Only IP or port number are encoded big endian.

You should look at the https://en.m.wikipedia.org/wiki/Endianness and flip the order of the bitstring to have the bit at the correct position

Using an online hex converter like this one https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ you can actually see that the hex interpreted as uint32 results to 1

enter image description here

1
  • 1
    You gave me the information that I need to change the order of the chars in the hexstring from "01234567" to "67452301". That was very helpful. Thank you 🤗 – Martin Thoma Apr 3 at 5:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.