Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Anonymous Kid on October 28, 2018, 06:10:10 PM



Title: How are bitcoin blocks verified?
Post by: Anonymous Kid on October 28, 2018, 06:10:10 PM
I see in the bitcoin wiki there is something called "script" which compiles down to some bytecode to be run by a very very basic virtual machine.
Does this mean that each block is actually just a string/array of bytes when it comes in and is processed by a node?
so a block in its "true" format would look something like [0x01, 0x04, 0x0f, 0xa1.... etc. ?

and then the node that recieves the block just puts the bytes into the interpreter to be run by the bitcoin VM?
or is there some plaintext involved in the block as well? so it looks something like JSON;
{
   blockhash: 12983092....,
   transactions: [ {8123098...}, {12381923...}],
   timestamp: "08:00:23 12/09/2017"
}

which is correct? a block is pure bytecode or JSON? what would a bitcoincore node understand when receiving a new block?


Title: Re: How are bitcoin blocks verified?
Post by: achow101 on October 29, 2018, 04:01:13 AM
By definition, everything in a computer is a string of bytes, even text  ;D



All kidding aside, a block has a serialized byte format. It is not transmitted over the network in JSON. The JSON output that you get from Bitcoin Core is merely something that is human readable. That is not actually how blocks are transmitted over the network.

The block format is just bytes with bytes at certain positions having specific meanings, as defined by the format. You can see the hexadecimal representation of these bytes if you call getblock with verbosity level 0 (i.e. getblock <hash> 0).

A block is not a script. Scripts are part of transactions and are in a specific field for scripts only.


Title: Re: How are bitcoin blocks verified?
Post by: pebwindkraft on October 29, 2018, 08:21:15 AM
Same request and further details here:

https://bitcoin.stackexchange.com/questions/80487/how-are-blocks-verified


Title: Re: How are bitcoin blocks verified?
Post by: Anonymous Kid on October 29, 2018, 09:45:06 AM
Same request and further details here:

https://bitcoin.stackexchange.com/questions/80487/how-are-blocks-verified
Thanks for asking the question there haha. i probably should have gone there first.
Achow explained pretty much what is was looking for anyway :)