Author

Topic: How are transactions separated on bit-level in blocks? (Read 754 times)

full member
Activity: 237
Merit: 100
Smile while thinking.
Thanks, that's the details I was looking for

Funny you want to have bit-scale details.  Have a look at the easy to understand and technically detailed doc : https://bitcoin.org/en/developer-reference#raw-transaction-format

Kex
newbie
Activity: 22
Merit: 7
Thanks, that's the details I was looking for
legendary
Activity: 3472
Merit: 4794
Transactions have a known calculable size when it is parsed. So you will know that when a transaction ends and the next begins.

Specifically...

  • Each transaction starts with 32 bits (set of thirty-two 0 and 1 digits) that store a version number.
  • Following that is a "set of 0 and 1" that tell how many bits (actually how many bytes, but you can multiply by 8 to get the quantity of 0 and 1) in the transaction inputs.*
  • Following that is a "set of 0 and 1" representing all the inputs. This set is exactly the amount indicated in the previous "how many bits" value.
  • Following that is a "set of 0 and 1" that tell how many bits (actually how many bytes, but you can multiply by 8 to get the quantity of 0 and 1) in the transaction outputs.*
  • Following that is a "set of 0 and 1" representing all the outputs. This set is exactly the amount indicated in the previous "how many bits" value.
  • Following that is 32 bits that represent the locktime.

* note, there is a special pattern to the first eight 0 and 1 values of the section that "tells how many bits". This pattern allows the program to know when it has read enough 0 and 1 to determine the appropriate value. If this section starts with 11111111, then the next sixty-four 0 and 1 are used to indicate the size of the inputs or outputs. If it starts with 11111110, then the next thirty-two 0 and 1 are used to indicate the size of the inputs or outputs,  If it starts with 11111101, then the next sixteen 0 and 1 are used to indicate the size of the inputs or outputs. If it starts with anything else, then these 8 values are themselves the indication of the size of the inputs or outputs, and there is no need to use any additional digits to determine that size.

staff
Activity: 3458
Merit: 6793
Just writing some code
Transactions have a known calculable size when it is parsed. So you will know that when a transaction ends and the next begins.
newbie
Activity: 22
Merit: 7
Hi,

A quick question. Assume that a block body contains several transactions (tx), and none of these transactions are of equal length. On bit level, transactions are represented by a set of 0 and 1. A set of tx will therefore result in a set of 0 and 1. Now, if a block contains multiple tx, how can the receiver of a block distinguish each transaction in the block body?

Thanks.
Jump to: