/// Is it true that script doesn't contain anything except push value operations?
/// </summary>
/// <returns>Checking result</returns>
- public bool IsPushonly()
+ public bool IsPushonly
{
- WrappedList<byte> wCodeBytes = new WrappedList<byte>(codeBytes);
-
- opcodetype opcode; // Current opcode
- IEnumerable<byte> pushArgs; // OP_PUSHDATAn argument
-
- // Scan opcodes sequence
- while (ScriptCode.GetOp(ref wCodeBytes, out opcode, out pushArgs))
+ get
{
- if (opcode > opcodetype.OP_16)
+ WrappedList<byte> wCodeBytes = new WrappedList<byte>(codeBytes);
+
+ opcodetype opcode; // Current opcode
+ IEnumerable<byte> pushArgs; // OP_PUSHDATAn argument
+
+ // Scan opcodes sequence
+ while (ScriptCode.GetOp(ref wCodeBytes, out opcode, out pushArgs))
{
- // We don't allow control opcodes here
- return false;
+ if (opcode > opcodetype.OP_16)
+ {
+ // We don't allow control opcodes here
+ return false;
+ }
}
- }
- return true;
+ return true;
+ }
}
/// <summary>
/// Is it true that script doesn't contain non-canonical push operations?
/// </summary>
/// <returns>Checking result</returns>
- public bool HashOnlyCanonicalPushes()
+ public bool HasOnlyCanonicalPushes
{
- WrappedList<byte> wCodeBytes = new WrappedList<byte>(codeBytes);
-
- opcodetype opcode; // Current opcode
- IEnumerable<byte> pushArgs; // OP_PUSHDATAn argument
-
- // Scan opcodes sequence
- while (ScriptCode.GetOp(ref wCodeBytes, out opcode, out pushArgs))
+ get
{
- byte[] data = pushArgs.ToArray();
+ WrappedList<byte> wCodeBytes = new WrappedList<byte>(codeBytes);
- if (opcode < opcodetype.OP_PUSHDATA1 && opcode > opcodetype.OP_0 && (data.Length == 1 && data[0] <= 16))
- {
- // Could have used an OP_n code, rather than a 1-byte push.
- return false;
- }
- if (opcode == opcodetype.OP_PUSHDATA1 && data.Length < (int)opcodetype.OP_PUSHDATA1)
- {
- // Could have used a normal n-byte push, rather than OP_PUSHDATA1.
- return false;
- }
- if (opcode == opcodetype.OP_PUSHDATA2 && data.Length <= 0xFF)
- {
- // Could have used an OP_PUSHDATA1.
- return false;
- }
- if (opcode == opcodetype.OP_PUSHDATA4 && data.LongLength <= 0xFFFF)
+ opcodetype opcode; // Current opcode
+ IEnumerable<byte> pushArgs; // OP_PUSHDATAn argument
+
+ // Scan opcodes sequence
+ while (ScriptCode.GetOp(ref wCodeBytes, out opcode, out pushArgs))
{
- // Could have used an OP_PUSHDATA2.
- return false;
+ byte[] data = pushArgs.ToArray();
+
+ if (opcode < opcodetype.OP_PUSHDATA1 && opcode > opcodetype.OP_0 && (data.Length == 1 && data[0] <= 16))
+ {
+ // Could have used an OP_n code, rather than a 1-byte push.
+ return false;
+ }
+ if (opcode == opcodetype.OP_PUSHDATA1 && data.Length < (int)opcodetype.OP_PUSHDATA1)
+ {
+ // Could have used a normal n-byte push, rather than OP_PUSHDATA1.
+ return false;
+ }
+ if (opcode == opcodetype.OP_PUSHDATA2 && data.Length <= 0xFF)
+ {
+ // Could have used an OP_PUSHDATA1.
+ return false;
+ }
+ if (opcode == opcodetype.OP_PUSHDATA4 && data.LongLength <= 0xFFFF)
+ {
+ // Could have used an OP_PUSHDATA2.
+ return false;
+ }
}
- }
- return true;
+ return true;
+ }
}
/// <summary>
{
// Sender provides hash of pubkey, receiver provides signature and pubkey
// OP_DUP OP_HASH160 20 [20 byte hash] OP_EQUALVERIFY OP_CHECKSIG
-
return (codeBytes.Count == 25 &&
codeBytes[0] == (byte)opcodetype.OP_DUP &&
codeBytes[1] == (byte)opcodetype.OP_HASH160 &&
/// <summary>
/// Access to script code.
/// </summary>
- public IEnumerable<byte> Enumerable
+ public IEnumerable<byte> Bytes
{
get { return codeBytes; }
}
typeRet = txnouttype.TX_SCRIPTHASH;
// Take 20 bytes with offset of 2 bytes
- IEnumerable<byte> hashBytes = scriptPubKey.Enumerable.Skip(2).Take(20);
+ IEnumerable<byte> hashBytes = scriptPubKey.Bytes.Skip(2).Take(20);
solutions.Add(hashBytes);
return true;
typeRet = txnouttype.TX_PUBKEYHASH;
// Take 20 bytes with offset of 3 bytes
- IEnumerable<byte> hashBytes = scriptPubKey.Enumerable.Skip(3).Take(20);
+ IEnumerable<byte> hashBytes = scriptPubKey.Bytes.Skip(3).Take(20);
solutions.Add(hashBytes);
return true;
IEnumerable<byte> args1, args2;
- byte last1 = script1.Enumerable.Last();
- byte last2 = script2.Enumerable.Last();
+ byte last1 = script1.Bytes.Last();
+ byte last2 = script2.Bytes.Last();
while (true)
{