Print signature for proof-of-stake blocks only
authorCryptoManiac <balthazar@yandex.ru>
Sat, 22 Aug 2015 22:14:22 +0000 (01:14 +0300)
committerCryptoManiac <balthazar@yandex.ru>
Sat, 22 Aug 2015 22:14:22 +0000 (01:14 +0300)
Novacoin/CBlock.cs

index 184b5f6..7286622 100644 (file)
@@ -73,13 +73,13 @@ namespace Novacoin
             }
         }
 
+        /// <summary>
+        /// Was this signed correctly?
+        /// </summary>
         public bool SignatureOK
         {
             get
             {
-                IList<IEnumerable<byte>> solutions;
-                txnouttype whichType;
-
                 if (IsProofOfStake)
                 {
                     if (signature.Length == 0)
@@ -87,6 +87,9 @@ namespace Novacoin
                         return false; // No signature
                     }
 
+                    txnouttype whichType;
+                    IList<IEnumerable<byte>> solutions;
+
                     if (!ScriptCode.Solver(vtx[1].vout[1].scriptPubKey, out whichType, out solutions))
                     {
                         return false; // No solutions found
@@ -120,7 +123,7 @@ namespace Novacoin
         }
 
         /// <summary>
-        /// Convert current instance into sequence of bytes
+        /// Get current instance as sequence of bytes
         /// </summary>
         /// <returns>Byte sequence</returns>
         public IList<byte> Bytes 
@@ -152,12 +155,15 @@ namespace Novacoin
 
             foreach(CTransaction tx in vtx)
             {
-                sb.AppendFormat("{0},\n", tx.ToString());
+                sb.AppendFormat("{0}", tx.ToString());
             }
 
-            sb.AppendFormat("signature={0})\n", Interop.ToHex(signature));
-            sb.AppendFormat("signatureOK={0})\n", SignatureOK);
+            if (IsProofOfStake)
+            {
+                sb.AppendFormat(", signature={0}, signatureOK={1}\n", Interop.ToHex(signature), SignatureOK);
+            }
 
+            sb.Append(")");
 
             // TODO
             return sb.ToString();