Browse Source

server: Add TransactionLogic

scalafmt-draft
Alexis Hernandez 7 years ago
parent
commit
00149965ed
  1. 24
      server/app/com/xsn/explorer/services/logic/TransactionLogic.scala

24
server/app/com/xsn/explorer/services/logic/TransactionLogic.scala

@ -0,0 +1,24 @@
package com.xsn.explorer.services.logic
import com.alexitc.playsonify.core.ApplicationResult
import com.alexitc.playsonify.models.ApplicationError
import com.xsn.explorer.models.{Address, Transaction, TransactionVIN, TransactionVOUT}
import org.scalactic.{One, Or}
class TransactionLogic {
def getAddress(vout: TransactionVOUT, error: ApplicationError): ApplicationResult[Address] = {
val maybe = vout.address
Or.from(maybe, One(error))
}
def getVIN(tx: Transaction, error: ApplicationError): ApplicationResult[TransactionVIN] = {
val maybe = tx.vin
Or.from(maybe, One(error))
}
def getVOUT(vin: TransactionVIN, previousTX: Transaction, error: ApplicationError): ApplicationResult[TransactionVOUT] = {
val maybe = previousTX.vout.find(_.n == vin.voutIndex)
Or.from(maybe, One(error))
}
}
Loading…
Cancel
Save