Move Json Reader, Writers, and Serializers to App Commons (#1328)

* Move Json Reader, Writers, and Serializers to App Commons

* Move app-commons outside of app/
This commit is contained in:
Ben Carman 2020-04-10 14:33:37 -05:00 committed by GitHub
parent 76a3edd0af
commit aa8a2e14a6
67 changed files with 934 additions and 246 deletions

3
app-commons/commons.sbt Normal file
View File

@ -0,0 +1,3 @@
name := "bitcoin-s-app-commons"
libraryDependencies ++= Deps.appCommons(scalaVersion.value)

View File

@ -1,12 +1,12 @@
package org.bitcoins.rpc.jsonmodels
package org.bitcoins.commons.jsonmodels.bitcoind
import org.bitcoins.core.config.NetworkParameters
import org.bitcoins.core.crypto.DoubleSha256DigestBE
import org.bitcoins.core.currency.Bitcoins
import org.bitcoins.core.gcs.GolombFilter
import org.bitcoins.core.number.{Int32, UInt32}
import org.bitcoins.core.protocol.blockchain.BlockHeader
import org.bitcoins.core.wallet.fee.BitcoinFeeUnit
import org.bitcoins.core.config.NetworkParameters
import org.bitcoins.core.gcs.GolombFilter
sealed abstract class BlockchainResult

View File

@ -1,4 +1,4 @@
package org.bitcoins.rpc.jsonmodels
package org.bitcoins.commons.jsonmodels.bitcoind
import java.net.URI

View File

@ -1,4 +1,4 @@
package org.bitcoins.rpc.jsonmodels
package org.bitcoins.commons.jsonmodels.bitcoind
import org.bitcoins.core.crypto.{
DoubleSha256Digest,

View File

@ -1,4 +1,4 @@
package org.bitcoins.rpc.jsonmodels
package org.bitcoins.commons.jsonmodels.bitcoind
import org.bitcoins.core.crypto.DoubleSha256DigestBE
import org.bitcoins.core.currency.Bitcoins

View File

@ -1,4 +1,4 @@
package org.bitcoins.rpc.client.common
package org.bitcoins.commons.jsonmodels.bitcoind
import org.bitcoins.core.crypto.{DoubleSha256DigestBE, ECPrivateKey}
import org.bitcoins.core.currency.Bitcoins
@ -6,7 +6,7 @@ import org.bitcoins.core.number.UInt32
import org.bitcoins.core.protocol.BitcoinAddress
import org.bitcoins.core.protocol.script.{ScriptPubKey, WitnessScriptPubKey}
import org.bitcoins.core.protocol.transaction.TransactionInput
import org.bitcoins.rpc.serializers.JsonWriters._
import org.bitcoins.commons.serializers.JsonWriters._
import play.api.libs.json.{Json, Writes}
object RpcOpts {

View File

@ -1,4 +1,4 @@
package org.bitcoins.rpc.jsonmodels
package org.bitcoins.commons.jsonmodels.bitcoind
import org.bitcoins.core.crypto.{ECDigitalSignature, ECPublicKey}
import org.bitcoins.core.currency.Bitcoins

View File

@ -1,8 +1,9 @@
package org.bitcoins.rpc.jsonmodels
package org.bitcoins.commons.jsonmodels.bitcoind
import java.io.File
import java.time.ZonedDateTime
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.LabelPurpose
import org.bitcoins.core.crypto.{
DoubleSha256DigestBE,
ECPublicKey,
@ -17,7 +18,6 @@ import org.bitcoins.core.protocol.script.{ScriptPubKey, WitnessVersion}
import org.bitcoins.core.protocol.transaction.Transaction
import org.bitcoins.core.script.ScriptType
import org.bitcoins.core.wallet.fee.BitcoinFeeUnit
import org.bitcoins.rpc.client.common.RpcOpts.LabelPurpose
sealed abstract class WalletResult

View File

@ -1,9 +1,10 @@
package org.bitcoins.eclair.rpc.api
package org.bitcoins.commons.jsonmodels.eclair
import java.net.InetSocketAddress
import java.time.Instant
import java.util.UUID
import org.bitcoins.commons.serializers.JsonReaders._
import org.bitcoins.core.crypto.{
DoubleSha256Digest,
DoubleSha256DigestBE,
@ -20,7 +21,6 @@ import org.bitcoins.core.protocol.ln.{
PaymentPreimage,
ShortChannelId
}
import org.bitcoins.eclair.rpc.network.PeerState
import play.api.libs.json.JsObject
import scala.concurrent.duration.FiniteDuration
@ -185,7 +185,6 @@ case class ChannelResult(
feeBaseMsat: Option[MilliSatoshis],
feeProportionalMillionths: Option[FeeProportionalMillionths],
data: JsObject) {
import org.bitcoins.eclair.rpc.client.JsonReaders._
lazy val shortChannelId: Option[ShortChannelId] =
(data \ "shortChannelId").validate[ShortChannelId].asOpt
}

View File

@ -1,4 +1,4 @@
package org.bitcoins.eclair.rpc.network
package org.bitcoins.commons.jsonmodels.eclair
sealed abstract class PeerState

View File

@ -1,31 +1,585 @@
package org.bitcoins.eclair.rpc.client
package org.bitcoins.commons.serializers
import java.net.InetSocketAddress
import java.time.Instant
import java.io.File
import java.net.{InetAddress, InetSocketAddress, URI}
import java.time._
import java.util.UUID
import org.bitcoins.core.crypto.{
DoubleSha256Digest,
DoubleSha256DigestBE,
ECDigitalSignature,
Sha256Digest
}
import org.bitcoins.core.currency.Satoshis
import org.bitcoins.commons.jsonmodels._
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.LabelPurpose
import org.bitcoins.commons.jsonmodels.bitcoind._
import org.bitcoins.commons.jsonmodels.eclair._
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.core.config._
import org.bitcoins.core.crypto._
import org.bitcoins.core.currency.{Bitcoins, Satoshis}
import org.bitcoins.core.number.{Int32, UInt32, UInt64}
import org.bitcoins.core.p2p.ServiceIdentifier
import org.bitcoins.core.protocol.blockchain.{Block, BlockHeader, MerkleBlock}
import org.bitcoins.core.protocol.ln._
import org.bitcoins.core.protocol.ln.channel.{ChannelState, FundedChannelId}
import org.bitcoins.core.protocol.ln.currency.{MilliSatoshis, PicoBitcoins}
import org.bitcoins.core.protocol.ln.channel._
import org.bitcoins.core.protocol.ln.currency._
import org.bitcoins.core.protocol.ln.fee.FeeProportionalMillionths
import org.bitcoins.core.protocol.ln.node.NodeId
import org.bitcoins.eclair.rpc.api._
import org.bitcoins.eclair.rpc.network.PeerState
import org.bitcoins.rpc.serializers.SerializerUtil
import org.bitcoins.core.protocol.script.{
ScriptPubKey,
ScriptSignature,
WitnessVersion,
WitnessVersion0
}
import org.bitcoins.core.protocol.transaction._
import org.bitcoins.core.protocol.{
Address,
BitcoinAddress,
P2PKHAddress,
P2SHAddress
}
import org.bitcoins.core.script.ScriptType
import org.bitcoins.core.script.crypto.HashType
import org.bitcoins.core.wallet.fee.{BitcoinFeeUnit, SatoshisPerByte}
import play.api.libs.json._
import scala.concurrent.duration._
import scala.util.{Failure, Success, Try}
object JsonReaders {
import org.bitcoins.rpc.serializers.JsonReaders._
/**
* Tries to prase the provided JSON into a map with keys of
* type `K` and values of type `V`
*/
def mapReads[K, V](js: JsValue)(
implicit readsK: Reads[K],
readsV: Reads[V]): JsResult[Map[K, V]] = {
js.validate[JsObject].flatMap { jsObj =>
val jsResults: scala.collection.Seq[(JsResult[K], JsResult[V])] =
jsObj.fields.map {
case (key, value) => JsString(key).validate[K] -> value.validate[V]
}
val allErrors: scala.collection.Seq[(
JsPath,
scala.collection.Seq[JsonValidationError])] =
jsResults.collect {
case (JsError(keyErrors), _) => keyErrors
case (_, JsError(valueErrors)) => valueErrors
}.flatten
if (allErrors.nonEmpty) {
JsError(allErrors)
} else {
JsSuccess(jsResults.collect {
case (JsSuccess(k, _), JsSuccess(v, _)) =>
k -> v
}.toMap)
}
}
}
implicit object ZonedDateTimeReads extends Reads[ZonedDateTime] {
override def reads(json: JsValue): JsResult[ZonedDateTime] =
SerializerUtil.processJsNumberBigInt[ZonedDateTime](
bigInt =>
ZonedDateTime.ofInstant(Instant.ofEpochSecond(bigInt.toLong),
ZoneOffset.UTC))(json)
}
implicit object LocalDateTimeReads extends Reads[LocalDateTime] {
override def reads(json: JsValue): JsResult[LocalDateTime] =
SerializerUtil.processJsNumberBigInt[LocalDateTime](
bigInt =>
LocalDateTime.ofInstant(Instant.ofEpochSecond(bigInt.toLong),
ZoneId.systemDefault()))(json)
}
implicit object BigIntReads extends Reads[BigInt] {
override def reads(json: JsValue): JsResult[BigInt] =
SerializerUtil.processJsNumber[BigInt](_.toBigInt)(json)
}
implicit object Sha256DigestReads extends Reads[Sha256Digest] {
override def reads(json: JsValue): JsResult[Sha256Digest] =
SerializerUtil.processJsString[Sha256Digest](Sha256Digest.fromHex)(json)
}
implicit object RipeMd160DigestReads extends Reads[RipeMd160Digest] {
override def reads(json: JsValue): JsResult[RipeMd160Digest] =
SerializerUtil.processJsString[RipeMd160Digest](RipeMd160Digest.fromHex)(
json)
}
implicit object RipeMd160DigestBEReads extends Reads[RipeMd160DigestBE] {
override def reads(json: JsValue): JsResult[RipeMd160DigestBE] =
SerializerUtil.processJsString[RipeMd160DigestBE](
RipeMd160DigestBE.fromHex)(json)
}
implicit object DoubleSha256DigestReads extends Reads[DoubleSha256Digest] {
override def reads(json: JsValue): JsResult[DoubleSha256Digest] =
SerializerUtil.processJsString[DoubleSha256Digest](
DoubleSha256Digest.fromHex)(json)
}
implicit object DoubleSha256DigestBEReads
extends Reads[DoubleSha256DigestBE] {
override def reads(json: JsValue): JsResult[DoubleSha256DigestBE] =
SerializerUtil.processJsString[DoubleSha256DigestBE](
DoubleSha256DigestBE.fromHex)(json)
}
implicit object BitcoinsReads extends Reads[Bitcoins] {
override def reads(json: JsValue): JsResult[Bitcoins] =
SerializerUtil.processJsNumber[Bitcoins](Bitcoins(_))(json)
}
implicit object SatoshisReads extends Reads[Satoshis] {
override def reads(json: JsValue): JsResult[Satoshis] =
SerializerUtil.processJsNumber[Satoshis](num => Satoshis(num.toBigInt))(
json)
}
implicit object BlockHeaderReads extends Reads[BlockHeader] {
override def reads(json: JsValue): JsResult[BlockHeader] =
SerializerUtil.processJsString[BlockHeader](BlockHeader.fromHex)(json)
}
implicit object Int32Reads extends Reads[Int32] {
override def reads(json: JsValue): JsResult[Int32] = json match {
case JsNumber(n) =>
n.toBigIntExact match {
case Some(num) => JsSuccess(Int32(num))
case None => SerializerUtil.buildErrorMsg("Int32", n)
}
case JsString(s) => JsSuccess(Int32.fromHex(s))
case err @ (JsNull | _: JsBoolean | _: JsArray | _: JsObject) =>
SerializerUtil.buildJsErrorMsg("jsnumber", err)
}
}
implicit object UInt32Reads extends Reads[UInt32] {
override def reads(json: JsValue): JsResult[UInt32] = json match {
case JsNumber(n) =>
n.toBigIntExact match {
case Some(num) =>
if (num >= 0) {
JsSuccess(UInt32(num))
} else {
SerializerUtil.buildErrorMsg("positive_value", num)
}
case None => SerializerUtil.buildErrorMsg("UInt32", n)
}
case JsString(s) => JsSuccess(UInt32.fromHex(s))
case err @ (JsNull | _: JsBoolean | _: JsArray | _: JsObject) =>
SerializerUtil.buildJsErrorMsg("jsnumber", err)
}
}
implicit object UInt64Reads extends Reads[UInt64] {
override def reads(json: JsValue): JsResult[UInt64] = json match {
case JsNumber(n) =>
n.toBigIntExact match {
case Some(num) =>
if (num >= 0) {
JsSuccess(UInt64(num))
} else {
SerializerUtil.buildErrorMsg("positive_value", num)
}
case None => SerializerUtil.buildErrorMsg("UInt32", n)
}
case JsString(s) => JsSuccess(UInt64.fromHex(s))
case err @ (JsNull | _: JsBoolean | _: JsArray | _: JsObject) =>
SerializerUtil.buildJsErrorMsg("jsnumber", err)
}
}
implicit object LabelPurposeReads extends Reads[LabelPurpose] {
override def reads(json: JsValue): JsResult[LabelPurpose] =
json match {
case JsString("send") => JsSuccess(LabelPurpose.Send)
case JsString("receive") => JsSuccess(LabelPurpose.Receive)
// TODO better error message?
case err =>
SerializerUtil.buildErrorMsg(expected = "send or receive", err)
}
}
implicit object WitnessVersionReads extends Reads[WitnessVersion] {
override def reads(json: JsValue): JsResult[WitnessVersion] =
json match {
case JsNumber(num) if num == 0 => JsSuccess(WitnessVersion0)
case JsNumber(num) if num != 0 =>
SerializerUtil.buildErrorMsg("Expected witness_version 0", num)
case err =>
SerializerUtil.buildErrorMsg("Expected numerical witness_version",
err)
}
}
implicit object AddressReads extends Reads[Address] {
override def reads(json: JsValue): JsResult[Address] = json match {
case JsString(s) =>
Address.fromString(s) match {
case Success(address) => JsSuccess(address)
case Failure(err) =>
SerializerUtil.buildErrorMsg("address", err)
}
case err @ (JsNull | _: JsBoolean | _: JsNumber | _: JsArray |
_: JsObject) =>
SerializerUtil.buildJsErrorMsg("jsstring", err)
}
}
// Errors for Unit return types are caught in RpcClient::checkUnit
implicit object UnitReads extends Reads[Unit] {
override def reads(json: JsValue): JsResult[Unit] = JsSuccess(())
}
implicit object InetAddressReads extends Reads[InetAddress] {
override def reads(json: JsValue): JsResult[InetAddress] =
SerializerUtil.processJsString[InetAddress](InetAddress.getByName)(json)
}
implicit object ECDigitalSignatureReads extends Reads[ECDigitalSignature] {
override def reads(json: JsValue): JsResult[ECDigitalSignature] = {
SerializerUtil.processJsString(ECDigitalSignature.fromHex)(json)
}
}
implicit object ScriptPubKeyReads extends Reads[ScriptPubKey] {
override def reads(json: JsValue): JsResult[ScriptPubKey] =
SerializerUtil.processJsString[ScriptPubKey](ScriptPubKey.fromAsmHex)(
json)
}
implicit object BlockReads extends Reads[Block] {
override def reads(json: JsValue): JsResult[Block] =
SerializerUtil.processJsString[Block](Block.fromHex)(json)
}
implicit object Sha256Hash160DigestReads extends Reads[Sha256Hash160Digest] {
override def reads(json: JsValue): JsResult[Sha256Hash160Digest] =
SerializerUtil.processJsString[Sha256Hash160Digest](
Sha256Hash160Digest.fromHex)(json)
}
implicit object ECPublicKeyReads extends Reads[ECPublicKey] {
override def reads(json: JsValue): JsResult[ECPublicKey] =
SerializerUtil.processJsString[ECPublicKey](ECPublicKey.fromHex)(json)
}
implicit object P2PKHAddressReads extends Reads[P2PKHAddress] {
override def reads(json: JsValue): JsResult[P2PKHAddress] = json match {
case JsString(s) =>
P2PKHAddress.fromString(s) match {
case Success(address) => JsSuccess(address)
case Failure(err) =>
SerializerUtil.buildErrorMsg("p2pkhaddress", err)
}
case err @ (JsNull | _: JsBoolean | _: JsNumber | _: JsArray |
_: JsObject) =>
SerializerUtil.buildJsErrorMsg("jsstring", err)
}
}
implicit object P2SHAddressReads extends Reads[P2SHAddress] {
override def reads(json: JsValue): JsResult[P2SHAddress] = json match {
case JsString(s) =>
P2SHAddress.fromString(s) match {
case Success(address) => JsSuccess(address)
case Failure(err) =>
SerializerUtil.buildErrorMsg("p2shaddress", err)
}
case err @ (JsNull | _: JsBoolean | _: JsNumber | _: JsArray |
_: JsObject) =>
SerializerUtil.buildJsErrorMsg("jsstring", err)
}
}
implicit object ScriptSignatureReads extends Reads[ScriptSignature] {
override def reads(json: JsValue): JsResult[ScriptSignature] =
SerializerUtil.processJsString[ScriptSignature](
ScriptSignature.fromAsmHex)(json)
}
implicit object TransactionInputReads extends Reads[TransactionInput] {
override def reads(json: JsValue): JsResult[TransactionInput] = {
(json \ "sequence").validate[UInt32].flatMap { sequence =>
(json \ "coinbase").validate[String] match {
case s: JsSuccess[String] =>
JsSuccess(
CoinbaseInput(ScriptSignature.fromAsmHex(s.value), sequence))
case _ =>
(json \ "txid").validate[DoubleSha256DigestBE].flatMap { txid =>
(json \ "vout").validate[UInt32].flatMap { vout =>
(json \ "scriptSig" \ "hex")
.validate[ScriptSignature]
.flatMap { scriptSig =>
JsSuccess(
TransactionInput(TransactionOutPoint(txid.flip, vout),
scriptSig,
sequence))
}
}
}
}
}
}
}
implicit object BitcoinAddressReads extends Reads[BitcoinAddress] {
override def reads(json: JsValue): JsResult[BitcoinAddress] = json match {
case JsString(s) =>
BitcoinAddress.fromString(s) match {
case Success(address) =>
JsSuccess(address)
case Failure(err) =>
SerializerUtil.buildErrorMsg("address", err)
}
case err @ (JsNull | _: JsBoolean | _: JsNumber | _: JsArray |
_: JsObject) =>
SerializerUtil.buildJsErrorMsg("jsstring", err)
}
}
implicit object MerkleBlockReads extends Reads[MerkleBlock] {
override def reads(json: JsValue): JsResult[MerkleBlock] =
SerializerUtil.processJsString[MerkleBlock](MerkleBlock.fromHex)(json)
}
implicit object TransactionReads extends Reads[Transaction] {
override def reads(json: JsValue): JsResult[Transaction] =
SerializerUtil.processJsString[Transaction](Transaction.fromHex)(json)
}
implicit object TransactionOutPointReads extends Reads[TransactionOutPoint] {
private case class OutPoint(txid: DoubleSha256DigestBE, vout: UInt32)
override def reads(json: JsValue): JsResult[TransactionOutPoint] = {
implicit val outPointReads: Reads[OutPoint] = Json.reads[OutPoint]
json.validate[OutPoint] match {
case JsSuccess(op, _) =>
JsSuccess(TransactionOutPoint(op.txid.flip, op.vout))
case JsError(err) =>
JsError(s"Could not parse TransactionOutPoint, got ${err.toString()}")
}
}
}
implicit object RpcAddressReads extends Reads[RpcAddress] {
def reads(json: JsValue): JsResult[RpcAddress] = json match {
case array: JsArray =>
val bitcoinResult = array.value.find(_.isInstanceOf[JsNumber]) match {
case Some(JsNumber(n)) => JsSuccess(Bitcoins(n))
case Some(
err @ (JsNull | _: JsBoolean | _: JsString | _: JsArray |
_: JsObject)) =>
SerializerUtil.buildJsErrorMsg("jsnumber", err)
case None => JsError("error.expected.balance")
}
bitcoinResult.flatMap { bitcoins =>
val jsStrings =
array.value
.filter(_.isInstanceOf[JsString])
.map(_.asInstanceOf[JsString].value)
val addressResult = jsStrings.find(BitcoinAddress.isValid) match {
case Some(s) =>
BitcoinAddress.fromString(s) match {
case Success(a) => JsSuccess(a)
case Failure(err) =>
SerializerUtil.buildErrorMsg("address", err)
}
case None => JsError("error.expected.address")
}
addressResult.flatMap { address =>
val account = jsStrings.find(s => !BitcoinAddress.isValid(s))
JsSuccess(RpcAddress(address, bitcoins, account))
}
}
case err @ (JsNull | _: JsBoolean | _: JsNumber | _: JsString |
_: JsObject) =>
SerializerUtil.buildJsErrorMsg("jsarray", err)
}
}
implicit object HashTypeReads extends Reads[HashType] {
override def reads(json: JsValue): JsResult[HashType] =
SerializerUtil.processJsString {
case "ALL" => HashType.sigHashAll
case "NONE" => HashType.sigHashNone
case "SINGLE" => HashType.sigHashSingle
case "ALL|ANYONECANPAY" => HashType.sigHashAllAnyoneCanPay
case "NONE|ANYONECANPAY" => HashType.sigHashNoneAnyoneCanPay
case "SINGLE|ANYONECANPAY" => HashType.sigHashSingleAnyoneCanPay
}(json)
}
implicit object FinalizedPsbtReads extends Reads[FinalizedPsbt] {
override def reads(json: JsValue): JsResult[FinalizedPsbt] =
(json \ "complete").validate[Boolean].flatMap { completed =>
if (completed) {
(json \ "hex").validate[Transaction].flatMap { tx =>
JsSuccess(FinalizedPsbt(tx))
}
} else {
JsError("PSBT was not completed!")
}
}
}
implicit object NonFinalizedPsbtReads extends Reads[NonFinalizedPsbt] {
override def reads(json: JsValue): JsResult[NonFinalizedPsbt] =
if ((json \ "hex").isDefined) {
JsError("PSBT was submitted as a serialized hex transaction!")
} else {
(json \ "psbt").validate[String].map(NonFinalizedPsbt)
}
}
implicit object FinalizePsbtResultReads extends Reads[FinalizePsbtResult] {
override def reads(json: JsValue): JsResult[FinalizePsbtResult] =
if ((json \ "hex").isDefined) {
json.validate[FinalizedPsbt]
} else {
json.validate[NonFinalizedPsbt]
}
}
implicit object RpcPsbtOutputReads extends Reads[RpcPsbtOutput] {
override def reads(json: JsValue): JsResult[RpcPsbtOutput] =
for {
redeemScript <- (json \ "redeem_script").validateOpt[RpcPsbtScript]
witnessScript <- (json \ "witness_script").validateOpt[RpcPsbtScript]
unknown <- (json \ "unknown").validateOpt[Map[String, String]]
bip32Derivs <- (json \ "bip32_derivs")
.validateOpt[Vector[PsbtBIP32Deriv]]
} yield RpcPsbtOutput(redeemScript, witnessScript, bip32Derivs, unknown)
}
implicit object PsbtBIP32DerivsReads extends Reads[PsbtBIP32Deriv] {
override def reads(json: JsValue): JsResult[PsbtBIP32Deriv] =
for {
pubkey <- (json \ "pubkey").validate[ECPublicKey]
masterFingerprint <- (json \ "master_fingerprint").validate[String]
path <- (json \ "path").validate[String]
} yield PsbtBIP32Deriv(pubkey = pubkey,
masterFingerprint = masterFingerprint,
path = path)
}
implicit object RpcPsbtScriptReads extends Reads[RpcPsbtScript] {
override def reads(json: JsValue): JsResult[RpcPsbtScript] =
for {
asm <- (json \ "asm").validate[String]
hex <- (json \ "hex").validate[ScriptPubKey]
scriptType <- (json \ "type").validateOpt[ScriptType]
address <- (json \ "address").validateOpt[BitcoinAddress]
} yield RpcPsbtScript(asm = asm,
hex = hex,
scriptType = scriptType,
address = address)
}
implicit object MapPubKeySignatureReads
extends Reads[Map[ECPublicKey, ECDigitalSignature]] {
override def reads(
json: JsValue): JsResult[Map[ECPublicKey, ECDigitalSignature]] =
JsonReaders.mapReads(json)(implicitly[Reads[ECPublicKey]],
implicitly[Reads[ECDigitalSignature]])
}
implicit object RpcPsbtInputReads extends Reads[RpcPsbtInput] {
override def reads(json: JsValue): JsResult[RpcPsbtInput] =
for {
nonWitnessUtxo <- (json \ "non_witness_utxo")
.validateOpt[RpcTransaction]
witnessUtxo <- (json \ "witness_utxo").validateOpt[PsbtWitnessUtxoInput]
finalScriptSig <- (json \ "final_scriptSig").validateOpt[RpcPsbtScript]
redeemScript <- (json \ "redeem_script").validateOpt[RpcPsbtScript]
sighash <- (json \ "sighash").validateOpt[HashType]
partialSignatures <- (json \ "partial_signatures")
.validateOpt[Map[ECPublicKey, ECDigitalSignature]]
witnessScript <- (json \ "witness_script").validateOpt[RpcPsbtScript]
bip32Derivs <- (json \ "bi32_derivs")
.validateOpt[Vector[PsbtBIP32Deriv]]
finalScriptWitness <- JsSuccess(None) // todo(torkelrogstad) find an example of this
unknown <- (json \ "unknown").validateOpt[Map[String, String]]
} yield {
bitcoind.RpcPsbtInput(
nonWitnessUtxo = nonWitnessUtxo,
witnessUtxo = witnessUtxo,
partialSignatures = partialSignatures,
sighash = sighash,
redeemScript = redeemScript,
witnessScript = witnessScript,
bip32Derivs = bip32Derivs,
finalScriptSig = finalScriptSig,
finalScriptwitness = finalScriptWitness,
unknown = unknown
)
}
}
implicit object ScriptTypeReads extends Reads[ScriptType] {
override def reads(json: JsValue): JsResult[ScriptType] =
json
.validate[String]
.map(ScriptType.fromStringExn)
}
implicit object TestMempoolAcceptResultReads
extends Reads[TestMempoolAcceptResult] {
override def reads(json: JsValue): JsResult[TestMempoolAcceptResult] =
for {
txid <- (json \ "txid").validate[DoubleSha256DigestBE]
allowed <- (json \ "allowed").validate[Boolean]
rejectReason <- (json \ "reject-reason").validateOpt[String]
} yield TestMempoolAcceptResult(txid, allowed, rejectReason)
}
// Currently takes in BTC/kB
implicit object BitcoinFeeUnitReads extends Reads[BitcoinFeeUnit] {
override def reads(json: JsValue): JsResult[BitcoinFeeUnit] =
SerializerUtil.processJsNumber[BitcoinFeeUnit](num =>
SatoshisPerByte(Satoshis((num * 100000).toBigInt)))(json)
}
implicit object FileReads extends Reads[File] {
override def reads(json: JsValue): JsResult[File] =
SerializerUtil.processJsString[File](new File(_))(json)
}
implicit object URIReads extends Reads[URI] {
override def reads(json: JsValue): JsResult[URI] =
SerializerUtil.processJsString[URI](str => new URI("http://" + str))(json)
}
implicit object NetworkParamsReads extends Reads[NetworkParameters] {
def reads(json: JsValue): JsResult[NetworkParameters] =
json.validate[String].map(_.toLowerCase()).map {
case "regtest" => RegTest
case "main" => MainNet
case "test" => TestNet3
}
}
implicit object ServiceIdentifierReads extends Reads[ServiceIdentifier] {
override def reads(json: JsValue): JsResult[ServiceIdentifier] =
json match {
case JsString(s) =>
Try(ServiceIdentifier.fromString(s)) match {
case Success(serviceIdentifier) => JsSuccess(serviceIdentifier)
case Failure(err) =>
SerializerUtil.buildJsErrorMsg(
s"Unexpected Service Identifier: $err",
json)
}
case err @ (JsNull | _: JsBoolean | _: JsNumber | _: JsArray |
_: JsObject) =>
SerializerUtil.buildJsErrorMsg("jsstring", err)
}
}
implicit val feeProportionalMillionthsReads: Reads[
FeeProportionalMillionths] = Reads { js =>

View File

@ -1,4 +1,4 @@
package org.bitcoins.rpc.serializers
package org.bitcoins.commons.serializers
import java.io.File
import java.net.{InetAddress, URI}
@ -22,11 +22,105 @@ import org.bitcoins.core.protocol.{
}
import org.bitcoins.core.script.ScriptType
import org.bitcoins.core.wallet.fee.{BitcoinFeeUnit, SatoshisPerKiloByte}
import org.bitcoins.rpc.client.common.RpcOpts.AddressType
import org.bitcoins.rpc.jsonmodels._
import org.bitcoins.rpc.serializers.JsonReaders._
import org.bitcoins.rpc.serializers.JsonWriters._
import org.bitcoins.commons.serializers.JsonReaders._
import org.bitcoins.commons.serializers.JsonWriters._
import java.time.LocalDateTime
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.AddressType
import org.bitcoins.commons.jsonmodels.bitcoind.{
AddressInfoResult,
AnalyzePsbtInput,
AnalyzePsbtResult,
ArrayOfWalletsInput,
BalanceInfo,
Bip9Softfork,
BlockTransaction,
BumpFeeResult,
ChainTip,
CreateWalletResult,
DecodePsbtResult,
DecodeScriptResult,
DeriveAddressesResult,
DumpWalletResult,
EmbeddedResult,
EstimateSmartFeeResult,
FeeInfo,
FinalizePsbtResult,
FinalizedPsbt,
FundRawTransactionResult,
GetBalancesResult,
GetBlockChainInfoResult,
GetBlockHeaderResult,
GetBlockResult,
GetBlockTemplateResult,
GetBlockWithTransactionsResult,
GetChainTxStatsResult,
GetDescriptorInfoResult,
GetMemPoolEntryResultPostV19,
GetMemPoolEntryResultPreV19,
GetMemPoolInfoResult,
GetMemPoolResultPostV19,
GetMemPoolResultPreV19,
GetMemoryInfoResult,
GetMiningInfoResult,
GetNetTotalsResult,
GetNetworkInfoResult,
GetNodeAddressesResult,
GetRawTransactionResult,
GetRawTransactionScriptSig,
GetRawTransactionVin,
GetRpcInfoResult,
GetTransactionResult,
GetTxOutResult,
GetTxOutSetInfoResult,
GetWalletInfoResult,
ImportMultiError,
ImportMultiResult,
LabelResult,
ListSinceBlockResult,
ListTransactionsResult,
ListWalletDirResult,
MemoryManager,
MultiSigResult,
NetTarget,
Network,
NetworkAddress,
Node,
NodeAddress,
NodeBan,
NonFinalizedPsbt,
Payment,
Peer,
PeerNetworkInfo,
PsbtBIP32Deriv,
PsbtMissingData,
PsbtWitnessUtxoInput,
ReceivedAccount,
ReceivedAddress,
ReceivedLabel,
RescanBlockChainResult,
RpcAccount,
RpcAddress,
RpcCommands,
RpcPsbtInput,
RpcPsbtOutput,
RpcPsbtScript,
RpcScriptPubKey,
RpcTransaction,
RpcTransactionOutput,
SetWalletFlagResult,
SignRawTransactionError,
SignRawTransactionResult,
Softfork,
SoftforkProgress,
SubmitHeaderResult,
TestMempoolAcceptResult,
TransactionDetails,
UnspentOutput,
ValidateAddressResultImpl,
WalletCreateFundedPsbtResult,
WalletProcessPsbtResult
}
import play.api.libs.functional.syntax._
import play.api.libs.json._
@ -75,6 +169,7 @@ object JsonSerializers {
implicit val scriptSignatureReads: Reads[ScriptSignature] =
ScriptSignatureReads
implicit val addressTypeWrites: Writes[AddressType] = AddressTypeWrites
implicit val bitcoinsWrites: Writes[Bitcoins] = BitcoinsWrites
implicit val bitcoinAddressWrites: Writes[BitcoinAddress] =
BitcoinAddressWrites
@ -225,8 +320,6 @@ object JsonSerializers {
implicit val getTxOutSetInfoResultReads: Reads[GetTxOutSetInfoResult] =
Json.reads[GetTxOutSetInfoResult]
implicit val addressTypeWrites: Writes[AddressType] = AddressTypeWrites
implicit object Bip32PathFormats extends Format[BIP32Path] {
override def reads(json: JsValue): JsResult[BIP32Path] =
json.validate[String].map(BIP32Path.fromString)

View File

@ -1,5 +1,9 @@
package org.bitcoins.rpc.serializers
package org.bitcoins.commons.serializers
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.{
AddressType,
WalletCreateFundedPsbtOptions
}
import org.bitcoins.core.crypto.{DoubleSha256Digest, DoubleSha256DigestBE}
import org.bitcoins.core.currency.Bitcoins
import org.bitcoins.core.number.UInt32
@ -9,10 +13,6 @@ import org.bitcoins.core.protocol.script.ScriptPubKey
import org.bitcoins.core.protocol.transaction.{Transaction, TransactionInput}
import org.bitcoins.core.script.crypto._
import org.bitcoins.core.util.BitcoinSUtil
import org.bitcoins.rpc.client.common.RpcOpts.{
AddressType,
WalletCreateFundedPsbtOptions
}
import play.api.libs.json._
import scala.collection.mutable

View File

@ -1,18 +1,18 @@
package org.bitcoins
package org.bitcoins.commons.serializers
import org.bitcoins.core.crypto.ExtPublicKey
import org.bitcoins.core.protocol.{BitcoinAddress, BlockStamp}
import org.bitcoins.core.currency.{Bitcoins, Satoshis}
import org.bitcoins.core.protocol.transaction.Transaction
import org.bitcoins.core.protocol.{BitcoinAddress, BlockStamp}
import org.bitcoins.core.psbt.PSBT
import org.bitcoins.core.wallet.fee.SatoshisPerVirtualByte
import upickle.default._
package object picklers {
object Picklers {
import org.bitcoins.core.crypto.DoubleSha256DigestBE
implicit val bitcoinAddressPickler: ReadWriter[BitcoinAddress] =
readwriter[String]
.bimap(_.value, BitcoinAddress.fromStringExn(_))
.bimap(_.value, BitcoinAddress.fromStringExn)
implicit val bitcoinsPickler: ReadWriter[Bitcoins] =
readwriter[Double].bimap(_.toBigDecimal.toDouble, Bitcoins(_))

View File

@ -1,4 +1,4 @@
package org.bitcoins.rpc.serializers
package org.bitcoins.commons.serializers
import play.api.libs.json._

View File

@ -8,7 +8,7 @@ import org.bitcoins.core.protocol.transaction.{EmptyTransaction, Transaction}
import org.bitcoins.core.protocol.{BitcoinAddress, BlockStamp}
import org.bitcoins.core.psbt.PSBT
import org.bitcoins.core.wallet.fee.SatoshisPerVirtualByte
import org.bitcoins.picklers._
import org.bitcoins.commons.serializers.Picklers._
import scopt.OParser
import ujson.{Num, Str}
import upickle.{default => up}

View File

@ -6,7 +6,7 @@ import akka.http.scaladsl.server.Directives._
import akka.stream.ActorMaterializer
import org.bitcoins.chain.api.ChainApi
import org.bitcoins.picklers._
import org.bitcoins.commons.serializers.Picklers._
case class ChainRoutes(chain: ChainApi)(implicit system: ActorSystem)
extends ServerRoute {

View File

@ -7,7 +7,7 @@ import akka.stream.ActorMaterializer
import org.bitcoins.core.currency._
import org.bitcoins.core.wallet.fee.SatoshisPerByte
import org.bitcoins.node.Node
import org.bitcoins.picklers._
import org.bitcoins.commons.serializers.Picklers._
import org.bitcoins.wallet.api.UnlockedWalletApi
import scala.concurrent.Future

View File

@ -4,8 +4,8 @@ import java.io.File
import java.nio.file.{Files, StandardOpenOption}
import akka.actor.ActorSystem
import org.bitcoins.commons.jsonmodels.eclair.PaymentId
import org.bitcoins.core.protocol.ln.currency._
import org.bitcoins.eclair.rpc.api.PaymentId
import org.bitcoins.testkit.async.TestAsyncUtil
import org.bitcoins.testkit.eclair.rpc.EclairRpcTestUtil

View File

@ -3,13 +3,13 @@ package org.bitcoins.bench.eclair
import java.util.concurrent.ConcurrentHashMap
import java.util.function.BiFunction
import org.bitcoins.core.crypto.Sha256Digest
import org.bitcoins.eclair.rpc.api.WebSocketEvent.{
import org.bitcoins.commons.jsonmodels.eclair.{PaymentId, WebSocketEvent}
import org.bitcoins.commons.jsonmodels.eclair.WebSocketEvent.{
PaymentFailed,
PaymentReceived,
PaymentSent
}
import org.bitcoins.eclair.rpc.api.{PaymentId, WebSocketEvent}
import org.bitcoins.core.crypto.Sha256Digest
import scala.concurrent.Promise

View File

@ -1,15 +1,18 @@
package org.bitcoins.rpc.common
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.{
AddNodeArgument,
AddressType
}
import org.bitcoins.core.config.RegTest
import org.bitcoins.core.currency.Bitcoins
import org.bitcoins.core.number.UInt32
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
import org.bitcoins.rpc.client.common.RpcOpts.{AddNodeArgument, AddressType}
import org.bitcoins.rpc.util.AsyncUtil
import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil
import org.bitcoins.testkit.util.BitcoindRpcTest
import scala.concurrent.Future
import org.bitcoins.core.config.RegTest
class BlockchainRpcTest extends BitcoindRpcTest {

View File

@ -1,9 +1,9 @@
package org.bitcoins.rpc.common
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.AddressType
import org.bitcoins.core.crypto.ECPrivateKey
import org.bitcoins.core.protocol.P2PKHAddress
import org.bitcoins.rpc.client.common.BitcoindRpcClient
import org.bitcoins.rpc.client.common.RpcOpts.AddressType
import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil
import org.bitcoins.testkit.util.BitcoindRpcTest

View File

@ -1,9 +1,9 @@
package org.bitcoins.rpc.common
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.AddressType
import org.bitcoins.core.crypto.ECPrivateKey
import org.bitcoins.core.protocol.P2PKHAddress
import org.bitcoins.rpc.client.common.BitcoindRpcClient
import org.bitcoins.rpc.client.common.RpcOpts.AddressType
import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil
import org.bitcoins.testkit.util.BitcoindRpcTest

View File

@ -2,9 +2,12 @@ package org.bitcoins.rpc.common
import java.net.URI
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.{
AddNodeArgument,
SetBanCommand
}
import org.bitcoins.core.number.UInt32
import org.bitcoins.rpc.client.common.BitcoindRpcClient
import org.bitcoins.rpc.client.common.RpcOpts.{AddNodeArgument, SetBanCommand}
import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil
import org.bitcoins.testkit.util.BitcoindRpcTest

View File

@ -1,5 +1,6 @@
package org.bitcoins.rpc.common
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts
import org.bitcoins.core.currency.Bitcoins
import org.bitcoins.core.number.UInt32
import org.bitcoins.core.protocol.script.{
@ -11,12 +12,12 @@ import org.bitcoins.core.protocol.transaction.{
TransactionInput,
TransactionOutPoint
}
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, RpcOpts}
import org.bitcoins.rpc.BitcoindException.InvalidAddressOrKey
import org.bitcoins.rpc.client.common.BitcoindRpcClient
import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil
import org.bitcoins.testkit.util.BitcoindRpcTest
import scala.concurrent.Future
import org.bitcoins.rpc.BitcoindException.InvalidAddressOrKey
class RawTransactionRpcTest extends BitcoindRpcTest {
lazy val clientsF: Future[(BitcoindRpcClient, BitcoindRpcClient)] =

View File

@ -1,6 +1,7 @@
package org.bitcoins.rpc.common
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, RpcOpts}
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts
import org.bitcoins.rpc.client.common.BitcoindRpcClient
import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil
import org.bitcoins.testkit.util.BitcoindRpcTest

View File

@ -1,10 +1,10 @@
package org.bitcoins.rpc.common
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.AddressType
import org.bitcoins.core.crypto.ECPrivateKey
import org.bitcoins.core.protocol.P2PKHAddress
import org.bitcoins.core.script.ScriptType
import org.bitcoins.rpc.client.common.BitcoindRpcClient
import org.bitcoins.rpc.client.common.RpcOpts.AddressType
import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil
import org.bitcoins.testkit.util.BitcoindRpcTest

View File

@ -3,6 +3,7 @@ package org.bitcoins.rpc.common
import java.io.File
import java.util.Scanner
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts
import org.bitcoins.core.crypto.{
DoubleSha256DigestBE,
ECPrivateKey,
@ -17,12 +18,8 @@ import org.bitcoins.core.protocol.transaction.{
}
import org.bitcoins.core.protocol.{BitcoinAddress, P2PKHAddress}
import org.bitcoins.core.wallet.fee.SatoshisPerByte
import org.bitcoins.rpc.client.common.RpcOpts.AddressType
import org.bitcoins.rpc.client.common.{
BitcoindRpcClient,
BitcoindVersion,
RpcOpts
}
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.AddressType
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
import org.bitcoins.rpc.util.RpcUtil
import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil
import org.bitcoins.testkit.util.BitcoindRpcTest

View File

@ -1,5 +1,6 @@
package org.bitcoins.rpc.v16
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.SignRawTransactionOutputParameter
import org.bitcoins.core.crypto.{DoubleSha256DigestBE, ECPrivateKey}
import org.bitcoins.core.currency.Bitcoins
import org.bitcoins.core.number.UInt32
@ -10,7 +11,7 @@ import org.bitcoins.core.protocol.transaction.{
TransactionInput,
TransactionOutPoint
}
import org.bitcoins.rpc.client.common.RpcOpts.SignRawTransactionOutputParameter
import org.bitcoins.rpc.client.common.BitcoindVersion
import org.bitcoins.rpc.client.v16.BitcoindV16RpcClient
import org.bitcoins.rpc.util.AsyncUtil
import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil
@ -20,7 +21,6 @@ import scala.async.Async.{async, await}
import scala.concurrent.Future
import scala.concurrent.duration.DurationInt
import scala.util.Properties
import org.bitcoins.rpc.client.common.BitcoindVersion
class BitcoindV16RpcClientTest extends BitcoindRpcTest {
lazy val clientsF: Future[(BitcoindV16RpcClient, BitcoindV16RpcClient)] =

View File

@ -1,5 +1,10 @@
package org.bitcoins.rpc.v17
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.{
AddressType,
LabelPurpose,
SignRawTransactionOutputParameter
}
import org.bitcoins.core.config.RegTest
import org.bitcoins.core.crypto.{DoubleSha256DigestBE, ECPrivateKey}
import org.bitcoins.core.currency.Bitcoins
@ -7,11 +12,6 @@ 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.TransactionInput
import org.bitcoins.rpc.client.common.RpcOpts.{
AddressType,
LabelPurpose,
SignRawTransactionOutputParameter
}
import org.bitcoins.rpc.client.v17.BitcoindV17RpcClient
import org.bitcoins.rpc.util.AsyncUtil
import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil

View File

@ -1,4 +1,8 @@
package org.bitcoins.rpc.v17
import org.bitcoins.commons.jsonmodels.bitcoind.{
FinalizedPsbt,
NonFinalizedPsbt
}
import org.bitcoins.core.currency.Bitcoins
import org.bitcoins.core.number.UInt32
import org.bitcoins.core.protocol.script.ScriptSignature
@ -7,9 +11,7 @@ import org.bitcoins.core.protocol.transaction.{
TransactionInput,
TransactionOutPoint
}
import org.bitcoins.rpc.client.common.RpcOpts.AddressType
import org.bitcoins.rpc.client.v17.BitcoindV17RpcClient
import org.bitcoins.rpc.jsonmodels.{FinalizedPsbt, NonFinalizedPsbt}
import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil
import org.bitcoins.testkit.util.BitcoindRpcTest

View File

@ -1,8 +1,8 @@
package org.bitcoins.rpc.v18
import org.bitcoins.chain.models.BlockHeaderDbHelper
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.AddNodeArgument
import org.bitcoins.core.protocol.blockchain.RegTestNetChainParams
import org.bitcoins.rpc.client.common.BitcoindVersion
import org.bitcoins.rpc.client.common.RpcOpts.AddNodeArgument
import org.bitcoins.rpc.client.v18.BitcoindV18RpcClient
import org.bitcoins.testkit.chain.BlockHeaderHelper
import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil

View File

@ -1,7 +1,7 @@
package org.bitcoins.rpc.v19
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.WalletFlag
import org.bitcoins.core.gcs.{BlockFilter, FilterType}
import org.bitcoins.rpc.client.common.BitcoindVersion
import org.bitcoins.rpc.client.common.RpcOpts.WalletFlag
import org.bitcoins.rpc.client.v19.BitcoindV19RpcClient
import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil
import org.bitcoins.testkit.util.BitcoindRpcTest

View File

@ -1,9 +1,9 @@
package org.bitcoins.rpc.client.common
import org.bitcoins.commons.jsonmodels.bitcoind._
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.core.crypto.{DoubleSha256Digest, DoubleSha256DigestBE}
import org.bitcoins.core.protocol.blockchain.{Block, BlockHeader}
import org.bitcoins.rpc.jsonmodels._
import org.bitcoins.rpc.serializers.JsonSerializers._
import play.api.libs.json.{JsBoolean, JsNumber, JsString}
import scala.concurrent.Future

View File

@ -12,9 +12,8 @@ import org.bitcoins.core.config.{MainNet, NetworkParameters, RegTest, TestNet3}
import org.bitcoins.core.crypto.ECPrivateKey
import org.bitcoins.core.util.{BitcoinSLogger, FutureUtil, StartStop}
import org.bitcoins.rpc.config.BitcoindInstance
import org.bitcoins.rpc.serializers.JsonSerializers._
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.rpc.util.AsyncUtil
import play.api.libs.json._
import scala.concurrent._
import scala.concurrent.duration.DurationInt
@ -26,8 +25,10 @@ import org.bitcoins.rpc.config.BitcoindAuthCredentials.CookieBased
import org.bitcoins.rpc.config.BitcoindAuthCredentials.PasswordBased
import java.nio.file.Path
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts
import org.bitcoins.rpc.config.BitcoindAuthCredentials
import org.bitcoins.rpc.BitcoindException
import play.api.libs.json._
/**
* This is the base trait for Bitcoin Core

View File

@ -1,11 +1,11 @@
package org.bitcoins.rpc.client.common
import org.bitcoins.rpc.jsonmodels.{
import org.bitcoins.commons.jsonmodels.bitcoind.{
DeriveAddressesResult,
GetDescriptorInfoResult
}
import org.bitcoins.commons.serializers.JsonSerializers._
import play.api.libs.json.{JsString, Json}
import org.bitcoins.rpc.serializers.JsonSerializers._
import scala.concurrent.Future

View File

@ -1,18 +1,10 @@
package org.bitcoins.rpc.client.common
import org.bitcoins.commons.jsonmodels.bitcoind._
import org.bitcoins.commons.serializers.JsonReaders._
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.core.crypto.{DoubleSha256Digest, DoubleSha256DigestBE}
import org.bitcoins.rpc.client.common.BitcoindVersion._
import org.bitcoins.rpc.jsonmodels.{
GetMemPoolEntryResult,
GetMemPoolEntryResultPostV19,
GetMemPoolEntryResultPreV19,
GetMemPoolInfoResult,
GetMemPoolResult,
GetMemPoolResultPostV19,
GetMemPoolResultPreV19
}
import org.bitcoins.rpc.serializers.JsonReaders._
import org.bitcoins.rpc.serializers.JsonSerializers._
import play.api.libs.json.{JsBoolean, JsString}
import scala.concurrent.Future

View File

@ -1,11 +1,15 @@
package org.bitcoins.rpc.client.common
import org.bitcoins.commons.jsonmodels.bitcoind.{
GetBlockTemplateResult,
GetMiningInfoResult,
RpcOpts
}
import org.bitcoins.commons.serializers.JsonReaders._
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.core.crypto.{DoubleSha256Digest, DoubleSha256DigestBE}
import org.bitcoins.core.currency.Satoshis
import org.bitcoins.core.protocol.BitcoinAddress
import org.bitcoins.rpc.jsonmodels.{GetBlockTemplateResult, GetMiningInfoResult}
import org.bitcoins.rpc.serializers.JsonReaders._
import org.bitcoins.rpc.serializers.JsonSerializers._
import play.api.libs.json.{JsNumber, JsString, Json}
import scala.concurrent.Future

View File

@ -1,11 +1,11 @@
package org.bitcoins.rpc.client.common
import org.bitcoins.commons.jsonmodels.bitcoind.MultiSigResult
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.AddressType
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.commons.serializers.JsonWriters._
import org.bitcoins.core.crypto.ECPublicKey
import org.bitcoins.core.protocol.P2PKHAddress
import org.bitcoins.rpc.client.common.RpcOpts.AddressType
import org.bitcoins.rpc.jsonmodels.MultiSigResult
import org.bitcoins.rpc.serializers.JsonSerializers._
import org.bitcoins.rpc.serializers.JsonWriters._
import play.api.libs.json.{JsArray, JsNumber, JsString, Json}
import scala.concurrent.Future

View File

@ -1,9 +1,9 @@
package org.bitcoins.rpc.client.common
import org.bitcoins.commons.jsonmodels.bitcoind.GetMemoryInfoResult
import org.bitcoins.core.number.UInt32
import org.bitcoins.rpc.jsonmodels.GetMemoryInfoResult
import org.bitcoins.rpc.serializers.JsonReaders
import org.bitcoins.rpc.serializers.JsonSerializers._
import org.bitcoins.commons.serializers.JsonReaders
import org.bitcoins.commons.serializers.JsonSerializers._
import play.api.libs.json._
import scala.concurrent.Future

View File

@ -2,10 +2,13 @@ package org.bitcoins.rpc.client.common
import java.net.URI
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.{
AddNodeArgument,
SetBanCommand
}
import org.bitcoins.commons.jsonmodels.bitcoind._
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.core.protocol.blockchain.Block
import org.bitcoins.rpc.client.common.RpcOpts.{AddNodeArgument, SetBanCommand}
import org.bitcoins.rpc.jsonmodels._
import org.bitcoins.rpc.serializers.JsonSerializers._
import play.api.libs.json.{JsBoolean, JsNumber, JsString}
import scala.concurrent.Future

View File

@ -1,7 +1,7 @@
package org.bitcoins.rpc.client.common
import org.bitcoins.rpc.jsonmodels.AnalyzePsbtResult
import org.bitcoins.rpc.serializers.JsonSerializers._
import org.bitcoins.commons.jsonmodels.bitcoind.AnalyzePsbtResult
import org.bitcoins.commons.serializers.JsonSerializers._
import play.api.libs.json.{JsString, Json}
import scala.concurrent.Future

View File

@ -1,17 +1,18 @@
package org.bitcoins.rpc.client.common
import org.bitcoins.commons.jsonmodels.bitcoind.{
FundRawTransactionResult,
GetRawTransactionResult,
RpcOpts,
RpcTransaction
}
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.commons.serializers.JsonWriters._
import org.bitcoins.core.crypto.DoubleSha256DigestBE
import org.bitcoins.core.currency.Bitcoins
import org.bitcoins.core.protocol.BitcoinAddress
import org.bitcoins.core.protocol.transaction.{Transaction, TransactionInput}
import org.bitcoins.rpc.client.common.BitcoindVersion._
import org.bitcoins.rpc.jsonmodels.{
FundRawTransactionResult,
GetRawTransactionResult,
RpcTransaction
}
import org.bitcoins.rpc.serializers.JsonSerializers._
import org.bitcoins.rpc.serializers.JsonWriters._
import play.api.libs.json._
import scala.concurrent.Future

View File

@ -1,12 +1,15 @@
package org.bitcoins.rpc.client.common
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.{
AddressType,
FeeEstimationMode
}
import org.bitcoins.commons.jsonmodels.bitcoind._
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.core.crypto.{DoubleSha256Digest, DoubleSha256DigestBE}
import org.bitcoins.core.currency.{Bitcoins, CurrencyUnit, Satoshis}
import org.bitcoins.core.protocol.BitcoinAddress
import org.bitcoins.core.protocol.blockchain.MerkleBlock
import org.bitcoins.rpc.client.common.RpcOpts.{AddressType, FeeEstimationMode}
import org.bitcoins.rpc.jsonmodels._
import org.bitcoins.rpc.serializers.JsonSerializers._
import play.api.libs.json._
import scala.concurrent.Future

View File

@ -1,10 +1,10 @@
package org.bitcoins.rpc.client.common
import org.bitcoins.commons.jsonmodels.bitcoind.{RpcOpts, UnspentOutput}
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.core.protocol.BitcoinAddress
import org.bitcoins.core.protocol.transaction.TransactionOutPoint
import org.bitcoins.rpc.jsonmodels.UnspentOutput
import org.bitcoins.rpc.serializers.JsonSerializers._
import play.api.libs.json.{JsBoolean, JsNumber, Json}
import play.api.libs.json._
import scala.concurrent.Future

View File

@ -1,13 +1,13 @@
package org.bitcoins.rpc.client.common
import org.bitcoins.core.protocol.BitcoinAddress
import org.bitcoins.core.protocol.script.ScriptPubKey
import org.bitcoins.rpc.jsonmodels.{
import org.bitcoins.commons.jsonmodels.bitcoind.{
DecodeScriptResult,
ValidateAddressResult,
ValidateAddressResultImpl
}
import org.bitcoins.rpc.serializers.JsonSerializers._
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.core.protocol.BitcoinAddress
import org.bitcoins.core.protocol.script.ScriptPubKey
import play.api.libs.json.{JsString, Json}
import scala.concurrent.Future

View File

@ -1,5 +1,6 @@
package org.bitcoins.rpc.client.common
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.AddressType
import org.bitcoins.core.crypto.{
DoubleSha256Digest,
DoubleSha256DigestBE,
@ -11,9 +12,9 @@ import org.bitcoins.core.protocol.BitcoinAddress
import org.bitcoins.core.protocol.blockchain.MerkleBlock
import org.bitcoins.core.protocol.transaction.Transaction
import org.bitcoins.rpc.client.common.BitcoindVersion._
import org.bitcoins.rpc.client.common.RpcOpts.AddressType
import org.bitcoins.rpc.jsonmodels._
import org.bitcoins.rpc.serializers.JsonSerializers._
import org.bitcoins.commons.jsonmodels.bitcoind._
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.commons.serializers.JsonWriters._
import play.api.libs.json._
import scala.concurrent.Future

View File

@ -1,18 +1,17 @@
package org.bitcoins.rpc.client.v16
import akka.actor.ActorSystem
import org.bitcoins.commons.jsonmodels.bitcoind.{
RpcOpts,
SignRawTransactionResult
}
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.commons.serializers.JsonWriters._
import org.bitcoins.core.crypto.ECPrivateKey
import org.bitcoins.core.protocol.transaction.Transaction
import org.bitcoins.core.script.crypto.HashType
import org.bitcoins.rpc.client.common.{
BitcoindRpcClient,
BitcoindVersion,
RpcOpts
}
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
import org.bitcoins.rpc.config.BitcoindInstance
import org.bitcoins.rpc.jsonmodels.SignRawTransactionResult
import org.bitcoins.rpc.serializers.JsonSerializers._
import org.bitcoins.rpc.serializers.JsonWriters._
import play.api.libs.json._
import scala.concurrent.Future

View File

@ -1,11 +1,11 @@
package org.bitcoins.rpc.client.v16
import org.bitcoins.commons.jsonmodels.bitcoind.ReceivedAccount
import org.bitcoins.commons.serializers.JsonReaders._
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.core.currency.Bitcoins
import org.bitcoins.core.protocol.BitcoinAddress
import org.bitcoins.rpc.client.common.Client
import org.bitcoins.rpc.jsonmodels.ReceivedAccount
import org.bitcoins.rpc.serializers.JsonReaders._
import org.bitcoins.rpc.serializers.JsonSerializers._
import play.api.libs.json.{JsBoolean, JsNumber, JsString}
import scala.concurrent.Future

View File

@ -1,16 +1,14 @@
package org.bitcoins.rpc.client.v16
import org.bitcoins.commons.serializers.JsonReaders._
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.core.crypto.DoubleSha256DigestBE
import org.bitcoins.core.currency.Bitcoins
import org.bitcoins.core.currency.{Bitcoins, CurrencyUnit}
import org.bitcoins.core.protocol.BitcoinAddress
import org.bitcoins.rpc.client.common.Client
import org.bitcoins.rpc.serializers.JsonReaders._
import org.bitcoins.rpc.serializers.JsonSerializers._
import play.api.libs.json.{JsNumber, JsString}
import play.api.libs.json.{JsNumber, JsString, Json}
import scala.concurrent.Future
import org.bitcoins.core.currency.CurrencyUnit
import play.api.libs.json.Json
/**
* RPC calls related to transaction sending

View File

@ -1,22 +1,19 @@
package org.bitcoins.rpc.client.v17
import akka.actor.ActorSystem
import org.bitcoins.core.crypto.ECPrivateKey
import org.bitcoins.core.protocol.transaction.Transaction
import org.bitcoins.core.script.crypto.HashType
import org.bitcoins.rpc.client.common.{
BitcoindRpcClient,
BitcoindVersion,
RpcOpts
}
import org.bitcoins.rpc.config.BitcoindInstance
import org.bitcoins.rpc.jsonmodels.{
import org.bitcoins.commons.jsonmodels.bitcoind.{
RpcOpts,
SignRawTransactionResult,
TestMempoolAcceptResult
}
import org.bitcoins.rpc.serializers.JsonSerializers._
import org.bitcoins.rpc.serializers.JsonWriters._
import play.api.libs.json.{JsArray, JsBoolean, JsString, Json}
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.commons.serializers.JsonWriters._
import org.bitcoins.core.crypto.ECPrivateKey
import org.bitcoins.core.protocol.transaction.Transaction
import org.bitcoins.core.script.crypto.HashType
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
import org.bitcoins.rpc.config.BitcoindInstance
import play.api.libs.json._
import scala.concurrent.Future
import scala.util.Try

View File

@ -1,11 +1,11 @@
package org.bitcoins.rpc.client.v17
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.LabelPurpose
import org.bitcoins.commons.jsonmodels.bitcoind.{LabelResult, ReceivedLabel}
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.core.currency.Bitcoins
import org.bitcoins.core.protocol.BitcoinAddress
import org.bitcoins.rpc.client.common.Client
import org.bitcoins.rpc.client.common.RpcOpts.LabelPurpose
import org.bitcoins.rpc.jsonmodels.{LabelResult, ReceivedLabel}
import org.bitcoins.rpc.serializers.JsonSerializers._
import play.api.libs.json.{JsBoolean, JsNumber, JsString}
import scala.concurrent.Future

View File

@ -1,31 +1,25 @@
package org.bitcoins.rpc.client.v18
import akka.actor.ActorSystem
import org.bitcoins.commons.jsonmodels.bitcoind.{
RpcOpts,
SignRawTransactionResult
}
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.commons.serializers.JsonWriters._
import org.bitcoins.core.crypto.ECPrivateKey
import org.bitcoins.core.protocol.transaction.Transaction
import org.bitcoins.core.script.crypto.HashType
import org.bitcoins.rpc.client.common.{
BitcoindRpcClient,
BitcoindVersion,
DescriptorRpc,
RpcOpts
}
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
import org.bitcoins.rpc.client.common.{
BitcoindRpcClient,
BitcoindVersion,
PsbtRpc,
RpcOpts
PsbtRpc
}
import org.bitcoins.rpc.config.BitcoindInstance
import scala.util.Try
import org.bitcoins.core.protocol.transaction.Transaction
import org.bitcoins.core.crypto.ECPrivateKey
import org.bitcoins.core.script.crypto.HashType
import org.bitcoins.rpc.jsonmodels.SignRawTransactionResult
import play.api.libs.json.Json
import play.api.libs.json.JsString
import play.api.libs.json._
import scala.concurrent.Future
import org.bitcoins.rpc.serializers.JsonSerializers._
import org.bitcoins.rpc.serializers.JsonWriters._
import scala.util.Try
/**
* Class for creating a BitcoindV18 instance that can access RPCs

View File

@ -1,12 +1,12 @@
package org.bitcoins.rpc.client.v18
import org.bitcoins.core.protocol.blockchain.BlockHeader
import org.bitcoins.rpc.client.common.Client
import org.bitcoins.rpc.jsonmodels.{
import org.bitcoins.commons.jsonmodels.bitcoind.{
GetNodeAddressesResult,
GetRpcInfoResult,
ListWalletDirResult
}
import org.bitcoins.rpc.serializers.JsonSerializers._
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.core.protocol.blockchain.BlockHeader
import org.bitcoins.rpc.client.common.Client
import play.api.libs.json.{JsString, Json}
import scala.concurrent.Future

View File

@ -1,27 +1,26 @@
package org.bitcoins.rpc.client.v19
import akka.actor.ActorSystem
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.WalletFlag
import org.bitcoins.commons.jsonmodels.bitcoind.{
GetBalancesResult,
RpcOpts,
SetWalletFlagResult,
SignRawTransactionResult
}
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.commons.serializers.JsonWriters._
import org.bitcoins.core.crypto.ECPrivateKey
import org.bitcoins.core.protocol.transaction.Transaction
import org.bitcoins.core.script.crypto.HashType
import org.bitcoins.rpc.client.common.RpcOpts.WalletFlag
import org.bitcoins.rpc.client.common.{
BitcoindRpcClient,
BitcoindVersion,
DescriptorRpc,
PsbtRpc,
RpcOpts
PsbtRpc
}
import org.bitcoins.rpc.config.BitcoindInstance
import org.bitcoins.rpc.jsonmodels.{
GetBalancesResult,
SetWalletFlagResult,
SignRawTransactionResult
}
import play.api.libs.json.Json
import play.api.libs.json.JsString
import org.bitcoins.rpc.serializers.JsonSerializers._
import org.bitcoins.rpc.serializers.JsonWriters._
import play.api.libs.json._
import scala.concurrent.Future
import scala.util.Try

View File

@ -1,10 +1,10 @@
package org.bitcoins.rpc.client.v19
import org.bitcoins.commons.jsonmodels.bitcoind.GetBlockFilterResult
import org.bitcoins.commons.serializers.JsonReaders.DoubleSha256DigestBEReads
import org.bitcoins.core.crypto.DoubleSha256DigestBE
import org.bitcoins.core.gcs.{BlockFilter, FilterType}
import org.bitcoins.rpc.client.common.Client
import org.bitcoins.rpc.jsonmodels.GetBlockFilterResult
import org.bitcoins.rpc.serializers.JsonReaders.DoubleSha256DigestBEReads
import play.api.libs.json._
import scala.concurrent.Future

View File

@ -30,7 +30,12 @@ lazy val benchSettings: Seq[Def.SettingsDefinition] = {
import Projects._
lazy val core = project in file("core")
lazy val bitcoindRpc = project in file("bitcoind-rpc")
lazy val bitcoindRpc = project
.in(file("bitcoind-rpc"))
.settings(CommonSettings.prodSettings: _*)
.dependsOn(
appCommons
)
lazy val eclairRpc = project in file("eclair-rpc")
// quoting the val name this way makes it appear as
@ -57,7 +62,6 @@ lazy val `bitcoin-s` = project
keyManagerTest,
node,
nodeTest,
picklers,
wallet,
walletTest,
appServer,
@ -201,11 +205,18 @@ lazy val coreTest = project
testkit
)
lazy val appCommons = project
.in(file("app-commons"))
.settings(CommonSettings.prodSettings: _*)
.dependsOn(
core % testAndCompile
)
lazy val appServer = project
.in(file("app/server"))
.settings(CommonSettings.prodSettings: _*)
.dependsOn(
picklers,
appCommons,
node,
chain,
wallet,
@ -221,18 +232,11 @@ lazy val appServerTest = project
testkit
)
// internal picklers used by server
// and CLI
lazy val picklers = project
.in(file("app/picklers"))
.settings(CommonSettings.prodSettings: _*)
.dependsOn(core % testAndCompile)
lazy val cli = project
.in(file("app/cli"))
.settings(CommonSettings.prodSettings: _*)
.dependsOn(
picklers
appCommons
)
lazy val cliTest = project

View File

@ -51,7 +51,7 @@ class ChainHandlerTest extends ChainUnitTest {
val arrStr = source.getLines.next
source.close()
import org.bitcoins.rpc.serializers.JsonReaders.BlockHeaderReads
import org.bitcoins.commons.serializers.JsonReaders.BlockHeaderReads
val headersResult: Vector[BlockHeader] =
Json.parse(arrStr).validate[Vector[BlockHeader]].get
@ -82,7 +82,7 @@ class ChainHandlerTest extends ChainUnitTest {
val arrStr = source.getLines.next
source.close()
import org.bitcoins.rpc.serializers.JsonReaders.BlockHeaderReads
import org.bitcoins.commons.serializers.JsonReaders.BlockHeaderReads
val headersResult = Json.parse(arrStr).validate[Vector[BlockHeader]]
if (headersResult.isError) {
fail(headersResult.toString)

View File

@ -3,6 +3,15 @@ package org.bitcoins.eclair.rpc
import java.nio.file.Files
import java.time.Instant
import org.bitcoins.commons.jsonmodels.eclair.{
ChannelResult,
ChannelUpdate,
IncomingPaymentStatus,
InvoiceResult,
OpenChannelInfo,
OutgoingPaymentStatus,
WebSocketEvent
}
import org.bitcoins.core.currency.{CurrencyUnit, CurrencyUnits, Satoshis}
import org.bitcoins.core.number.UInt64
import org.bitcoins.core.protocol.BitcoinAddress

View File

@ -3,6 +3,25 @@ package org.bitcoins.eclair.rpc.api
import java.net.InetSocketAddress
import java.time.Instant
import org.bitcoins.commons.jsonmodels.eclair.{
AuditResult,
ChannelDesc,
ChannelInfo,
ChannelResult,
ChannelStats,
ChannelUpdate,
GetInfoResult,
IncomingPayment,
InvoiceResult,
NetworkFeesResult,
NodeInfo,
OutgoingPayment,
PaymentId,
PeerInfo,
SendToRouteResult,
UsableBalancesResult,
WebSocketEvent
}
import org.bitcoins.core.crypto.Sha256Digest
import org.bitcoins.core.currency.{CurrencyUnit, Satoshis}
import org.bitcoins.core.protocol.ln.channel.{ChannelId, FundedChannelId}

View File

@ -16,6 +16,8 @@ import akka.http.scaladsl.model.ws.{Message, TextMessage, WebSocketRequest}
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Flow, Sink, Source}
import akka.util.ByteString
import org.bitcoins.commons.jsonmodels.eclair._
import org.bitcoins.commons.serializers.JsonReaders._
import org.bitcoins.core.crypto.Sha256Digest
import org.bitcoins.core.currency.{CurrencyUnit, Satoshis}
import org.bitcoins.core.protocol.ln.channel.{ChannelId, FundedChannelId}
@ -33,8 +35,7 @@ import org.bitcoins.core.util.{BitcoinSUtil, FutureUtil, StartStop}
import org.bitcoins.core.wallet.fee.SatoshisPerByte
import org.bitcoins.eclair.rpc.api._
import org.bitcoins.eclair.rpc.config.EclairInstance
import org.bitcoins.eclair.rpc.network.{NodeUri, PeerState}
import org.bitcoins.rpc.serializers.JsonReaders._
import org.bitcoins.eclair.rpc.network.NodeUri
import org.bitcoins.rpc.util.AsyncUtil
import org.slf4j.LoggerFactory
import play.api.libs.json._
@ -52,7 +53,6 @@ class EclairRpcClient(val instance: EclairInstance, binary: Option[File] = None)
implicit system: ActorSystem)
extends EclairApi
with StartStop[EclairRpcClient] {
import JsonReaders._
implicit val m = ActorMaterializer.create(system)
private val logger = LoggerFactory.getLogger(this.getClass)

View File

@ -71,10 +71,10 @@ object Deps {
val scalaFx = "org.scalafx" %% "scalafx" % V.scalaFxV withSources () withJavadoc ()
lazy val osName = System.getProperty("os.name") match {
case n if n.startsWith("Linux") => "linux"
case n if n.startsWith("Mac") => "mac"
case n if n.startsWith("Linux") => "linux"
case n if n.startsWith("Mac") => "mac"
case n if n.startsWith("Windows") => "win"
case _ => throw new Exception("Unknown platform!")
case _ => throw new Exception("Unknown platform!")
}
// Not sure if all of these are needed, some might be possible to remove
lazy val javaFxBase = "org.openjfx" % s"javafx-base" % V.javaFxV classifier osName withSources () withJavadoc ()
@ -84,7 +84,13 @@ object Deps {
lazy val javaFxMedia = "org.openjfx" % s"javafx-media" % V.javaFxV classifier osName withSources () withJavadoc ()
lazy val javaFxSwing = "org.openjfx" % s"javafx-swing" % V.javaFxV classifier osName withSources () withJavadoc ()
lazy val javaFxWeb = "org.openjfx" % s"javafx-web" % V.javaFxV classifier osName withSources () withJavadoc ()
lazy val javaFxDeps = List(javaFxBase, javaFxControls, javaFxFxml, javaFxGraphics, javaFxMedia, javaFxSwing, javaFxWeb)
lazy val javaFxDeps = List(javaFxBase,
javaFxControls,
javaFxFxml,
javaFxGraphics,
javaFxMedia,
javaFxSwing,
javaFxWeb)
val playJson = "com.typesafe.play" %% "play-json" % V.playv withSources () withJavadoc ()
val typesafeConfig = "com.typesafe" % "config" % V.typesafeConfigV withSources () withJavadoc ()
@ -122,7 +128,7 @@ object Deps {
val scalacheck = "org.scalacheck" %% "scalacheck" % V.scalacheck withSources () withJavadoc ()
val scalaTest = "org.scalatest" %% "scalatest" % V.scalaTest withSources () withJavadoc ()
val scalaTestPlus = "org.scalatestplus" %% "scalacheck-1-14" % V.scalaTestPlus withSources() withJavadoc()
val scalaTestPlus = "org.scalatestplus" %% "scalacheck-1-14" % V.scalaTestPlus withSources () withJavadoc ()
}
object Test {
@ -147,6 +153,13 @@ object Deps {
val chainTest = List()
def appCommons(scalaVersion: String) = List(
if (scalaVersion.startsWith("2.11")) Compile.oldMicroPickle
else Compile.newMicroPickle,
Compile.playJson,
Compile.slf4j
)
val core = List(
Compile.bouncycastle,
Compile.scodec,
@ -177,8 +190,6 @@ object Deps {
val bitcoindRpc = List(
Compile.akkaHttp,
Compile.akkaStream,
Compile.playJson,
Compile.slf4j,
Compile.typesafeConfig
)
@ -203,7 +214,6 @@ object Deps {
Compile.logback,
Compile.sqlite,
Compile.slickHikari,
Test.scalaTest
)
@ -221,11 +231,6 @@ object Deps {
val gui = List(Compile.scalaFx) ++ Compile.javaFxDeps
def picklers(scalaVersion: String) = List(
if (scalaVersion.startsWith("2.11")) Compile.oldMicroPickle
else Compile.newMicroPickle
)
def server(scalaVersion: String) = List(
if (scalaVersion.startsWith("2.11")) Compile.oldMicroPickle
else Compile.newMicroPickle,
@ -272,7 +277,7 @@ object Deps {
def keyManager(scalaVersion: String) = List(
if (scalaVersion.startsWith("2.11")) Compile.oldMicroJson
else Compile.newMicroJson,
else Compile.newMicroJson
)
val keyManagerTest = List(

View File

@ -348,7 +348,7 @@ object ChainUnitTest extends ChainVerificationLogger {
val arrStr = source.getLines.next
source.close()
import org.bitcoins.rpc.serializers.JsonReaders.BlockHeaderReads
import org.bitcoins.commons.serializers.JsonReaders.BlockHeaderReads
val headersResult = Json.parse(arrStr).validate[Vector[BlockHeader]]
headersResult match {

View File

@ -10,7 +10,7 @@ import org.bitcoins.core.protocol.blockchain.{Block, BlockHeader}
import org.bitcoins.core.util.{BitcoinSLogger, FutureUtil}
import org.bitcoins.rpc.client.common.BitcoindRpcClient
import org.bitcoins.rpc.client.v19.BitcoindV19RpcClient
import org.bitcoins.rpc.jsonmodels.GetBlockFilterResult
import org.bitcoins.commons.jsonmodels.bitcoind.GetBlockFilterResult
import org.bitcoins.wallet.Wallet
import scala.concurrent.{ExecutionContext, Future}

View File

@ -6,6 +6,12 @@ import java.nio.file.Files
import akka.actor.ActorSystem
import com.typesafe.config.{Config, ConfigFactory}
import org.bitcoins.commons.jsonmodels.eclair.{
IncomingPaymentStatus,
OutgoingPayment,
OutgoingPaymentStatus,
PaymentId
}
import org.bitcoins.core.compat.JavaConverters._
import org.bitcoins.core.config.RegTest
import org.bitcoins.core.crypto.Sha256Digest

View File

@ -6,6 +6,13 @@ import java.nio.file.{Files, Path, Paths}
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.AddNodeArgument
import org.bitcoins.commons.jsonmodels.bitcoind.{
GetBlockWithTransactionsResult,
GetTransactionResult,
RpcOpts,
SignRawTransactionResult
}
import org.bitcoins.core.compat.JavaConverters._
import org.bitcoins.core.config.RegTest
import org.bitcoins.core.crypto.{
@ -31,12 +38,7 @@ import org.bitcoins.rpc.client.common.BitcoindVersion.{
V18,
_
}
import org.bitcoins.rpc.client.common.RpcOpts.AddNodeArgument
import org.bitcoins.rpc.client.common.{
BitcoindRpcClient,
BitcoindVersion,
RpcOpts
}
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
import org.bitcoins.rpc.client.v16.BitcoindV16RpcClient
import org.bitcoins.rpc.client.v17.BitcoindV17RpcClient
import org.bitcoins.rpc.client.v18.BitcoindV18RpcClient
@ -47,11 +49,6 @@ import org.bitcoins.rpc.config.{
BitcoindInstance,
ZmqConfig
}
import org.bitcoins.rpc.jsonmodels.{
GetBlockWithTransactionsResult,
GetTransactionResult,
SignRawTransactionResult
}
import org.bitcoins.rpc.util.{AsyncUtil, RpcUtil}
import org.bitcoins.testkit.util.{FileUtil, TestkitBinaries}
import org.bitcoins.util.ListUtil

View File

@ -1,7 +1,7 @@
package org.bitcoins.wallet
import com.typesafe.config.{Config, ConfigFactory}
import org.bitcoins.rpc.serializers.JsonSerializers._
import org.bitcoins.commons.serializers.JsonSerializers._
import org.bitcoins.core.crypto.{ExtPublicKey, MnemonicCode}
import org.bitcoins.core.hd._
import org.bitcoins.core.protocol.BitcoinAddress