VarInt class, TxIn/TXOut/Tx serializarion, some CKey and CPubKey methods
[NovacoinLibrary.git] / Novacoin / CTxOut.cs
1 \feffusing System;
2 using System.Text;
3 using System.Collections.Generic;
4
5 namespace Novacoin
6 {
7         /// <summary>
8         /// Transaction output.
9         /// </summary>
10         public class CTxOut
11         {
12                 /// <summary>
13                 /// Input value.
14                 /// </summary>
15                 private ulong nValue = 0;
16
17                 /// <summary>
18                 /// Second half of script which contains spending instructions.
19                 /// </summary>
20                 private byte[] scriptPubKey;
21
22                 public CTxOut ()
23                 {
24                 }
25
26         public IList<byte> ToBytes()
27         {
28             List<byte> resultBytes = new List<byte>();
29
30             resultBytes.AddRange(Interop.LEBytes(nValue)); // txout value
31             resultBytes.AddRange(VarInt.EncodeVarInt(scriptPubKey.LongLength)); // scriptPubKey length
32             resultBytes.AddRange(scriptPubKey); // scriptPubKey
33
34             return resultBytes;
35         }
36
37                 public override string ToString ()
38                 {
39                         StringBuilder sb = new StringBuilder ();
40                         sb.AppendFormat ("CTxOut(nValue={0},scriptPubKey={1}", nValue, scriptPubKey.ToString());
41
42                         return sb.ToString ();
43                 }
44         }
45 }
46