2 using System.Collections.Generic;
7 /// Represents the block. Block consists of header, transaction array and header signature.
14 public CBlockHeader header;
17 /// Transactions array.
19 public CTransaction[] tx;
22 /// Block header signature.
24 public byte[] signature;
27 /// Parse byte sequence and initialize new block instance
29 /// <param name="blockBytes"></param>
30 public CBlock (List<byte> blockBytes)
32 header = new CBlockHeader();
34 WrappedList<byte> wBytes = new WrappedList<byte>(blockBytes);
36 // Fill the block header fields
37 header.nVersion = Interop.LEBytesToUInt32(wBytes.GetItems(4));
38 header.prevHash = new Hash256(wBytes.GetItems(32));
39 header.merkleRoot = new Hash256(wBytes.GetItems(32));
40 header.nTime = Interop.LEBytesToUInt32(wBytes.GetItems(4));
41 header.nBits = Interop.LEBytesToUInt32(wBytes.GetItems(4));
42 header.nNonce = Interop.LEBytesToUInt32(wBytes.GetItems(4));
44 // Parse transactions list
45 tx = CTransaction.ReadTransactionsList(ref wBytes);
47 // Read block signature
48 signature = wBytes.GetItems((int)VarInt.ReadVarInt(ref wBytes));
51 public override string ToString()
54 return base.ToString();