mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-23 22:56:52 +01:00
Merge pull request #141 from Christewart/interpreter_run_verify
Add runVerify, runAll, and runAllVerify helper methods in ScriptInter…
This commit is contained in:
commit
5ee167e60d
1 changed files with 21 additions and 0 deletions
|
@ -97,6 +97,27 @@ sealed abstract class ScriptInterpreter {
|
|||
else ScriptErrorEvalFalse
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the given [[org.bitcoins.core.script.PreExecutionScriptProgram]] and
|
||||
* return if that script was valid or not
|
||||
*/
|
||||
def runVerify(p: PreExecutionScriptProgram): Boolean = { ScriptInterpreter.run(p) == ScriptOk }
|
||||
|
||||
/**
|
||||
* Every given [[org.bitcoins.core.script.PreExecutionScriptProgram]] and returns
|
||||
* it's [[org.bitcoins.core.script.result.ScriptResult]]
|
||||
*/
|
||||
def runAll(programs: Seq[PreExecutionScriptProgram]): Seq[ScriptResult] = {
|
||||
programs.map(p => ScriptInterpreter.run(p))
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs all the given [[org.bitcoins.core.script.ScriptProgram]] and return
|
||||
* if it is valid or not
|
||||
*/
|
||||
def runAllVerify(programs: Seq[PreExecutionScriptProgram]): Boolean = {
|
||||
!programs.exists(p => ScriptInterpreter.run(p) != ScriptOk)
|
||||
}
|
||||
/**
|
||||
* P2SH scripts are unique in their evaluation, first the scriptSignature must be added to the stack, next the
|
||||
* p2sh scriptPubKey must be run to make sure the serialized redeem script hashes to the value found in the p2sh
|
||||
|
|
Loading…
Add table
Reference in a new issue