com.wavesplatform.api.http.requests.LeaseRequest.scala Maven / Gradle / Ivy
The newest version!
package com.wavesplatform.api.http.requests
import com.wavesplatform.account.{AddressOrAlias, PublicKey}
import com.wavesplatform.common.state.ByteStr
import com.wavesplatform.lang.ValidationError
import com.wavesplatform.transaction.Proofs
import com.wavesplatform.transaction.lease.LeaseTransaction
import play.api.libs.json.{Format, Json}
case class LeaseRequest(
version: Option[Byte],
sender: Option[String],
senderPublicKey: Option[String],
recipient: String,
amount: Long,
fee: Long,
timestamp: Option[Long],
signature: Option[ByteStr],
proofs: Option[Proofs]
) extends TxBroadcastRequest[LeaseTransaction] {
def toTxFrom(sender: PublicKey): Either[ValidationError, LeaseTransaction] =
for {
validRecipient <- AddressOrAlias.fromString(recipient)
validProofs <- toProofs(signature, proofs)
tx <- LeaseTransaction.create(
version.getOrElse(1.toByte),
sender,
validRecipient,
amount,
fee,
timestamp.getOrElse(0L),
validProofs
)
} yield tx
}
object LeaseRequest {
implicit val jsonFormat: Format[LeaseRequest] = Json.format
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy