CODESEPARATOR workaround
[NovacoinLibrary.git] / Novacoin / ScriptCode.cs
index 4f86d73..eb5f4dc 100644 (file)
@@ -267,7 +267,7 @@ namespace Novacoin
             // Immediate operand
             if (opcode <= instruction.OP_PUSHDATA4)
             {
-                byte[] szBytes = new byte[4] { 0, 0, 0, 0 }; // Zero length
+                var szBytes = new byte[4] { 0, 0, 0, 0 }; // Zero length
 
                 try
                 {
@@ -685,7 +685,7 @@ namespace Novacoin
 
             // In case concatenating two scripts ends up with two codeseparators,
             // or an extra one at the end, this prevents all those possible incompatibilities.
-            script.RemovePattern(new byte[] { (byte)instruction.OP_CODESEPARATOR });
+            //script.RemovePattern(new byte[] { (byte)instruction.OP_CODESEPARATOR });     // TODO: issue here, due to false matches this breaks the validation of some scripts
 
             // Blank out other inputs' signatures
             for (int i = 0; i < txTmp.vin.Length; i++)
@@ -1568,11 +1568,11 @@ namespace Novacoin
                                         return false;
                                     }
 
-                                    byte[] sigBytes = stacktop(ref stack, -2);
-                                    byte[] pubkeyBytes = stacktop(ref stack, -1);
+                                    var sigBytes = stacktop(ref stack, -2);
+                                    var pubkeyBytes = stacktop(ref stack, -1);
 
                                     // Subset of script starting at the most recent codeseparator
-                                    CScript scriptCode = new CScript(script.Bytes.Skip(nCodeHashBegin));
+                                    var scriptCode = new CScript(script.Bytes.Skip(nCodeHashBegin).ToArray());
 
                                     // There's no way for a signature to sign itself
                                     scriptCode.RemovePattern(sigBytes);
@@ -1639,7 +1639,7 @@ namespace Novacoin
                                     }
 
                                     // Subset of script starting at the most recent codeseparator
-                                    CScript scriptCode = new CScript(script.Bytes.Skip(nCodeHashBegin));
+                                    var scriptCode = new CScript(script.Bytes.Skip(nCodeHashBegin).ToArray());
 
                                     // There is no way for a signature to sign itself, so we need to drop the signatures
                                     for (int k = 0; k < nSigsCount; k++)