mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-01-19 05:43:51 +01:00
Adding companion objects for script operation factories
This commit is contained in:
parent
60ca80e0e8
commit
b70bf70dd2
@ -1,5 +1,12 @@
|
||||
package org.scalacoin.script
|
||||
|
||||
import org.scalacoin.script.arithmetic.ArithmeticOperationsFactory
|
||||
import org.scalacoin.script.bitwise.BitwiseOperationsFactory
|
||||
import org.scalacoin.script.control.ControlOperationsFactory
|
||||
import org.scalacoin.script.crypto.CryptoOperationFactory
|
||||
import org.scalacoin.script.locktime.LocktimeOperationFactory
|
||||
import org.scalacoin.script.stack.StackOperationFactory
|
||||
|
||||
/**
|
||||
* Created by chris on 1/8/16.
|
||||
*/
|
||||
@ -20,3 +27,12 @@ trait ScriptOperationFactory[T] {
|
||||
def fromString(str : String) : Option[T] = operations.find(_.toString == str)
|
||||
|
||||
}
|
||||
|
||||
|
||||
object ScriptOperationFactory extends ScriptOperationFactory[ScriptOperation] {
|
||||
|
||||
override def operations = StackOperationFactory.operations ++ LocktimeOperationFactory.operations ++
|
||||
CryptoOperationFactory.operations ++ ControlOperationsFactory.operations ++ BitwiseOperationsFactory.operations ++
|
||||
ArithmeticOperationsFactory.operations
|
||||
|
||||
}
|
||||
|
@ -2,10 +2,12 @@ package org.scalacoin.script.parsing
|
||||
|
||||
import org.scalacoin.script.ScriptOperation
|
||||
|
||||
import scala.annotation.tailrec
|
||||
|
||||
/**
|
||||
* Created by chris on 1/7/16.
|
||||
*/
|
||||
trait ScriptParser {
|
||||
trait ScriptParser extends {
|
||||
|
||||
|
||||
/**
|
||||
@ -18,7 +20,21 @@ trait ScriptParser {
|
||||
str.split(" ").toList
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an output script of a transaction
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
/* def parseOutputScript(str : String) : List[ScriptOperation] = {
|
||||
|
||||
@tailrec
|
||||
def loop(operations : List[String], accum : List[ScriptOperation]) : List[ScriptOperation] = {
|
||||
operations match {
|
||||
case h :: t if ()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
loop(str.split(" ").toList, List())
|
||||
}*/
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ class ScriptParserTest extends FlatSpec with MustMatchers with ScriptParser {
|
||||
parsedInput must be (TestUtil.p2pkhInputScript)
|
||||
}
|
||||
|
||||
/* it must "parse an output script" in {
|
||||
it must "parse an output script" in {
|
||||
val parsedOutput = parseOutputScript(TestUtil.p2pkhOutputScriptNotParsed)
|
||||
parsedOutput must be (TestUtil.p2pkhOutputScript)
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user