mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-24 06:57:51 +01:00
Added implementation and test for getBlockTemplate, replaced filter(...).head with find(...).get (performs better), and ran scalafmt
This commit is contained in:
parent
0198124259
commit
04bace39d0
2 changed files with 51 additions and 2 deletions
|
@ -1,12 +1,55 @@
|
|||
package org.bitcoins.rpc.jsonmodels
|
||||
|
||||
import org.bitcoins.core.crypto.{ECPublicKey, Sha256Hash160Digest}
|
||||
import org.bitcoins.core.crypto.{
|
||||
DoubleSha256Digest,
|
||||
ECPublicKey,
|
||||
Sha256Hash160Digest
|
||||
}
|
||||
import org.bitcoins.core.currency.Satoshis
|
||||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.protocol.BitcoinAddress
|
||||
import org.bitcoins.core.protocol.script.ScriptPubKey
|
||||
import org.bitcoins.core.protocol.transaction.Transaction
|
||||
import org.bitcoins.core.wallet.fee.BitcoinFeeUnit
|
||||
import play.api.libs.json.JsObject
|
||||
|
||||
sealed abstract class OtherResult
|
||||
|
||||
case class GetBlockTemplateResult(
|
||||
capabilities: Vector[String],
|
||||
version: Int,
|
||||
rules: Vector[String],
|
||||
vbavailable: Map[String, Int], // Is this Int or BigDecimal?
|
||||
vbrequired: Int,
|
||||
previousblockhash: DoubleSha256Digest,
|
||||
transactions: Vector[BlockTransaction],
|
||||
coinbaseaux: Map[String, String],
|
||||
coinbasevalue: Satoshis,
|
||||
longpollid: String, // What is this?
|
||||
coinbasetxn: Option[JsObject],
|
||||
target: String, // What should this be?
|
||||
mintime: UInt32,
|
||||
mutable: Vector[String],
|
||||
noncerange: String,
|
||||
sigoplimit: Int,
|
||||
sizelimit: Int,
|
||||
weightlimit: Int,
|
||||
curtime: UInt32,
|
||||
bits: String, // What should this be?
|
||||
height: Int
|
||||
) extends OtherResult
|
||||
|
||||
case class BlockTransaction(
|
||||
data: Transaction,
|
||||
txid: DoubleSha256Digest,
|
||||
hash: DoubleSha256Digest,
|
||||
depends: Vector[Int],
|
||||
fee: Satoshis,
|
||||
sigops: Int,
|
||||
weight: Int,
|
||||
required: Option[Boolean]
|
||||
) extends OtherResult
|
||||
|
||||
case class GetMiningInfoResult(
|
||||
blocks: Int,
|
||||
currentblockweight: Int,
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.bitcoins.core.crypto.{
|
|||
ECPublicKey,
|
||||
Sha256Hash160Digest
|
||||
}
|
||||
import org.bitcoins.core.currency.Bitcoins
|
||||
import org.bitcoins.core.currency.{Bitcoins, Satoshis}
|
||||
import org.bitcoins.core.number.{Int32, UInt32, UInt64}
|
||||
import org.bitcoins.core.protocol.{
|
||||
Address,
|
||||
|
@ -37,6 +37,7 @@ object JsonSerializers {
|
|||
implicit val doubleSha256DigestReads: Reads[DoubleSha256Digest] =
|
||||
DoubleSha256DigestReads
|
||||
implicit val bitcoinsReads: Reads[Bitcoins] = BitcoinsReads
|
||||
implicit val satoshisReads: Reads[Satoshis] = SatoshisReads
|
||||
implicit val blockHeaderReads: Reads[BlockHeader] = BlockHeaderReads
|
||||
implicit val int32Reads: Reads[Int32] = Int32Reads
|
||||
implicit val uInt32Reads: Reads[UInt32] = UInt32Reads
|
||||
|
@ -280,6 +281,11 @@ object JsonSerializers {
|
|||
Json.reads[UnspentOutput]
|
||||
|
||||
// Other Models
|
||||
implicit val blockTransactionReads: Reads[BlockTransaction] =
|
||||
Json.reads[BlockTransaction]
|
||||
implicit val getBlockTemplateResultReads: Reads[GetBlockTemplateResult] =
|
||||
Json.reads[GetBlockTemplateResult]
|
||||
|
||||
implicit val miningInfoReads: Reads[GetMiningInfoResult] =
|
||||
Json.reads[GetMiningInfoResult]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue