/// <param name="blockBytes"></param>
public CBlock (IList<byte> blockBytes)
{
- header = new CBlockHeader();
-
WrappedList<byte> wBytes = new WrappedList<byte>(blockBytes);
// Fill the block header fields
- header.nVersion = BitConverter.ToUInt32(wBytes.GetItems(4), 0);
- header.prevHash = new Hash256(wBytes.GetItems(32));
- header.merkleRoot = new Hash256(wBytes.GetItems(32));
- header.nTime = BitConverter.ToUInt32(wBytes.GetItems(4), 0);
- header.nBits = BitConverter.ToUInt32(wBytes.GetItems(4), 0);
- header.nNonce = BitConverter.ToUInt32(wBytes.GetItems(4), 0);
+ header = new CBlockHeader(wBytes.GetItems(80));
// Parse transactions list
vtx = CTransaction.ReadTransactionsList(ref wBytes);
\feffusing System;
+using System.Linq;
using System.Text;
using System.Collections.Generic;
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>
/// <summary>
/// Basic sanity checking
/// </summary>
- /// <returns></returns>
public bool IsValid
{
get
List<byte> r = new List<byte>();
r.Add((byte)(AddrType.PUBKEY_ADDRESS));
-
r.AddRange(PublicBytes);
return AddressTools.Base58EncodeCheck(r);
/// <summary>
/// Transaction variant number, irrelevant if nLockTime isn't specified. Its value is 0xffffffff by default.
/// </summary>
- public uint nSequence = 0xffffffff;
+ public uint nSequence = uint.MaxValue;
/// <summary>
/// Initialize new CTxIn instance as copy of another one.
public void SetNull()
{
nValue = -1;
+ scriptPubKey = new CScript();
}
/// <summary>
public void SetEmpty()
{
nValue = 0;
- scriptPubKey.SetNullDestination();
+ scriptPubKey = new CScript();
}
public bool IsNull
/// <param name="bytesList">List of bytes</param>
public Hash(IEnumerable<byte> bytes)
{
- _hashBytes = bytes.Take<byte>(hashSize).ToArray<byte>();
+ _hashBytes = bytes.Take(hashSize).ToArray();
}
public Hash(byte[] bytes)
using System.Security.Cryptography;
-
-
namespace Novacoin
{
/// <summary>