using System.Linq;
using System.Text;
using System.Collections.Generic;
+using System.Diagnostics.Contracts;
namespace Novacoin
{
- public class CScriptException : Exception
- {
- public CScriptException()
- {
- }
-
- public CScriptException(string message)
- : base(message)
- {
- }
-
- public CScriptException(string message, Exception inner)
- : base(message, inner)
- {
- }
- }
-
/// <summary>
/// Representation of script code
/// </summary>
/// Return a new instance of ByteQueue object for current code bytes
/// </summary>
/// <returns></returns>
- public ByteQueue GetByteQUeue()
+ public ByteQueue GetByteQueue()
{
return new ByteQueue(codeBytes);
}
/// <param name="opcode"></param>
public void AddInstruction(instruction opcode)
{
- if (opcode < instruction.OP_0 || opcode > instruction.OP_INVALIDOPCODE)
- {
- throw new CScriptException("CScript::AddInstruction() : invalid instruction");
- }
+ Contract.Requires<ArgumentException>(opcode >= instruction.OP_0 && opcode <= instruction.OP_INVALIDOPCODE, "Invalid instruction.");
codeBytes.Add((byte)opcode);
}
// This is a pay-to-script-hash scriptPubKey;
// get the last item that the scriptSig
// pushes onto the stack:
- ByteQueue wScriptSig = scriptSig.GetByteQUeue();
+ ByteQueue wScriptSig = scriptSig.GetByteQueue();
instruction opcode; // Current instruction
byte[] pushArgs; // OP_PUSHDATAn argument
return script.codeBytes.ToArray();
}
+ /// <summary>
+ /// Script size
+ /// </summary>
+ public int Size
+ {
+ get { return codeBytes.Count; }
+ }
+
public CScriptID ScriptID
{
get { return new CScriptID(Hash160.Compute160(codeBytes.ToArray())); }