/// Initializes new instance of CScript and fills it with supplied bytes
/// </summary>
/// <param name="bytes">Enumerator interface for byte sequence</param>
- public CScript(IEnumerable<byte> bytes)
+ public CScript(byte[] bytes)
{
codeBytes = new List<byte>(bytes);
}
}
/// <summary>
- /// Adds specified operation to opcode bytes list
+ /// Adds specified operation to instruction list
/// </summary>
/// <param name="opcode"></param>
- public void AddOp(instruction opcode)
+ public void AddInstruction(instruction opcode)
{
if (opcode < instruction.OP_0 || opcode > instruction.OP_INVALIDOPCODE)
{
- throw new CScriptException("CScript::AddOp() : invalid opcode");
+ throw new CScriptException("CScript::AddInstruction() : invalid instruction");
}
codeBytes.Add((byte)opcode);
}
/// <summary>
- /// Adds hash to opcode bytes list.
+ /// Adds hash to instruction list.
/// New items are added in this format:
/// hash_length_byte hash_bytes
/// </summary>
}
/// <summary>
- /// Adds hash to opcode bytes list.
+ /// Adds hash to instruction list.
/// New items are added in this format:
/// hash_length_byte hash_bytes
/// </summary>
}
/// <summary>
- /// Create new OP_PUSHDATAn operator and add it to opcode bytes list
+ /// Create new OP_PUSHDATAn operator and add it to instruction list
/// </summary>
/// <param name="dataBytes">Set of data bytes</param>
public void PushData(byte[] dataBytes)
// OP_PUSHDATA1 0x00 0x01 [0x5a]
codeBytes.Add((byte)instruction.OP_PUSHDATA2);
- byte[] szBytes = Interop.BEBytes((ushort)nCount);
+ var szBytes = Interop.BEBytes((ushort)nCount);
codeBytes.AddRange(szBytes);
}
else if (nCount < 0xffffffff)
// OP_PUSHDATA1 0x00 0x00 0x00 0x01 [0x5a]
codeBytes.Add((byte)instruction.OP_PUSHDATA4);
- byte[] szBytes = Interop.BEBytes((uint)nCount);
+ var szBytes = Interop.BEBytes((uint)nCount);
codeBytes.AddRange(szBytes);
}
{
var wCodeBytes = new ByteQueue(codeBytes);
- instruction opcode; // Current opcode
+ instruction opcode; // Current instruction
byte[] pushArgs; // OP_PUSHDATAn argument
- // Scan opcodes sequence
+ // Scan instructions sequence
while (ScriptCode.GetOp(ref wCodeBytes, out opcode, out pushArgs))
{
if (opcode > instruction.OP_16)
{
- // We don't allow control opcodes here
+ // We don't allow control instructions here
return false;
}
}
var wCodeBytes = new ByteQueue(codeBytes);
byte[] pushArgs; // OP_PUSHDATAn argument
- instruction opcode; // Current opcode
+ instruction opcode; // Current instruction
- // Scan opcodes sequence
+ // Scan instructions sequence
while (ScriptCode.GetOp(ref wCodeBytes, out opcode, out pushArgs))
{
var data = pushArgs;
{
var wCodeBytes = new ByteQueue(codeBytes);
- instruction opcode; // Current opcode
+ instruction opcode; // Current instruction
byte[] pushArgs; // OP_PUSHDATAn argument
int nCount = 0;
var lastOpcode = instruction.OP_INVALIDOPCODE;
- // Scan opcodes sequence
+ // Scan instructions sequence
while (ScriptCode.GetOp(ref wCodeBytes, out opcode, out pushArgs))
{
if (opcode == instruction.OP_CHECKSIG || opcode == instruction.OP_CHECKSIGVERIFY)
// pushes onto the stack:
ByteQueue wScriptSig = scriptSig.GetByteQUeue();
- instruction opcode; // Current opcode
+ instruction opcode; // Current instruction
byte[] pushArgs; // OP_PUSHDATAn argument
while (ScriptCode.GetOp(ref wScriptSig, out opcode, out pushArgs))
{
codeBytes.Clear();
PushData(pubKey.PublicBytes);
- AddOp(instruction.OP_CHECKSIG);
+ AddInstruction(instruction.OP_CHECKSIG);
}
/// <summary>
public void SetDestination(CKeyID ID)
{
codeBytes.Clear();
- AddOp(instruction.OP_DUP);
- AddOp(instruction.OP_HASH160);
+ AddInstruction(instruction.OP_DUP);
+ AddInstruction(instruction.OP_HASH160);
AddHash(ID);
- AddOp(instruction.OP_EQUALVERIFY);
- AddOp(instruction.OP_CHECKSIG);
+ AddInstruction(instruction.OP_EQUALVERIFY);
+ AddInstruction(instruction.OP_CHECKSIG);
}
/// <summary>
public void SetDestination(CScriptID ID)
{
codeBytes.Clear();
- AddOp(instruction.OP_HASH160);
+ AddInstruction(instruction.OP_HASH160);
AddHash(ID);
- AddOp(instruction.OP_EQUAL);
+ AddInstruction(instruction.OP_EQUAL);
}
/// <summary>
public void SetMultiSig(int nRequired, CPubKey[] keys)
{
codeBytes.Clear();
- AddOp(ScriptCode.EncodeOP_N(nRequired));
+ AddInstruction(ScriptCode.EncodeOP_N(nRequired));
foreach (var key in keys)
{
PushData(key.PublicBytes);
}
- AddOp(ScriptCode.EncodeOP_N(keys.Length));
- AddOp(instruction.OP_CHECKMULTISIG);
+ AddInstruction(ScriptCode.EncodeOP_N(keys.Length));
+ AddInstruction(instruction.OP_CHECKMULTISIG);
}
/// <summary>
var sb = new StringBuilder();
var wCodeBytes = new ByteQueue(codeBytes);
- instruction opcode; // Current opcode
+ instruction opcode; // Current instruction
byte[] pushArgs; // OP_PUSHDATAn argument
while (ScriptCode.GetOp(ref wCodeBytes, out opcode, out pushArgs))
{