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.
Script is a stack-based language that is used to validate input and output scripts in transactions. Script is purposely designed to lack Turing-completeness (no loops) so that it is deterministic in nature. (No infinite loops, etc). An input/output is considered to be "valid" when the top stack item is true (or 0x01).
Does this mean that each block is actually just a string/array of bytes when it comes in and is processed by a node?
Bitcoin nodes validate transactions, Bitcoin miners compute blocks in accordance with the Proof-of-Work model defined in the Bitcoin protocol. That being said, yes, technically the raw block data is an array of hexadecimal bytes. When miners begin mining the block, they are only hashing the header of the block (first 80 bytes) which includes the following information:
nVersion|hashPrevBlock|hashMerkleRoot|Time|Bits|Nonce
They can get away with doing this because the hashMerkleRoot
value is a reference to the hash of all the transactions in the block they are mining. These transactions have been validated by nodes.
In Bitcoin-core you can specify serialization as the second parameter in the getblock
command. By default it will nicely display the data in a JSON like output, although it is really a long hexadecimal output.
Example:
getblock 00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09 0
Output: 010000007de867cc8adc5cc8fb6b898ca4462cf9fd66...