/// </summary>
public byte[] signature;
+ public CBlock(CBlock b)
+ {
+ header = new CBlockHeader(b.header);
+
+ for (int i = 0; i < b.vtx.Length; i++)
+ {
+ vtx[i] = new CTransaction(b.vtx[i]);
+ }
+
+ b.signature.CopyTo(signature, 0);
+ }
+
/// <summary>
/// Parse byte sequence and initialize new block instance
/// </summary>
signature = wBytes.GetItems((int)VarInt.ReadVarInt(ref wBytes));
}
+ public CBlock()
+ {
+ // Initialize empty array of transactions. Please note that such
+ // configuration is not valid real block since it has to provide
+ // at least one transaction.
+ vtx = new CTransaction[0];
+ }
+
/// <summary>
/// Convert current instance into sequence of bytes
/// </summary>
{
}
+ public CBlockHeader(CBlockHeader h)
+ {
+ nVersion = h.nVersion;
+ prevHash = new Hash256(h.prevHash);
+ merkleRoot = new Hash256(h.merkleRoot);
+ nTime = h.nTime;
+ nBits = h.nBits;
+ nNonce = h.nNonce;
+ }
+
/// <summary>
/// Convert current block header instance into sequence of bytes
/// </summary>
/// </summary>
public CTransaction()
{
- vin = new CTxIn[1]; /// Any transaction must provide at least one input ...
- vin[0] = new CTxIn();
-
- vout = new CTxOut[1]; // ... and output.
- vout[0] = new CTxOut();
+ // Initialize empty input and output arrays. Please note that such
+ // configuration is not valid for real transaction, you have to supply
+ // at least one input and one output.
+ vin = new CTxIn[0];
+ vout = new CTxOut[0];
}
/// <summary>
_hashBytes = bytes;
}
+ public Hash(Hash h)
+ {
+ h._hashBytes.CopyTo(_hashBytes, 0);
+ }
+
public bool IsZero
{
get { return !_hashBytes.Any(b => b != 0); }
public Hash160() : base() { }
public Hash160(byte[] bytes) : base(bytes) { }
public Hash160(IEnumerable<byte> bytes) : base(bytes) { }
+ public Hash160(Hash160 h) : base(h) { }
public static Hash160 Compute160(IEnumerable<byte> inputBytes)
{
public Hash256() : base() { }
public Hash256(byte[] bytes) : base(bytes) { }
public Hash256(IEnumerable<byte> bytes) : base(bytes) { }
+ public Hash256(Hash256 h) : base(h) { }
+
public static Hash256 Compute256(IEnumerable<byte> inputBytes)
{
public ScryptHash256() : base() { }
public ScryptHash256(byte[] bytes) : base(bytes) { }
public ScryptHash256(IEnumerable<byte> bytes) : base(bytes) { }
+ public ScryptHash256(ScryptHash256 h) : base(h) { }
/// <summary>
/// Calculate scrypt hash and return new instance of ScryptHash256 class