VarInt class, TxIn/TXOut/Tx serializarion, some CKey and CPubKey methods
[NovacoinLibrary.git] / Novacoin / CTxOut.cs
index 8ac5c7c..679c692 100644 (file)
@@ -1,5 +1,6 @@
 \feffusing System;
 using System.Text;
+using System.Collections.Generic;
 
 namespace Novacoin
 {
@@ -11,17 +12,28 @@ namespace Novacoin
                /// <summary>
                /// Input value.
                /// </summary>
-               public ulong nValue = 0;
+               private ulong nValue = 0;
 
                /// <summary>
                /// Second half of script which contains spending instructions.
                /// </summary>
-               public byte[] scriptPubKey;
+               private byte[] scriptPubKey;
 
                public CTxOut ()
                {
                }
 
+        public IList<byte> ToBytes()
+        {
+            List<byte> resultBytes = new List<byte>();
+
+            resultBytes.AddRange(Interop.LEBytes(nValue)); // txout value
+            resultBytes.AddRange(VarInt.EncodeVarInt(scriptPubKey.LongLength)); // scriptPubKey length
+            resultBytes.AddRange(scriptPubKey); // scriptPubKey
+
+            return resultBytes;
+        }
+
                public override string ToString ()
                {
                        StringBuilder sb = new StringBuilder ();