You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
666 B
26 lines
666 B
package com.xsn.explorer.models
|
|
|
|
import com.xsn.explorer.models.rpc.ScriptPubKey
|
|
import play.api.libs.functional.syntax._
|
|
import play.api.libs.json.{Reads, __}
|
|
|
|
case class TransactionVOUT(
|
|
value: BigDecimal,
|
|
n: Int,
|
|
scriptPubKey: Option[ScriptPubKey] = None) {
|
|
|
|
val address: Option[Address] = scriptPubKey.flatMap(_.addresses.headOption)
|
|
}
|
|
|
|
object TransactionVOUT {
|
|
|
|
implicit val reads: Reads[TransactionVOUT] = {
|
|
val builder = (__ \ 'value).read[BigDecimal] and
|
|
(__ \ 'n).read[Int] and
|
|
(__ \ 'scriptPubKey).readNullable[ScriptPubKey]
|
|
|
|
builder.apply { (value, n, script) =>
|
|
TransactionVOUT(value, n, script)
|
|
}
|
|
}
|
|
}
|
|
|