mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-01-19 05:43:51 +01:00
Adding Transaction case class, removing counter fields from Transaction
This commit is contained in:
parent
03d4e2f5e1
commit
c7aaf7fac1
@ -9,24 +9,16 @@ import org.scalacoin.protocol.{NetworkVarInt, VarInt}
|
||||
|
||||
|
||||
trait Transaction {
|
||||
def txId : String
|
||||
def version : Long
|
||||
def txInCount : VarInt
|
||||
def txIn : Seq[TransactionInput]
|
||||
def txOutCount : VarInt
|
||||
def txOut : Seq[TransactionOutput]
|
||||
def inputs : Seq[TransactionInput]
|
||||
def outputs : Seq[TransactionOutput]
|
||||
def lockTime : Long
|
||||
}
|
||||
|
||||
case class NetworkTx(serialization : String ) extends Transaction {
|
||||
require(!serialization.contains(" "), "Your network transaction contains whitespace")
|
||||
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
|
||||
|
||||
}
|
||||
case class TransactionImpl(txId : String, version : Long, inputs : Seq[TransactionInput],
|
||||
outputs : Seq[TransactionOutput], lockTime : Long) extends Transaction
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -7,11 +7,4 @@ import org.scalatest.{FlatSpec, 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)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user