<p>I'd like to partially answer your question on the tx structure: in general you are right, here some more detail, and yes, you can have several TX_INs and TX_OUTs:</p>

<pre><code>VERSION
TX_IN COUNT
  TX_IN[0] OutPoint hash
  TX_IN[0] OutPoint index
  TX_IN[0] Script Length
  TX_IN[0] Script Sig
  TX_IN[0] Sequence      

TX_OUT COUNT
  TX_OUT[0] Value/Amount in Satoshi
  TX_OUT[0] PK_Script Length
  TX_OUT[0] pk_script     
 LOCK_TIME
</code></pre>

<p>So in general the VERSION field at the very beginning and the LOCKTIME at the end is an additional piece. For sure you find further details in the developper section of bitcoin.org, and in Andreas' book "Mastering Bitcoin" (also online available). Avery good overview of the details was also provided here: <a href="http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html" rel="nofollow noreferrer">http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html</a>
I am not experienced enough to answer the part on the blocks, but it is also mentioned in the links. </p>

CC BY-SA 3.0
2017-11-10T21:33:46.850Z
2017-11-10T21:33:46.850Z
pebwindkraft
<p>If I understand correctly block consists of:</p>

<ul>
<li>block header,</li>
<li>transactions counter,</li>
<li>list of signed transactions.</li>
</ul>

<p>Each signed transaction consists of transaction itself and appended signature.</p>

<p>Each transaction consists of:</p>

<ul>
<li>transaction version no,</li>
<li>number of inputs, </li>
<li>inputs themselves, </li>
<li>number of outputs, </li>
<li>outputs themselves and </li>
<li>locktime.</li>
</ul>

<p>Each input consists of:</p>

<ul>
<li>Reference to its outputing transaction</li>
<li>index of output in that transaction</li>
<li>scriptSig</li>
</ul>

<p>Each output consists of:</p>

<ul>
<li>output value</li>
<li>scriptPubKey</li>
</ul>

<p>Is this structure correct?</p>

CC BY-SA 3.0
2017-11-10T21:22:58.073Z
Where did you get 81 bytes from?
Claris
CC BY-SA 3.0
2017-11-11T10:17:47.077Z
Found that figure on several places for example here: http://bitexperts.com/Question/Detail/3333/what-is-bitcoin-block-header-size-in-bytes, although 80 is more commonly shown. But here https://en.bitcoin.it/wiki/Block I find now there is more to the structure.
croraf
CC BY-SA 3.0
2017-11-11T10:19:05.070Z
It’s 80 bytes, not 81. They’re calling the number of transactions part of the header (and assuming its one byte), which it’s not.
Claris
CC BY-SA 3.0
2017-11-11T10:20:35.873Z
So in general it is 1-9 bytes, is not part of the header and shows the actual number of transactions in this block (and not always 0)?
croraf
CC BY-SA 3.0
2017-11-11T10:22:14.120Z
Right. It’s just part of the way it’s encoded though, that varint for the number of transactions isn’t included in any hash. It means you don’t know the size of the block until you’ve parsed every single transaction too.
Claris
CC BY-SA 3.0
2017-11-11T10:33:33.527Z
Don't you know the size from the block size field https://chat.stackexchange.com/rooms/68577/room-for-croraf-and-eponymous
croraf
<transactions><block>
What is the structure of bitcoin block?
croraf
# What is the structure of bitcoin block?

(Asked by: username_0 on 2017-11-10)

If I understand correctly block consists of:

* block header,
* transactions counter,
* list of signed transactions.

Each signed transaction consists of transaction itself and appended signature.

Each transaction consists of:

* transaction version no,
* number of inputs,
* inputs themselves,
* number of outputs,
* outputs themselves and
* locktime.

Each input consists of:

* Reference to its outputing transaction
* index of output in that transaction
* scriptSig

Each output consists of:

* output value
* scriptPubKey

Is this structure correct?

**Tags:** transactions, block

> **Comments:**
> **username_1**: Where did you get 81 bytes from?  
> **username_0**: Found that figure on several places for example here: http://bitexperts.com/Question/Detail/3333/what-is-bitcoin-block-header-size-in-bytes, although 80 is more commonly shown. But here https://en.bitcoin.it/wiki/Block I find now there is more to the structure.  
> **username_1**: It’s 80 bytes, not 81. They’re calling the number of transactions part of the header (and assuming its one byte), which it’s not.  
> **username_0**: So in general it is 1-9 bytes, is not part of the header and shows the actual number of transactions in this block (and not always 0)?  
> **username_1**: Right. It’s just part of the way it’s encoded though, that varint for the number of transactions isn’t included in any hash. It means you don’t know the size of the block until you’ve parsed every single transaction too.  
> **username_0**: Don't you know the size from the block size field https://chat.stackexchange.com/rooms/68577/room-for-username_0-and-eponymous  

---

## 1 answers

### Answer by username_2 on 2017-11-10. Score: 1

I'd like to partially answer your question on the tx structure: in general you are right, here some more detail, and yes, you can have several TX\_INs and TX\_OUTs:

```
VERSION
TX_IN COUNT
  TX_IN[0] OutPoint hash
  TX_IN[0] OutPoint index
  TX_IN[0] Script Length
  TX_IN[0] Script Sig
  TX_IN[0] Sequence      

TX_OUT COUNT
  TX_OUT[0] Value/Amount in Satoshi
  TX_OUT[0] PK_Script Length
  TX_OUT[0] pk_script     
 LOCK_TIME

```

So in general the VERSION field at the very beginning and the LOCKTIME at the end is an additional piece. For sure you find further details in the developper section of bitcoin.org, and in Andreas' book "Mastering Bitcoin" (also online available). Avery good overview of the details was also provided here: <http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html>
I am not experienced enough to answer the part on the blocks, but it is also mentioned in the links.


---

