Alexis Hernandez
7 years ago
1 changed files with 24 additions and 0 deletions
@ -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…
Reference in new issue