Adding Transaction case class, removing counter fields from Transaction

This commit is contained in:
Chris Stewart 2015-12-26 21:28:20 -06:00
parent 03d4e2f5e1
commit c7aaf7fac1
2 changed files with 6 additions and 21 deletions

View File

@ -9,24 +9,16 @@ import org.scalacoin.protocol.{NetworkVarInt, VarInt}
trait Transaction { trait Transaction {
def txId : String
def version : Long def version : Long
def txInCount : VarInt def inputs : Seq[TransactionInput]
def txIn : Seq[TransactionInput] def outputs : Seq[TransactionOutput]
def txOutCount : VarInt
def txOut : Seq[TransactionOutput]
def lockTime : Long def lockTime : Long
} }
case class NetworkTx(serialization : String ) extends Transaction { case class TransactionImpl(txId : String, version : Long, inputs : Seq[TransactionInput],
require(!serialization.contains(" "), "Your network transaction contains whitespace") outputs : Seq[TransactionOutput], lockTime : Long) extends Transaction
override def version = java.lang.Long.parseLong(serialization.slice(0,8),16)
override def txInCount : VarInt = NetworkVarInt("FF")
override def txIn : Seq[TransactionInput] = Seq()
override def txOutCount : VarInt = NetworkVarInt("FF")
override def txOut : Seq[TransactionOutput] = Seq(TransactionOutputImpl(Satoshis(1),NetworkVarInt("FF"), Seq()))
override def lockTime : Long = 0
}

View File

@ -7,11 +7,4 @@ import org.scalatest.{FlatSpec, MustMatchers}
*/ */
class TransactionTest extends FlatSpec with MustMatchers { class TransactionTest extends FlatSpec with MustMatchers {
"Tx" must "be instanstiated from a serialized tx on the network" in {
val tx = NetworkTx("01000000")
//00000001000000000000000000000000
tx.version must be (16777216)
}
} }