X-Git-Url: https://git.novaco.in/?p=NovacoinLibrary.git;a=blobdiff_plain;f=Novacoin%2FCScript.cs;fp=Novacoin%2FCScript.cs;h=abdad9c238b64cfd219295ebe5e86e01e3f9ea15;hp=2ac0c73de7bd2a1cb387e65d613e6faa611f04c5;hb=6dfa6de57c6493b76856acc9ab510ac31962c327;hpb=c45ca30262ee9cf9e6be22d31c0a2dddeffe4e17 diff --git a/Novacoin/CScript.cs b/Novacoin/CScript.cs index 2ac0c73..abdad9c 100644 --- a/Novacoin/CScript.cs +++ b/Novacoin/CScript.cs @@ -21,6 +21,7 @@ using System.Linq; using System.Text; using System.Collections.Generic; using System.Diagnostics.Contracts; +using System.Numerics; namespace Novacoin { @@ -58,9 +59,26 @@ namespace Novacoin } /// + /// Add serialized number to instructions list. + /// + /// Number to add. + public void AddNumber(int n) + { + if (n == -1 || (n >= 1 && n <= 16)) + { + codeBytes.Add((byte)ScriptCode.EncodeOP_N(n, true)); + } + else + { + BigInteger bn = n; + PushData(bn.ToByteArray()); + } + } + + /// /// Adds specified operation to instruction list /// - /// + /// Instruction to add. public void AddInstruction(instruction opcode) { Contract.Requires(opcode >= instruction.OP_0 && opcode <= instruction.OP_INVALIDOPCODE, "Invalid instruction.");