if (opcode <= instruction.OP_PUSHDATA4)
{
var szBytes = new byte[4] { 0, 0, 0, 0 }; // Zero length
+ int nSize = 0;
try
{
if (opcode < instruction.OP_PUSHDATA1)
{
// Zero value instructions (OP_0, OP_FALSE)
- szBytes[3] = (byte)opcode;
+ nSize = (int) opcode;
}
else if (opcode == instruction.OP_PUSHDATA1)
{
// The next byte contains the number of bytes to be pushed onto the stack,
// i.e. you have something like OP_PUSHDATA1 0x01 [0x5a]
- szBytes[3] = codeBytes.Get();
+ nSize = codeBytes.Get();
}
else if (opcode == instruction.OP_PUSHDATA2)
{
// The next two bytes contain the number of bytes to be pushed onto the stack,
- // i.e. now your operation will seem like this: OP_PUSHDATA2 0x00 0x01 [0x5a]
- codeBytes.Get(2).CopyTo(szBytes, 2);
+ // i.e. now your operation will seem like this: OP_PUSHDATA2 0x01 0x00 [0x5a]
+ nSize = BitConverter.ToInt16(codeBytes.Get(2), 0);
}
else if (opcode == instruction.OP_PUSHDATA4)
{
// The next four bytes contain the number of bytes to be pushed onto the stack,
- // OP_PUSHDATA4 0x00 0x00 0x00 0x01 [0x5a]
- szBytes = codeBytes.Get(4);
+ // OP_PUSHDATA4 0x01 0x00 0x00 0x00 [0x5a]
+ nSize = BitConverter.ToInt32(codeBytes.Get(4), 0);
}
}
catch (ByteQueueException)
return false;
}
- int nSize = (int)Interop.BEBytesToUInt32(szBytes);
-
if (nSize > 0)
{
// If nSize is greater than zero then there is some data available
if (bytes.Length <= 4)
{
- sb.Append(Interop.BEBytesToUInt32(bytes));
+ sb.Append(new BigInteger(bytes));
}
else
{
/// <returns>Result</returns>
public static bool Solver(CScript scriptPubKey, out txnouttype typeRet, out IList<byte[]> solutions)
{
+ var scriptBytes = ((byte[])scriptPubKey);
+
solutions = new List<byte[]>();
// There are shortcuts for pay-to-script-hash and pay-to-pubkey-hash, which are more constrained than the other types.
typeRet = txnouttype.TX_SCRIPTHASH;
// Take 20 bytes with offset of 2 bytes
- var hashBytes = scriptPubKey.Bytes.Skip(2).Take(20);
+ var hashBytes = scriptBytes.Skip(2).Take(20);
solutions.Add(hashBytes.ToArray());
return true;
typeRet = txnouttype.TX_PUBKEYHASH;
// Take 20 bytes with offset of 3 bytes
- var hashBytes = scriptPubKey.Bytes.Skip(3).Take(20);
+ var hashBytes = scriptBytes.Skip(3).Take(20);
solutions.Add(hashBytes.ToArray());
return true;
byte[] args1, args2;
- int last1 = script1.Bytes.Count() -1;
- int last2 = script2.Bytes.Count() - 1;
+ int last1 = ((byte[])script1).Length -1;
+ int last2 = ((byte[])script2).Length - 1;
while (true)
{
// 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.RemoveInstruction(instruction.OP_CODESEPARATOR);
// Blank out other inputs' signatures
for (int i = 0; i < txTmp.vin.Length; i++)
}
// Concatenate and hash
- var txBytes = txTmp.Bytes;
+ var txBytes = (byte[])txTmp;
var nHashTypeBytes = BitConverter.GetBytes(nHashType);
return Hash256.Compute256(ref txBytes, ref nHashTypeBytes);
/// <returns></returns>
public static bool EvalScript(ref List<byte[]> stack, CScript script, CTransaction txTo, int nIn, int flags, int nHashType)
{
- if (script.Bytes.Count() > 10000)
+ var scriptBytes = ((byte[])script);
+
+ if (scriptBytes.Length > 10000)
{
return false; // Size limit failed
}
break;
}
popstack(ref stack);
- stack.Add(hash.hashBytes);
+ stack.Add(hash);
}
break;
var pubkeyBytes = stacktop(ref stack, -1);
// Subset of script starting at the most recent codeseparator
- var scriptCode = new CScript(script.Bytes.Skip(nCodeHashBegin));
+ var scriptCode = new CScript(scriptBytes.Skip(nCodeHashBegin).ToArray());
// There's no way for a signature to sign itself
scriptCode.RemovePattern(sigBytes);
}
// Subset of script starting at the most recent codeseparator
- var scriptCode = new CScript(script.Bytes.Skip(nCodeHashBegin));
+ var scriptCode = new CScript(scriptBytes.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++)