Correct coinbase handling
[NovacoinLibrary.git] / Novacoin / CTxIn.cs
index d079d15..b840f1f 100644 (file)
@@ -42,6 +42,13 @@ namespace Novacoin
         }
 
         /// <summary>
+        /// Initialize an empty instance of CTxIn class
+        /// </summary>
+        public CTxIn()
+        {
+        }
+
+        /// <summary>
         /// Get raw bytes representation of our input.
         /// </summary>
         /// <returns>Byte sequence.</returns>
@@ -58,10 +65,23 @@ namespace Novacoin
             return inputBytes;
         }
 
+        public bool IsCoinBase()
+        {
+            return txID.IsZero();
+        }
+
                public override string ToString ()
                {
                        StringBuilder sb = new StringBuilder ();
-                       sb.AppendFormat ("CTxIn(txId={0},n={1},scriptSig={2}", txID.ToString(), n, scriptSig.ToString());
+
+            if (IsCoinBase())
+            {
+                sb.AppendFormat("CTxIn(txId={0},coinbase={2},nSequence={3})", txID.ToString(), n, Interop.ToHex(scriptSig), nSequence);
+            }
+            else
+            {
+                sb.AppendFormat("CTxIn(txId={0},n={1},scriptSig={2},nSequence={3})", txID.ToString(), n, (new CScript(scriptSig)).ToString(), nSequence);
+            }
 
                        return sb.ToString ();
                }