This commit is contained in:
Nadav Kohen 2018-05-29 22:04:32 -05:00 committed by nkohen
parent 6589bf495f
commit 9db6436573
3 changed files with 74 additions and 5 deletions

View File

@ -1,8 +1,12 @@
package org.bitcoins.rpc.jsonmodels
import java.net.InetAddress
import org.bitcoins.core.crypto.DoubleSha256Digest
import org.bitcoins.core.currency.Bitcoins
import org.bitcoins.core.number.{ Int32, UInt32 }
import org.bitcoins.core.number.{Int32, UInt32}
import org.bitcoins.core.protocol.Address
import org.bitcoins.core.protocol.script.ScriptPubKey
sealed abstract class NetworkResult
@ -53,4 +57,39 @@ case class GetBlockHeaderResult(
difficulty: Double,
chainwork: String,
previousblockhash: Option[DoubleSha256Digest],
nextblockhash: Option[DoubleSha256Digest]) extends NetworkResult
nextblockhash: Option[DoubleSha256Digest]) extends NetworkResult
case class ValidateAddressResult(
isvalid: Boolean,
address: Option[Address],
scriptPubKey: Option[ScriptPubKey],
ismine: Option[Boolean],
iswatchonly: Option[Boolean],
isscript: Option[Boolean],
script: Option[String],
hex: Option[String],
addresses: Option[Array[Address]],
sigrequired: Option[Int],
pubkey: Option[String], // Is this right?
iscompressed: Option[Boolean],
account: Option[String],
hdkeypath: Option[String],
hdmasterkeyid: Option[String] // Is this right?
) extends NetworkResult
case class NodeBan(
address: InetAddress,
banned_until: UInt32,
ban_created: UInt32,
ban_reason: String
) extends NetworkResult
case class Node(
addednode: InetAddress, // Need to add Reads[InetAddress]
connected: Option[Boolean],
addresses: Option[Array[NodeAddress]]
) extends NetworkResult
case class NodeAddress(
address: InetAddress,
connected: String
) extends NetworkResult

View File

@ -1,5 +1,22 @@
package org.bitcoins.rpc.jsonmodels
class WalletResult {
import org.bitcoins.core.crypto.DoubleSha256Digest
import org.bitcoins.core.currency.Bitcoins
import org.bitcoins.core.number.UInt32
}
sealed abstract class WalletResult
case class GetWalletInfoResult(
walletname: String, // Is this right? FILE
walletversion: Int,
balance: Bitcoins,
unconfirmed_balance: Bitcoins,
immature_balance: Bitcoins,
txcount: Int,
keypoololdest: UInt32,
keypoolsize: Int,
keypoolsize_hd_internal: Int,
paytxfee: Bitcoins,
hdmasterkeyid: DoubleSha256Digest, // Is this right?
unlocked_until: Option[Int]
) extends WalletResult

View File

@ -1,10 +1,13 @@
package org.bitcoins.rpc.serializers
import java.net.InetAddress
import org.bitcoins.core.crypto.DoubleSha256Digest
import org.bitcoins.core.currency.Bitcoins
import org.bitcoins.core.number.{Int32, UInt32}
import org.bitcoins.core.protocol.Address
import org.bitcoins.core.protocol.blockchain.BlockHeader
import org.bitcoins.core.protocol.script.ScriptPubKey
import org.bitcoins.rpc.jsonmodels._
import org.bitcoins.rpc.serializers.JsonReaders._
import play.api.libs.json.{Json, Reads}
@ -18,6 +21,8 @@ object JsonSerializers {
implicit val uInt32Reads: Reads[UInt32] = UInt32Reads
implicit val addressReads: Reads[Address] = AddressReads
implicit val unitReads: Reads[Unit] = UnitReads
implicit val inetAddressReads: Reads[InetAddress] = InetAddressReads
implicit val scriptPubKeyReads: Reads[ScriptPubKey] = ScriptPubKeyReads
// Network Models
implicit val networkReads: Reads[Network] = Json.reads[Network]
@ -28,8 +33,16 @@ object JsonSerializers {
implicit val blockHeaderFormattedReads: Reads[GetBlockHeaderResult] = Json.reads[GetBlockHeaderResult]
implicit val validateAddressResultReads: Reads[ValidateAddressResult] = Json.reads[ValidateAddressResult]
implicit val nodeBanReads: Reads[NodeBan] = Json.reads[NodeBan]
implicit val nodeAddressReads: Reads[NodeAddress] = Json.reads[NodeAddress]
implicit val nodeReads: Reads[Node] = Json.reads[Node]
// Mining Models
implicit val minginInfoReads: Reads[GetMiningInfoResult] = Json.reads[GetMiningInfoResult]
implicit val miningInfoReads: Reads[GetMiningInfoResult] = Json.reads[GetMiningInfoResult]
// Wallet Models
implicit val getWalletInfoResultReads: Reads[GetWalletInfoResult] = Json.reads[GetWalletInfoResult]
}