Simplification of syntax
[NovacoinLibrary.git] / Novacoin / COutPoint.cs
1 \feffusing System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6
7 namespace Novacoin
8 {
9     public class COutPoint
10     {
11         /// <summary>
12         /// Hash of parent transaction.
13         /// </summary>
14         public Hash256 hash;
15
16         /// <summary>
17         /// Parent input number.
18         /// </summary>
19         public uint n;
20
21         public COutPoint()
22         {
23             hash = new Hash256();
24             n = uint.MaxValue;
25         }
26
27         public COutPoint(Hash256 hashIn, uint nIn)
28         {
29             hash = hashIn;
30             n = nIn;
31         }
32
33         public COutPoint(COutPoint o)
34         {
35             hash = new Hash256(o.hash);
36             n = o.n;
37         }
38
39         public COutPoint(IEnumerable<byte> bytes)
40         {
41             hash = new Hash256(bytes);
42             n = BitConverter.ToUInt32(bytes.ToArray(), 32);
43         }
44
45         public bool IsNull
46         {
47             get { return hash.IsZero && n == uint.MaxValue; }
48         }
49
50         public IList<byte> Bytes
51         {
52             get
53             {
54                 List<byte> r = new List<byte>();
55                 r.AddRange(hash.hashBytes);
56                 r.AddRange(BitConverter.GetBytes(n));
57
58                 return r;
59             }
60         }
61
62         public override string ToString()
63         {
64             StringBuilder sb = new StringBuilder();
65             sb.AppendFormat("COutPoint({0}, {1})", hash.ToString(), n);
66
67             return sb.ToString();
68         }
69
70         
71     }
72
73 }