mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-22 14:33:06 +01:00
parent
3e0c624d2f
commit
e7ce9cd157
2 changed files with 10 additions and 18 deletions
|
@ -35,7 +35,8 @@ class ScriptProgramFactoryTest extends FlatSpec with MustMatchers {
|
|||
|
||||
it must "update the OP_CODESEPARATOR index" in {
|
||||
val index = 999
|
||||
val program = ScriptProgram(TestUtil.testProgramExecutionInProgress, index)
|
||||
val program =
|
||||
TestUtil.testProgramExecutionInProgress.updateLastCodeSeparator(index)
|
||||
program.lastCodeSeparator must be(Some(index))
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,8 @@ case class PreExecutionScriptProgram(
|
|||
this.copy(script = tokens.toList)
|
||||
}
|
||||
|
||||
def updateOriginalScript(tokens: Seq[ScriptToken]): PreExecutionScriptProgram = {
|
||||
def updateOriginalScript(
|
||||
tokens: Seq[ScriptToken]): PreExecutionScriptProgram = {
|
||||
this.copy(originalScript = tokens.toList)
|
||||
}
|
||||
}
|
||||
|
@ -137,6 +138,11 @@ case class ExecutionInProgressScriptProgram(
|
|||
def removeFlags(): ExecutionInProgressScriptProgram = {
|
||||
this.replaceFlags(Seq.empty)
|
||||
}
|
||||
|
||||
def updateLastCodeSeparator(
|
||||
newLastCodeSeparator: Int): ExecutionInProgressScriptProgram = {
|
||||
this.copy(lastCodeSeparator = Some(newLastCodeSeparator))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -253,21 +259,6 @@ object ScriptProgram extends BitcoinSLogger {
|
|||
updatedScript
|
||||
}
|
||||
|
||||
/** Updates the last [[org.bitcoins.core.script.crypto.OP_CODESEPARATOR OP_CODESEPARATOR]] index. */
|
||||
def apply(
|
||||
oldProgram: ExecutionInProgressScriptProgram,
|
||||
lastCodeSeparator: Int): ExecutionInProgressScriptProgram = {
|
||||
ExecutionInProgressScriptProgram(
|
||||
oldProgram.txSignatureComponent,
|
||||
oldProgram.stack,
|
||||
oldProgram.script,
|
||||
oldProgram.originalScript,
|
||||
oldProgram.altStack,
|
||||
oldProgram.flags,
|
||||
Some(lastCodeSeparator)
|
||||
)
|
||||
}
|
||||
|
||||
/** Updates the [[org.bitcoins.core.script.constant.ScriptToken ScriptToken]]s
|
||||
* in either the stack or script and the last
|
||||
* [[org.bitcoins.core.script.crypto.OP_CODESEPARATOR OP_CODESEPARATOR]] index */
|
||||
|
@ -277,7 +268,7 @@ object ScriptProgram extends BitcoinSLogger {
|
|||
indicator: UpdateIndicator,
|
||||
lastCodeSeparator: Int): ExecutionInProgressScriptProgram = {
|
||||
val updatedIndicator = ScriptProgram(oldProgram, tokens, indicator)
|
||||
ScriptProgram(updatedIndicator, lastCodeSeparator)
|
||||
updatedIndicator.updateLastCodeSeparator(lastCodeSeparator)
|
||||
}
|
||||
|
||||
/** Updates the [[org.bitcoins.core.script.ScriptProgram.Stack Stack]],
|
||||
|
|
Loading…
Add table
Reference in a new issue