New constructor for block header class
[NovacoinLibrary.git] / Novacoin / CBlockHeader.cs
index e8b257f..8c07cf2 100644 (file)
@@ -1,4 +1,5 @@
 \feffusing System;
+using System.Linq;
 using System.Text;
 using System.Collections.Generic;
 
@@ -56,6 +57,16 @@ namespace Novacoin
             nNonce = h.nNonce;
         }
 
+        public CBlockHeader(byte[] bytes)
+        {
+            nVersion = BitConverter.ToUInt32(bytes, 0);
+            prevHash = new Hash256(bytes.Skip(4).Take(32).ToArray());
+            merkleRoot = new Hash256(bytes.Skip(36).Take(32).ToArray());
+            nTime = BitConverter.ToUInt32(bytes, 68);
+            nBits = BitConverter.ToUInt32(bytes, 72);
+            nNonce = BitConverter.ToUInt32(bytes, 76);
+        }
+
         /// <summary>
         /// Convert current block header instance into sequence of bytes
         /// </summary>