mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-24 23:08:31 +01:00
Src files now compile on using ScriptProgram's new factory functions
This commit is contained in:
parent
87beb9ec8d
commit
8a45232d22
2 changed files with 190 additions and 153 deletions
|
@ -435,5 +435,38 @@ object ScriptProgram {
|
||||||
|
|
||||||
def apply(txSignatureComponent : TransactionSignatureComponent, stack : Seq[ScriptToken], script : Seq[ScriptToken]) : ScriptProgram =
|
def apply(txSignatureComponent : TransactionSignatureComponent, stack : Seq[ScriptToken], script : Seq[ScriptToken]) : ScriptProgram =
|
||||||
factory(txSignatureComponent, stack, script)
|
factory(txSignatureComponent, stack, script)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes a program that is being executed inside o
|
||||||
|
* @param executionInProgressScriptProgram
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
def toExecutedProgram(executionInProgressScriptProgram: ExecutionInProgressScriptProgram) : ExecutedScriptProgram = {
|
||||||
|
ExecutedScriptProgramImpl(executionInProgressScriptProgram.txSignatureComponent, executionInProgressScriptProgram.stack,
|
||||||
|
executionInProgressScriptProgram.script,executionInProgressScriptProgram.originalScript,executionInProgressScriptProgram.altStack,
|
||||||
|
executionInProgressScriptProgram.flags,None)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes a script program that is pre execution and changes it to an execution in progress script program
|
||||||
|
* @param preExecutionScriptProgram
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
def toExecutionInProgress(preExecutionScriptProgram: PreExecutionScriptProgram) : ExecutionInProgressScriptProgram = {
|
||||||
|
toExecutionInProgress(preExecutionScriptProgram,List())
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes a pre execution script program to a execution in progress script program with the given stack state
|
||||||
|
* @param preExecutionScriptProgram
|
||||||
|
* @param stack
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
def toExecutionInProgress(preExecutionScriptProgram: PreExecutionScriptProgram, stack : List[ScriptToken]) : ExecutionInProgressScriptProgram = {
|
||||||
|
ExecutionInProgressScriptProgramImpl(preExecutionScriptProgram.txSignatureComponent,stack,preExecutionScriptProgram.script,
|
||||||
|
preExecutionScriptProgram.originalScript,preExecutionScriptProgram.altStack,preExecutionScriptProgram.flags, 0)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,11 @@ package org.scalacoin.script.interpreter
|
||||||
|
|
||||||
import org.scalacoin.protocol.script._
|
import org.scalacoin.protocol.script._
|
||||||
import org.scalacoin.protocol.transaction.Transaction
|
import org.scalacoin.protocol.transaction.Transaction
|
||||||
|
import org.scalacoin.script.error._
|
||||||
import org.scalacoin.script.flag._
|
import org.scalacoin.script.flag._
|
||||||
import org.scalacoin.script.locktime.{OP_CHECKLOCKTIMEVERIFY, LockTimeInterpreter}
|
import org.scalacoin.script.locktime.{OP_CHECKLOCKTIMEVERIFY, LockTimeInterpreter}
|
||||||
import org.scalacoin.script.splice._
|
import org.scalacoin.script.splice._
|
||||||
import org.scalacoin.script.{ScriptProgram}
|
import org.scalacoin.script.{ExecutionInProgressScriptProgram, PreExecutionScriptProgram, ExecutedScriptProgram, ScriptProgram}
|
||||||
import org.scalacoin.script.arithmetic._
|
import org.scalacoin.script.arithmetic._
|
||||||
import org.scalacoin.script.bitwise._
|
import org.scalacoin.script.bitwise._
|
||||||
import org.scalacoin.script.constant._
|
import org.scalacoin.script.constant._
|
||||||
|
@ -64,173 +65,176 @@ trait ScriptInterpreter extends CryptoInterpreter with StackInterpreter with Con
|
||||||
if (opCount > maxScriptOps) {
|
if (opCount > maxScriptOps) {
|
||||||
logger.error("We have reached the maximum amount of script operations allowed")
|
logger.error("We have reached the maximum amount of script operations allowed")
|
||||||
logger.error("Here are the remaining operations in the script: " + program.script)
|
logger.error("Here are the remaining operations in the script: " + program.script)
|
||||||
(false,ScriptProgram(program,false))
|
(false,ScriptProgram(program,ScriptErrorOpCount))
|
||||||
} else if (program.script.flatMap(_.bytes).size > 10000) {
|
} else if (program.script.flatMap(_.bytes).size > 10000) {
|
||||||
logger.error("We cannot run a script that is larger than 10,000 bytes")
|
logger.error("We cannot run a script that is larger than 10,000 bytes")
|
||||||
(false,ScriptProgram(program,false))
|
(false, ScriptProgram(program, ScriptErrorScriptSize))
|
||||||
} else {
|
} else {
|
||||||
program.script match {
|
program match {
|
||||||
//if at any time we see that the program is not valid
|
case p : PreExecutionScriptProgram => loop(ScriptProgram.toExecutionInProgress(p,p.stack))
|
||||||
//cease script execution
|
case p : ExecutedScriptProgram => (p.error.isDefined, p)
|
||||||
case _ if !program.isValid =>
|
case p : ExecutionInProgressScriptProgram =>
|
||||||
logger.error("Script program was marked as invalid: " + program)
|
p.script match {
|
||||||
(false, ScriptProgram(program, false))
|
//if at any time we see that the program is not valid
|
||||||
case _ if !program.script.intersect(Seq(OP_VERIF, OP_VERNOTIF)).isEmpty =>
|
//cease script execution
|
||||||
logger.error("Script is invalid even when a OP_VERIF or OP_VERNOTIF occurs in an unexecuted OP_IF branch")
|
case _ if !p.script.intersect(Seq(OP_VERIF, OP_VERNOTIF)).isEmpty =>
|
||||||
(false, ScriptProgram(program, false))
|
logger.error("Script is invalid even when a OP_VERIF or OP_VERNOTIF occurs in an unexecuted OP_IF branch")
|
||||||
//disabled splice operation
|
(false, ScriptProgram(p, ScriptErrorDisabledOpCode))
|
||||||
case _ if !program.script.intersect(Seq(OP_CAT, OP_SUBSTR, OP_LEFT, OP_RIGHT)).isEmpty =>
|
//disabled splice operation
|
||||||
logger.error("Script is invalid because it contains a disabled splice operation")
|
case _ if !p.script.intersect(Seq(OP_CAT, OP_SUBSTR, OP_LEFT, OP_RIGHT)).isEmpty =>
|
||||||
(false, ScriptProgram(program, false))
|
logger.error("Script is invalid because it contains a disabled splice operation")
|
||||||
//disabled bitwise operations
|
(false, ScriptProgram(p, ScriptErrorDisabledOpCode))
|
||||||
case _ if !program.script.intersect(Seq(OP_INVERT, OP_AND, OP_OR, OP_XOR)).isEmpty =>
|
//disabled bitwise operations
|
||||||
logger.error("Script is invalid because it contains a disabled bitwise operation")
|
case _ if !p.script.intersect(Seq(OP_INVERT, OP_AND, OP_OR, OP_XOR)).isEmpty =>
|
||||||
(false, ScriptProgram(program, false))
|
logger.error("Script is invalid because it contains a disabled bitwise operation")
|
||||||
//disabled arithmetic operations
|
(false, ScriptProgram(p, ScriptErrorDisabledOpCode))
|
||||||
case _ if !program.script.intersect(Seq(OP_MUL, OP_2MUL, OP_DIV, OP_2DIV, OP_MOD, OP_LSHIFT, OP_RSHIFT)).isEmpty =>
|
//disabled arithmetic operations
|
||||||
logger.error("Script is invalid because it contains a disabled arithmetic operation")
|
case _ if !p.script.intersect(Seq(OP_MUL, OP_2MUL, OP_DIV, OP_2DIV, OP_MOD, OP_LSHIFT, OP_RSHIFT)).isEmpty =>
|
||||||
(false, ScriptProgram(program, false))
|
logger.error("Script is invalid because it contains a disabled arithmetic operation")
|
||||||
//program cannot contain a push operation > 520 bytes
|
(false, ScriptProgram(p, ScriptErrorDisabledOpCode))
|
||||||
case _ if (program.script.exists(token => token.bytes.size > 520)) =>
|
//program cannot contain a push operation > 520 bytes
|
||||||
logger.error("We have a script constant that is larger than 520 bytes, this is illegal: " + program.script)
|
case _ if (p.script.exists(token => token.bytes.size > 520)) =>
|
||||||
loop(ScriptProgram(program, false))
|
logger.error("We have a script constant that is larger than 520 bytes, this is illegal: " + p.script)
|
||||||
//program stack size cannot be greater than 1000 elements
|
loop(ScriptProgram(p, ScriptErrorPushSize))
|
||||||
case _ if ((program.stack.size + program.altStack.size) > 1000) =>
|
//program stack size cannot be greater than 1000 elements
|
||||||
logger.error("We cannot have a stack + alt stack size larger than 1000 elements")
|
case _ if ((p.stack.size + p.altStack.size) > 1000) =>
|
||||||
loop(ScriptProgram(program, false))
|
logger.error("We cannot have a stack + alt stack size larger than 1000 elements")
|
||||||
|
loop(ScriptProgram(p, ScriptErrorStackSize))
|
||||||
|
|
||||||
//stack operations
|
//stack operations
|
||||||
case OP_DUP :: t => loop(opDup(program))
|
case OP_DUP :: t => loop(opDup(p))
|
||||||
case OP_DEPTH :: t => loop(opDepth(program))
|
case OP_DEPTH :: t => loop(opDepth(p))
|
||||||
case OP_TOALTSTACK :: t => loop(opToAltStack(program))
|
case OP_TOALTSTACK :: t => loop(opToAltStack(p))
|
||||||
case OP_FROMALTSTACK :: t => loop(opFromAltStack(program))
|
case OP_FROMALTSTACK :: t => loop(opFromAltStack(p))
|
||||||
case OP_DROP :: t => loop(opDrop(program))
|
case OP_DROP :: t => loop(opDrop(p))
|
||||||
case OP_IFDUP :: t => loop(opIfDup(program))
|
case OP_IFDUP :: t => loop(opIfDup(p))
|
||||||
case OP_NIP :: t => loop(opNip(program))
|
case OP_NIP :: t => loop(opNip(p))
|
||||||
case OP_OVER :: t => loop(opOver(program))
|
case OP_OVER :: t => loop(opOver(p))
|
||||||
case OP_PICK :: t => loop(opPick(program))
|
case OP_PICK :: t => loop(opPick(p))
|
||||||
case OP_ROLL :: t => loop(opRoll(program))
|
case OP_ROLL :: t => loop(opRoll(p))
|
||||||
case OP_ROT :: t => loop(opRot(program))
|
case OP_ROT :: t => loop(opRot(p))
|
||||||
case OP_2ROT :: t => loop(op2Rot(program))
|
case OP_2ROT :: t => loop(op2Rot(p))
|
||||||
case OP_2DROP :: t => loop(op2Drop(program))
|
case OP_2DROP :: t => loop(op2Drop(p))
|
||||||
case OP_SWAP :: t => loop(opSwap(program))
|
case OP_SWAP :: t => loop(opSwap(p))
|
||||||
case OP_TUCK :: t => loop(opTuck(program))
|
case OP_TUCK :: t => loop(opTuck(p))
|
||||||
case OP_2DUP :: t => loop(op2Dup(program))
|
case OP_2DUP :: t => loop(op2Dup(p))
|
||||||
case OP_3DUP :: t => loop(op3Dup(program))
|
case OP_3DUP :: t => loop(op3Dup(p))
|
||||||
case OP_2OVER :: t => loop(op2Over(program))
|
case OP_2OVER :: t => loop(op2Over(p))
|
||||||
case OP_2SWAP :: t => loop(op2Swap(program))
|
case OP_2SWAP :: t => loop(op2Swap(p))
|
||||||
|
|
||||||
//arithmetic operations
|
//arithmetic operations
|
||||||
case OP_ADD :: t => loop(opAdd(program))
|
case OP_ADD :: t => loop(opAdd(p))
|
||||||
case OP_1ADD :: t => loop(op1Add(program))
|
case OP_1ADD :: t => loop(op1Add(p))
|
||||||
case OP_1SUB :: t => loop(op1Sub(program))
|
case OP_1SUB :: t => loop(op1Sub(p))
|
||||||
case OP_SUB :: t => loop(opSub(program))
|
case OP_SUB :: t => loop(opSub(p))
|
||||||
case OP_ABS :: t => loop(opAbs(program))
|
case OP_ABS :: t => loop(opAbs(p))
|
||||||
case OP_NEGATE :: t => loop(opNegate(program))
|
case OP_NEGATE :: t => loop(opNegate(p))
|
||||||
case OP_NOT :: t => loop(opNot(program))
|
case OP_NOT :: t => loop(opNot(p))
|
||||||
case OP_0NOTEQUAL :: t => loop(op0NotEqual(program))
|
case OP_0NOTEQUAL :: t => loop(op0NotEqual(p))
|
||||||
case OP_BOOLAND :: t => loop(opBoolAnd(program))
|
case OP_BOOLAND :: t => loop(opBoolAnd(p))
|
||||||
case OP_BOOLOR :: t => loop(opBoolOr(program))
|
case OP_BOOLOR :: t => loop(opBoolOr(p))
|
||||||
case OP_NUMEQUAL :: t => loop(opNumEqual(program))
|
case OP_NUMEQUAL :: t => loop(opNumEqual(p))
|
||||||
case OP_NUMEQUALVERIFY :: t => loop(opNumEqualVerify(program))
|
case OP_NUMEQUALVERIFY :: t => loop(opNumEqualVerify(p))
|
||||||
case OP_NUMNOTEQUAL :: t => loop(opNumNotEqual(program))
|
case OP_NUMNOTEQUAL :: t => loop(opNumNotEqual(p))
|
||||||
case OP_LESSTHAN :: t => loop(opLessThan(program))
|
case OP_LESSTHAN :: t => loop(opLessThan(p))
|
||||||
case OP_GREATERTHAN :: t => loop(opGreaterThan(program))
|
case OP_GREATERTHAN :: t => loop(opGreaterThan(p))
|
||||||
case OP_LESSTHANOREQUAL :: t => loop(opLessThanOrEqual(program))
|
case OP_LESSTHANOREQUAL :: t => loop(opLessThanOrEqual(p))
|
||||||
case OP_GREATERTHANOREQUAL :: t => loop(opGreaterThanOrEqual(program))
|
case OP_GREATERTHANOREQUAL :: t => loop(opGreaterThanOrEqual(p))
|
||||||
case OP_MIN :: t => loop(opMin(program))
|
case OP_MIN :: t => loop(opMin(p))
|
||||||
case OP_MAX :: t => loop(opMax(program))
|
case OP_MAX :: t => loop(opMax(p))
|
||||||
case OP_WITHIN :: t => loop(opWithin(program))
|
case OP_WITHIN :: t => loop(opWithin(p))
|
||||||
|
|
||||||
//bitwise operations
|
//bitwise operations
|
||||||
case OP_EQUAL :: t =>
|
case OP_EQUAL :: t =>
|
||||||
val newProgram = opEqual(program)
|
val newProgram = opEqual(p)
|
||||||
loop(newProgram)
|
loop(newProgram)
|
||||||
|
|
||||||
case OP_EQUALVERIFY :: t => loop(opEqualVerify(program))
|
case OP_EQUALVERIFY :: t => loop(opEqualVerify(p))
|
||||||
|
|
||||||
case (scriptNumberOp: ScriptNumberOperation) :: t =>
|
case (scriptNumberOp: ScriptNumberOperation) :: t =>
|
||||||
if (scriptNumberOp == OP_0) loop(ScriptProgram(program, ScriptNumberFactory.zero :: program.stack, t))
|
if (scriptNumberOp == OP_0) loop(ScriptProgram(p, ScriptNumberFactory.zero :: p.stack, t))
|
||||||
else loop(ScriptProgram(program, ScriptNumberFactory.fromNumber(scriptNumberOp.num) :: program.stack, t))
|
else loop(ScriptProgram(p, ScriptNumberFactory.fromNumber(scriptNumberOp.num) :: p.stack, t))
|
||||||
case (bytesToPushOntoStack: BytesToPushOntoStack) :: t => loop(pushScriptNumberBytesToStack(program))
|
case (bytesToPushOntoStack: BytesToPushOntoStack) :: t => loop(pushScriptNumberBytesToStack(p))
|
||||||
case (scriptNumber: ScriptNumber) :: t =>
|
case (scriptNumber: ScriptNumber) :: t =>
|
||||||
loop(ScriptProgram(program, scriptNumber :: program.stack, t))
|
loop(ScriptProgram(p, scriptNumber :: p.stack, t))
|
||||||
case OP_PUSHDATA1 :: t => loop(opPushData1(program))
|
case OP_PUSHDATA1 :: t => loop(opPushData1(p))
|
||||||
case OP_PUSHDATA2 :: t => loop(opPushData2(program))
|
case OP_PUSHDATA2 :: t => loop(opPushData2(p))
|
||||||
case OP_PUSHDATA4 :: t => loop(opPushData4(program))
|
case OP_PUSHDATA4 :: t => loop(opPushData4(p))
|
||||||
|
|
||||||
case (x : ScriptConstant) :: t => loop(ScriptProgram(program, x :: program.stack, t))
|
case (x : ScriptConstant) :: t => loop(ScriptProgram(p, x :: p.stack, t))
|
||||||
|
|
||||||
//control operations
|
//control operations
|
||||||
case OP_IF :: t => loop(opIf(program))
|
case OP_IF :: t => loop(opIf(p))
|
||||||
case OP_NOTIF :: t => loop(opNotIf(program))
|
case OP_NOTIF :: t => loop(opNotIf(p))
|
||||||
case OP_ELSE :: t => loop(opElse(program))
|
case OP_ELSE :: t => loop(opElse(p))
|
||||||
case OP_ENDIF :: t => loop(opEndIf(program))
|
case OP_ENDIF :: t => loop(opEndIf(p))
|
||||||
case OP_RETURN :: t =>
|
case OP_RETURN :: t => loop(opReturn(p))
|
||||||
val newProgram = opReturn(program)
|
|
||||||
(newProgram.isValid, newProgram)
|
|
||||||
case OP_VERIFY :: t => loop(opVerify(program))
|
|
||||||
|
|
||||||
//crypto operations
|
case OP_VERIFY :: t => loop(opVerify(p))
|
||||||
case OP_HASH160 :: t => loop(opHash160(program))
|
|
||||||
case OP_CHECKSIG :: t => loop(opCheckSig(program))
|
|
||||||
case OP_SHA1 :: t => loop(opSha1(program))
|
|
||||||
case OP_RIPEMD160 :: t => loop(opRipeMd160(program))
|
|
||||||
case OP_SHA256 :: t => loop(opSha256(program))
|
|
||||||
case OP_HASH256 :: t => loop(opHash256(program))
|
|
||||||
case OP_CODESEPARATOR :: t => loop(opCodeSeparator(program))
|
|
||||||
case OP_CHECKMULTISIG :: t => loop(opCheckMultiSig(program))
|
|
||||||
case OP_CHECKMULTISIGVERIFY :: t => loop(opCheckMultiSigVerify(program))
|
|
||||||
//reserved operations
|
|
||||||
case OP_NOP :: t =>
|
|
||||||
//script discourage upgradeable flag does not apply to a OP_NOP
|
|
||||||
loop(ScriptProgram(program, program.stack, t))
|
|
||||||
|
|
||||||
//if we see an OP_NOP and the DISCOURAGE_UPGRADABLE_OP_NOPS flag is set we must fail our program
|
//crypto operations
|
||||||
case (nop: NOP) :: t if ScriptFlagUtil.discourageUpgradableNOPs(program.flags) =>
|
case OP_HASH160 :: t => loop(opHash160(p))
|
||||||
logger.error("We cannot execute a NOP when the ScriptVerifyDiscourageUpgradableNOPs is set")
|
case OP_CHECKSIG :: t => loop(opCheckSig(p))
|
||||||
(false, ScriptProgram(program, false))
|
case OP_SHA1 :: t => loop(opSha1(p))
|
||||||
case (nop: NOP) :: t => loop(ScriptProgram(program, program.stack, t))
|
case OP_RIPEMD160 :: t => loop(opRipeMd160(p))
|
||||||
case OP_RESERVED :: t =>
|
case OP_SHA256 :: t => loop(opSha256(p))
|
||||||
logger.error("OP_RESERVED automatically marks transaction invalid")
|
case OP_HASH256 :: t => loop(opHash256(p))
|
||||||
(false, program)
|
case OP_CODESEPARATOR :: t => loop(opCodeSeparator(p))
|
||||||
case OP_VER :: t =>
|
case OP_CHECKMULTISIG :: t => loop(opCheckMultiSig(p))
|
||||||
logger.error("Transaction is invalid when executing OP_VER")
|
case OP_CHECKMULTISIGVERIFY :: t => loop(opCheckMultiSigVerify(p))
|
||||||
(false, program)
|
//reserved operations
|
||||||
case OP_RESERVED1 :: t =>
|
case OP_NOP :: t =>
|
||||||
logger.error("Transaction is invalid when executing OP_RESERVED1")
|
//script discourage upgradeable flag does not apply to a OP_NOP
|
||||||
(false, program)
|
loop(ScriptProgram(p, p.stack, t))
|
||||||
case OP_RESERVED2 :: t =>
|
|
||||||
logger.error("Transaction is invalid when executing OP_RESERVED2")
|
|
||||||
(false, program)
|
|
||||||
|
|
||||||
case (reservedOperation : ReservedOperation) :: t =>
|
//if we see an OP_NOP and the DISCOURAGE_UPGRADABLE_OP_NOPS flag is set we must fail our program
|
||||||
logger.error("Undefined operation found which automatically fails the script: " + reservedOperation)
|
case (nop: NOP) :: t if ScriptFlagUtil.discourageUpgradableNOPs(p.flags) =>
|
||||||
loop(ScriptProgram(program,false))
|
logger.error("We cannot execute a NOP when the ScriptVerifyDiscourageUpgradableNOPs is set")
|
||||||
//splice operations
|
loop(ScriptProgram(p, ScriptErrorDiscourageUpgradableNOPs))
|
||||||
case OP_SIZE :: t => loop(opSize(program))
|
case (nop: NOP) :: t => loop(ScriptProgram(p, p.stack, t))
|
||||||
|
case OP_RESERVED :: t =>
|
||||||
|
logger.error("OP_RESERVED automatically marks transaction invalid")
|
||||||
|
(false, p)
|
||||||
|
case OP_VER :: t =>
|
||||||
|
logger.error("Transaction is invalid when executing OP_VER")
|
||||||
|
(false, p)
|
||||||
|
case OP_RESERVED1 :: t =>
|
||||||
|
logger.error("Transaction is invalid when executing OP_RESERVED1")
|
||||||
|
(false, p)
|
||||||
|
case OP_RESERVED2 :: t =>
|
||||||
|
logger.error("Transaction is invalid when executing OP_RESERVED2")
|
||||||
|
(false, p)
|
||||||
|
|
||||||
//locktime operations
|
case (reservedOperation : ReservedOperation) :: t =>
|
||||||
case OP_CHECKLOCKTIMEVERIFY :: t =>
|
logger.error("Undefined operation found which automatically fails the script: " + reservedOperation)
|
||||||
//check if CLTV is enforced yet
|
loop(ScriptProgram(p,ScriptErrorBadOpCode))
|
||||||
if (ScriptFlagUtil.checkLockTimeVerifyEnabled(program.flags)) loop(opCheckLockTimeVerify(program))
|
//splice operations
|
||||||
//if not, check to see if we should discourage NOPs
|
case OP_SIZE :: t => loop(opSize(p))
|
||||||
else if (ScriptFlagUtil.discourageUpgradableNOPs(program.flags)) {
|
|
||||||
logger.error("We cannot execute a NOP when the ScriptVerifyDiscourageUpgradableNOPs is set")
|
//locktime operations
|
||||||
(false, ScriptProgram(program, false))
|
case OP_CHECKLOCKTIMEVERIFY :: t =>
|
||||||
|
//check if CLTV is enforced yet
|
||||||
|
if (ScriptFlagUtil.checkLockTimeVerifyEnabled(p.flags)) loop(opCheckLockTimeVerify(p))
|
||||||
|
//if not, check to see if we should discourage p
|
||||||
|
else if (ScriptFlagUtil.discourageUpgradableNOPs(p.flags)) {
|
||||||
|
logger.error("We cannot execute a NOP when the ScriptVerifyDiscourageUpgradableNOPs is set")
|
||||||
|
loop(ScriptProgram(p, ScriptErrorDiscourageUpgradableNOPs))
|
||||||
|
}
|
||||||
|
//in this case, just reat OP_CLTV just like a NOP and remove it from the stack
|
||||||
|
else loop(ScriptProgram(p, p.script.tail, ScriptProgram.Script))
|
||||||
|
//no more script operations to run, return whether the program is valid and the final state of the program
|
||||||
|
case Nil =>
|
||||||
|
//reset opCount variable to zero since we may need to count the ops
|
||||||
|
//in the scriptPubKey - we don't want the op count of the scriptSig
|
||||||
|
//to count towards the scriptPubKey op count
|
||||||
|
opCount = 0
|
||||||
|
loop(ScriptProgram.toExecutedProgram(p))
|
||||||
|
|
||||||
|
case h :: t => throw new RuntimeException(h + " was unmatched")
|
||||||
}
|
}
|
||||||
//in this case, just reat OP_CLTV just like a NOP and remove it from the stack
|
|
||||||
else loop(ScriptProgram(program, program.script.tail, ScriptProgram.Script))
|
|
||||||
//no more script operations to run, return whether the program is valid and the final state of the program
|
|
||||||
case Nil =>
|
|
||||||
//reset opCount variable to zero since we may need to count the ops
|
|
||||||
//in the scriptPubKey - we don't want the op count of the scriptSig
|
|
||||||
//to count towards the scriptPubKey op count
|
|
||||||
opCount = 0
|
|
||||||
(program.isValid, program)
|
|
||||||
|
|
||||||
case h :: t => throw new RuntimeException(h + " was unmatched")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue