mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-19 01:40:55 +01:00
Remove support for 23.x of bitcoind (#5538)
* Remove support for 23.x of bitcoind * Remove duplicate test * Fix compile * Move unit bech32m unit test earlier in WalletRpcTest * Make wallet name unique in WalletRpcTest
This commit is contained in:
parent
7b3463229f
commit
f7adb6264e
@ -12,7 +12,11 @@ import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.protocol.script._
|
||||
import org.bitcoins.core.protocol.script.descriptor.P2WPKHDescriptor
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.protocol.{Bech32Address, BitcoinAddress}
|
||||
import org.bitcoins.core.protocol.{
|
||||
Bech32Address,
|
||||
Bech32mAddress,
|
||||
BitcoinAddress
|
||||
}
|
||||
import org.bitcoins.core.psbt.PSBT
|
||||
import org.bitcoins.core.wallet.fee.SatoshisPerByte
|
||||
import org.bitcoins.core.wallet.signer.BitcoinSigner
|
||||
@ -328,6 +332,15 @@ class WalletRpcTest extends BitcoindFixturesCachedPairNewest {
|
||||
}
|
||||
}
|
||||
|
||||
it should "generate a bech32m address" in { nodePair =>
|
||||
val client = nodePair.node1
|
||||
for {
|
||||
address <- client.getNewAddress(addressType = AddressType.Bech32m)
|
||||
} yield {
|
||||
assert(address.isInstanceOf[Bech32mAddress])
|
||||
}
|
||||
}
|
||||
|
||||
it should "be able to list transactions by receiving addresses" in {
|
||||
nodePair: FixtureParam =>
|
||||
val client = nodePair.node1
|
||||
@ -659,6 +672,16 @@ class WalletRpcTest extends BitcoindFixturesCachedPairNewest {
|
||||
}
|
||||
}
|
||||
|
||||
it should "return a list of wallets" in { nodePair =>
|
||||
val client = nodePair.node1
|
||||
for {
|
||||
_ <- client.createWallet(s"Suredbits-${System.currentTimeMillis()}")
|
||||
list <- client.listWalletDir()
|
||||
} yield {
|
||||
assert(list.wallets.exists(_.name.contains("Suredbits")))
|
||||
}
|
||||
}
|
||||
|
||||
def startClient(client: BitcoindRpcClient): Future[Unit] = {
|
||||
BitcoindRpcTestUtil.startServers(Vector(client))
|
||||
}
|
||||
|
@ -1,112 +0,0 @@
|
||||
package org.bitcoins.rpc.v23
|
||||
|
||||
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.AddressType
|
||||
import org.bitcoins.commons.jsonmodels.bitcoind.{
|
||||
AddressInfoResultPostV18,
|
||||
AddressInfoResultPostV21,
|
||||
AddressInfoResultPreV18
|
||||
}
|
||||
import org.bitcoins.core.api.chain.db.BlockHeaderDbHelper
|
||||
import org.bitcoins.core.protocol.Bech32mAddress
|
||||
import org.bitcoins.core.protocol.blockchain.RegTestNetChainParams
|
||||
import org.bitcoins.core.protocol.script.descriptor.Descriptor
|
||||
import org.bitcoins.rpc.client.common.BitcoindVersion
|
||||
import org.bitcoins.rpc.client.v23.BitcoindV23RpcClient
|
||||
import org.bitcoins.testkit.chain.BlockHeaderHelper
|
||||
import org.bitcoins.testkit.rpc.BitcoindFixturesFundedCachedV23
|
||||
|
||||
class BitcoindV23RpcClientTest extends BitcoindFixturesFundedCachedV23 {
|
||||
|
||||
behavior of "BitcoindV23RpcClient"
|
||||
|
||||
it should "be able to start a V23 bitcoind instance" in {
|
||||
client: BitcoindV23RpcClient =>
|
||||
for {
|
||||
v <- client.version
|
||||
} yield assert(v == BitcoindVersion.V23)
|
||||
}
|
||||
|
||||
it should "be able to get network info" in {
|
||||
freshClient: BitcoindV23RpcClient =>
|
||||
for {
|
||||
info <- freshClient.getNetworkInfo
|
||||
} yield {
|
||||
assert(info.networkactive)
|
||||
assert(info.localrelay)
|
||||
}
|
||||
}
|
||||
|
||||
it should "generate a bech32m address" in { client: BitcoindV23RpcClient =>
|
||||
for {
|
||||
address <- client.getNewAddress(addressType = AddressType.Bech32m)
|
||||
} yield {
|
||||
assert(address.isInstanceOf[Bech32mAddress])
|
||||
}
|
||||
}
|
||||
|
||||
it should "have extra address information" in { client =>
|
||||
for {
|
||||
address <- client.getNewAddress
|
||||
info <- client.getAddressInfo(address)
|
||||
} yield {
|
||||
info match {
|
||||
case _: AddressInfoResultPreV18 | _: AddressInfoResultPostV18 =>
|
||||
fail("Was expecting AddressInfoResultPostV21")
|
||||
case postV21Info: AddressInfoResultPostV21 =>
|
||||
assert(postV21Info.address == address)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it should "return active rpc commands" in { client =>
|
||||
val generatedF =
|
||||
client.getNewAddress.flatMap(addr => client.generateToAddress(100, addr))
|
||||
val rpcinfoF =
|
||||
generatedF.flatMap(_ => client.getRpcInfo())
|
||||
|
||||
rpcinfoF.map { result =>
|
||||
assert(result.active_commands.length == 1)
|
||||
}
|
||||
}
|
||||
|
||||
it should "return a list of wallets" in { client =>
|
||||
for {
|
||||
_ <- client.createWallet("Suredbits")
|
||||
list <- client.listWalletDir()
|
||||
} yield {
|
||||
assert(list.wallets.exists(_.name.contains("Suredbits")))
|
||||
}
|
||||
}
|
||||
|
||||
it should "analyze a descriptor" in { client =>
|
||||
val descriptor =
|
||||
Descriptor.fromString(
|
||||
"pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)#gn28ywm7"
|
||||
)
|
||||
val descriptorF = client.getDescriptorInfo(descriptor)
|
||||
|
||||
descriptorF.map { result =>
|
||||
assert(result.descriptor == descriptor)
|
||||
assert(result.isrange.==(false))
|
||||
assert(result.issolvable.==(true))
|
||||
assert(result.hasprivatekeys.==(false))
|
||||
}
|
||||
}
|
||||
|
||||
it should "get node address given a null parameter" in { client =>
|
||||
val nodeF = client.getNodeAddresses()
|
||||
|
||||
nodeF.map { result =>
|
||||
assert(result.isEmpty)
|
||||
}
|
||||
}
|
||||
|
||||
it should "successfully submit a header" in { client =>
|
||||
val genesisHeader = RegTestNetChainParams.genesisBlock.blockHeader
|
||||
val genesisHeaderDb =
|
||||
BlockHeaderDbHelper.fromBlockHeader(height = 1, BigInt(0), genesisHeader)
|
||||
val nextHeader = BlockHeaderHelper.buildNextHeader(genesisHeaderDb)
|
||||
client.submitHeader(nextHeader.blockHeader).map(_ => succeed)
|
||||
}
|
||||
|
||||
}
|
@ -5,18 +5,12 @@ import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.{
|
||||
AddressType,
|
||||
WalletFlag
|
||||
}
|
||||
import org.bitcoins.commons.jsonmodels.bitcoind.{
|
||||
AddressInfoResultPostV18,
|
||||
AddressInfoResultPostV21,
|
||||
AddressInfoResultPreV18,
|
||||
DescriptorsResult,
|
||||
GetBlockChainInfoResultPostV23
|
||||
}
|
||||
import org.bitcoins.commons.jsonmodels.bitcoind._
|
||||
import org.bitcoins.core.api.chain.db.BlockHeaderDbHelper
|
||||
import org.bitcoins.core.config.RegTest
|
||||
import org.bitcoins.core.currency._
|
||||
import org.bitcoins.core.gcs.{BlockFilter, FilterType}
|
||||
import org.bitcoins.core.protocol.{Bech32mAddress, BitcoinAddress}
|
||||
import org.bitcoins.core.protocol.BitcoinAddress
|
||||
import org.bitcoins.core.protocol.blockchain.RegTestNetChainParams
|
||||
import org.bitcoins.core.protocol.script.descriptor.Descriptor
|
||||
import org.bitcoins.core.psbt.PSBT
|
||||
@ -80,14 +74,6 @@ class BitcoindV24RpcClientTest extends BitcoindFixturesFundedCachedV24 {
|
||||
}
|
||||
}
|
||||
|
||||
it should "generate a bech32m address" in { client: BitcoindV24RpcClient =>
|
||||
for {
|
||||
address <- client.getNewAddress(addressType = AddressType.Bech32m)
|
||||
} yield {
|
||||
assert(address.isInstanceOf[Bech32mAddress])
|
||||
}
|
||||
}
|
||||
|
||||
it should "have extra address information" in { client =>
|
||||
for {
|
||||
address <- client.getNewAddress
|
||||
@ -404,5 +390,4 @@ class BitcoindV24RpcClientTest extends BitcoindFixturesFundedCachedV24 {
|
||||
info1 <- client.getTxOut(block.tx.head.txid, 0)
|
||||
} yield assert(info1.coinbase)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,12 +23,12 @@ TaskKeys.downloadBitcoind := {
|
||||
}
|
||||
|
||||
val versions =
|
||||
List("24.2", "23.2")
|
||||
List("24.2")
|
||||
|
||||
logger.debug(
|
||||
s"(Maybe) downloading Bitcoin Core binaries for versions: ${versions.mkString(",")}")
|
||||
|
||||
val arm64MacVersions = List("24.2", "23.2")
|
||||
val arm64MacVersions = List("24.2")
|
||||
def getPlatformAndSuffix(version: String): (String, String) = {
|
||||
if (Properties.isLinux) ("x86_64-linux-gnu", "tar.gz")
|
||||
else if (Properties.isMac) {
|
||||
@ -96,18 +96,13 @@ TaskKeys.downloadBitcoind := {
|
||||
if (Properties.isLinux)
|
||||
Map(
|
||||
"24.2" -> "7540d6e34c311e355af2fd76e5eee853b76c291978d6b5ebb555c7877e9de38d",
|
||||
"23.2" -> "853b9b0a50800a5b355df7a39dbdd6d7a2339f765e2d31a36d14bd705e7dbce1"
|
||||
)
|
||||
else if (Properties.isMac)
|
||||
Map(
|
||||
"24.2" -> (if (System.getProperty("os.arch") == "aarch64")
|
||||
"ae6f5f0cb4079005c32695711ef78b26a26c4c547ceb593b3626059626530a5d"
|
||||
else
|
||||
"b1b21455c339b2daf0998bfad17d0741d967c3c81db040bb5f73234168526d29"),
|
||||
"23.2" -> (if (System.getProperty("os.arch") == "aarch64")
|
||||
"33f8680f820327d5f9e64c02e476d03a5b2e5bd403e1b1cb0a82bd7ec2a8dc5e"
|
||||
else
|
||||
"f56f2e21718c3ef13b962775f1e9985eed962ae6237684deebf6b59f799a912f")
|
||||
"b1b21455c339b2daf0998bfad17d0741d967c3c81db040bb5f73234168526d29")
|
||||
)
|
||||
else if (Properties.isWin)
|
||||
Map(
|
||||
|
@ -16,7 +16,6 @@ import org.bitcoins.core.wallet.fee.FeeUnit
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, StringFactory}
|
||||
import org.bitcoins.rpc.client.v18.V18AssortedRpc
|
||||
import org.bitcoins.rpc.client.v20.{V20AssortedRpc, V20MultisigRpc}
|
||||
import org.bitcoins.rpc.client.v23.BitcoindV23RpcClient
|
||||
import org.bitcoins.rpc.client.v24.BitcoindV24RpcClient
|
||||
import org.bitcoins.rpc.config._
|
||||
|
||||
@ -342,7 +341,6 @@ object BitcoindRpcClient {
|
||||
system: ActorSystem
|
||||
): BitcoindRpcClient = {
|
||||
val bitcoind = version match {
|
||||
case BitcoindVersion.V23 => BitcoindV23RpcClient.withActorSystem(instance)
|
||||
case BitcoindVersion.V24 => BitcoindV24RpcClient.withActorSystem(instance)
|
||||
case BitcoindVersion.Unknown =>
|
||||
sys.error(
|
||||
@ -371,14 +369,10 @@ object BitcoindVersion
|
||||
val newest: BitcoindVersion = V24
|
||||
|
||||
val standard: Vector[BitcoindVersion] =
|
||||
Vector(V23, V24)
|
||||
Vector(V24)
|
||||
|
||||
val known: Vector[BitcoindVersion] = standard
|
||||
|
||||
case object V23 extends BitcoindVersion {
|
||||
override def toString: String = "v23"
|
||||
}
|
||||
|
||||
case object V24 extends BitcoindVersion {
|
||||
override def toString: String = "v24"
|
||||
}
|
||||
@ -401,7 +395,6 @@ object BitcoindVersion
|
||||
def fromNetworkVersion(int: Int): BitcoindVersion = {
|
||||
// need to translate the int 210100 (as an example) to a BitcoindVersion
|
||||
int.toString.substring(0, 2) match {
|
||||
case "23" => V23
|
||||
case "24" => V24
|
||||
case _ =>
|
||||
logger.warn(
|
||||
|
@ -39,7 +39,7 @@ trait BlockchainRpc extends ChainApi { self: Client =>
|
||||
}
|
||||
|
||||
def getBlockChainInfo: Future[GetBlockChainInfoResult] = {
|
||||
self.version.flatMap { case V23 | V24 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[GetBlockChainInfoResultPostV23]("getblockchaininfo")
|
||||
}
|
||||
}
|
||||
@ -92,7 +92,7 @@ trait BlockchainRpc extends ChainApi { self: Client =>
|
||||
headerHash: DoubleSha256DigestBE
|
||||
): Future[GetBlockWithTransactionsResultV22] = {
|
||||
val isVerboseJsonObject = JsNumber(2)
|
||||
self.version.flatMap { case V23 | V24 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[GetBlockWithTransactionsResultV22](
|
||||
"getblock",
|
||||
List(JsString(headerHash.hex), isVerboseJsonObject)
|
||||
|
@ -35,7 +35,7 @@ trait MempoolRpc { self: Client =>
|
||||
txid: DoubleSha256DigestBE
|
||||
): Future[Map[DoubleSha256DigestBE, GetMemPoolResult]] = {
|
||||
|
||||
self.version.flatMap { case V24 | V23 | V24 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[Map[DoubleSha256DigestBE, GetMemPoolResultPostV23]](
|
||||
"getmempoolancestors",
|
||||
List(JsString(txid.hex), JsBoolean(true))
|
||||
@ -67,7 +67,7 @@ trait MempoolRpc { self: Client =>
|
||||
def getMemPoolDescendantsVerbose(
|
||||
txid: DoubleSha256DigestBE
|
||||
): Future[Map[DoubleSha256DigestBE, GetMemPoolResult]] = {
|
||||
self.version.flatMap { case V24 | V23 | V24 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[Map[DoubleSha256DigestBE, GetMemPoolResultPostV23]](
|
||||
"getmempooldescendants",
|
||||
List(JsString(txid.hex), JsBoolean(true))
|
||||
@ -85,7 +85,7 @@ trait MempoolRpc { self: Client =>
|
||||
txid: DoubleSha256DigestBE
|
||||
): Future[GetMemPoolEntryResult] = {
|
||||
|
||||
self.version.flatMap { case V24 | V23 | V24 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[GetMemPoolEntryResultPostV23](
|
||||
"getmempoolentry",
|
||||
List(JsString(txid.hex))
|
||||
@ -130,7 +130,7 @@ trait MempoolRpc { self: Client =>
|
||||
def getRawMemPoolWithTransactions
|
||||
: Future[Map[DoubleSha256DigestBE, GetMemPoolResult]] = {
|
||||
|
||||
self.version.flatMap { case V24 | V23 | V24 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[Map[DoubleSha256DigestBE, GetMemPoolResultPostV23]](
|
||||
"getrawmempool",
|
||||
List(JsBoolean(true))
|
||||
|
@ -43,7 +43,7 @@ trait MultisigRpc { self: Client =>
|
||||
JsString(account)
|
||||
) ++ addressType.map(Json.toJson(_)).toList
|
||||
|
||||
self.version.flatMap { case V24 | V23 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[MultiSigResultPostV20](
|
||||
"addmultisigaddress",
|
||||
params,
|
||||
@ -86,7 +86,7 @@ trait MultisigRpc { self: Client =>
|
||||
addressType: AddressType,
|
||||
walletNameOpt: Option[String] = None
|
||||
): Future[MultiSigResult] = {
|
||||
self.version.flatMap { case V24 | V23 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[MultiSigResultPostV20](
|
||||
"createmultisig",
|
||||
List(
|
||||
|
@ -64,13 +64,13 @@ trait P2PRpc { self: Client =>
|
||||
}
|
||||
|
||||
def getPeerInfo: Future[Vector[Peer]] = {
|
||||
self.version.flatMap { case V24 | V23 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[Vector[PeerPostV21]]("getpeerinfo")
|
||||
}
|
||||
}
|
||||
|
||||
def listBanned: Future[Vector[NodeBan]] = {
|
||||
self.version.flatMap { case V23 | V24 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[Vector[NodeBanPostV22]]("listbanned")
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ trait PsbtRpc {
|
||||
}
|
||||
|
||||
def decodePsbt(psbt: PSBT): Future[DecodePsbtResult] = {
|
||||
self.version.flatMap { case V23 | V24 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[DecodePsbtResultV22]("decodepsbt", List(Json.toJson(psbt)))
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ trait RawTransactionRpc { self: Client =>
|
||||
|
||||
def decodeRawTransaction(transaction: Transaction): Future[RpcTransaction] = {
|
||||
|
||||
self.version.flatMap { case V23 | V24 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[RpcTransactionV22](
|
||||
"decoderawtransaction",
|
||||
List(JsString(transaction.hex))
|
||||
@ -102,7 +102,7 @@ trait RawTransactionRpc { self: Client =>
|
||||
case None => Nil
|
||||
}
|
||||
val params = List(JsString(txid.hex), JsBoolean(true)) ++ lastParam
|
||||
self.version.flatMap { case V23 | V24 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[GetRawTransactionResultV22]("getrawtransaction", params)
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import org.bitcoins.commons.serializers.JsonSerializers._
|
||||
import org.bitcoins.core.currency.Satoshis
|
||||
import org.bitcoins.core.protocol.blockchain.MerkleBlock
|
||||
import org.bitcoins.crypto.{DoubleSha256Digest, DoubleSha256DigestBE}
|
||||
import org.bitcoins.rpc.client.common.BitcoindVersion.{Unknown, V23, V24}
|
||||
import org.bitcoins.rpc.client.common.BitcoindVersion.{Unknown, V24}
|
||||
import play.api.libs.json._
|
||||
|
||||
import scala.concurrent.Future
|
||||
@ -90,7 +90,7 @@ trait TransactionRpc { self: Client =>
|
||||
vout: Long,
|
||||
includeMemPool: Boolean = true
|
||||
): Future[GetTxOutResult] = {
|
||||
self.version.flatMap { case V23 | V24 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[GetTxOutResultV22](
|
||||
"gettxout",
|
||||
List(JsString(txid.hex), JsNumber(vout), JsBoolean(includeMemPool))
|
||||
@ -104,7 +104,7 @@ trait TransactionRpc { self: Client =>
|
||||
includeMemPool: Boolean = true
|
||||
): Future[Option[GetTxOutResult]] = {
|
||||
self.version
|
||||
.flatMap { case V23 | V24 | Unknown =>
|
||||
.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[GetTxOutResultV22](
|
||||
"gettxout",
|
||||
List(JsString(txid.hex), JsNumber(vout), JsBoolean(includeMemPool))
|
||||
|
@ -24,7 +24,7 @@ trait UtilRpc { self: Client =>
|
||||
}
|
||||
|
||||
def decodeScript(script: ScriptPubKey): Future[DecodeScriptResult] = {
|
||||
self.version.flatMap { case V23 | V24 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[DecodeScriptResultV22](
|
||||
"decodescript",
|
||||
List(Json.toJson(script))
|
||||
@ -34,13 +34,13 @@ trait UtilRpc { self: Client =>
|
||||
}
|
||||
|
||||
def getIndexInfo: Future[Map[String, IndexInfoResult]] = {
|
||||
version.flatMap { case V24 | V23 | Unknown =>
|
||||
version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[Map[String, IndexInfoResult]]("getindexinfo")
|
||||
}
|
||||
}
|
||||
|
||||
def getIndexInfo(indexName: String): Future[IndexInfoResult] = {
|
||||
version.flatMap { case V24 | V23 | Unknown =>
|
||||
version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[Map[String, IndexInfoResult]](
|
||||
"getindexinfo",
|
||||
List(JsString(indexName))
|
||||
|
@ -149,13 +149,11 @@ trait WalletRpc { self: Client =>
|
||||
private def getWalletInfo(
|
||||
walletName: Option[String]
|
||||
): Future[GetWalletInfoResult] = {
|
||||
self.version.flatMap {
|
||||
case BitcoindVersion.V23 | BitcoindVersion.V24 |
|
||||
BitcoindVersion.Unknown =>
|
||||
bitcoindCall[GetWalletInfoResultPostV22](
|
||||
"getwalletinfo",
|
||||
uriExtensionOpt = walletName.map(walletExtension)
|
||||
)
|
||||
self.version.flatMap { case BitcoindVersion.V24 | BitcoindVersion.Unknown =>
|
||||
bitcoindCall[GetWalletInfoResultPostV22](
|
||||
"getwalletinfo",
|
||||
uriExtensionOpt = walletName.map(walletExtension)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -376,7 +374,7 @@ trait WalletRpc { self: Client =>
|
||||
descriptors: Boolean = false
|
||||
): Future[CreateWalletResult] =
|
||||
self.version.flatMap {
|
||||
case V24 | V23 =>
|
||||
case V24 =>
|
||||
bitcoindCall[CreateWalletResult](
|
||||
"createwallet",
|
||||
List(
|
||||
@ -412,7 +410,7 @@ trait WalletRpc { self: Client =>
|
||||
List(JsString(address.value)),
|
||||
uriExtensionOpt = walletNameOpt.map(walletExtension)
|
||||
)
|
||||
case V24 | V23 | Unknown =>
|
||||
case V24 | Unknown =>
|
||||
bitcoindCall[AddressInfoResultPostV21](
|
||||
"getaddressinfo",
|
||||
List(JsString(address.value)),
|
||||
|
@ -40,7 +40,7 @@ trait V20MultisigRpc extends MultisigRpc { self: Client =>
|
||||
JsString(account)
|
||||
) ++ addressType.map(Json.toJson(_)).toList
|
||||
|
||||
self.version.flatMap { case V23 | V24 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[MultiSigResultPostV20]("addmultisigaddress", params)
|
||||
}
|
||||
}
|
||||
@ -79,7 +79,7 @@ trait V20MultisigRpc extends MultisigRpc { self: Client =>
|
||||
addressType: AddressType,
|
||||
walletNameOpt: Option[String] = None
|
||||
): Future[MultiSigResultPostV20] = {
|
||||
self.version.flatMap { case V23 | V24 | Unknown =>
|
||||
self.version.flatMap { case V24 | Unknown =>
|
||||
bitcoindCall[MultiSigResultPostV20](
|
||||
"createmultisig",
|
||||
List(
|
||||
|
@ -1,50 +0,0 @@
|
||||
package org.bitcoins.rpc.client.v23
|
||||
|
||||
import org.apache.pekko.actor.ActorSystem
|
||||
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
|
||||
import org.bitcoins.rpc.config.BitcoindInstance
|
||||
|
||||
import scala.concurrent.Future
|
||||
import scala.util.Try
|
||||
|
||||
/** Class for creating a BitcoindV23 instance that can access RPCs
|
||||
*/
|
||||
class BitcoindV23RpcClient(override val instance: BitcoindInstance)(implicit
|
||||
actorSystem: ActorSystem
|
||||
) extends BitcoindRpcClient(instance) {
|
||||
|
||||
override lazy val version: Future[BitcoindVersion] =
|
||||
Future.successful(BitcoindVersion.V23)
|
||||
}
|
||||
|
||||
object BitcoindV23RpcClient {
|
||||
|
||||
/** Creates an RPC client from the given instance.
|
||||
*
|
||||
* Behind the scenes, we create an actor system for you. You can use
|
||||
* `withActorSystem` if you want to manually specify an actor system for the
|
||||
* RPC client.
|
||||
*/
|
||||
def apply(instance: BitcoindInstance): BitcoindV23RpcClient = {
|
||||
implicit val system: ActorSystem =
|
||||
ActorSystem.create(BitcoindRpcClient.ActorSystemName)
|
||||
withActorSystem(instance)
|
||||
}
|
||||
|
||||
/** Creates an RPC client from the given instance, together with the given
|
||||
* actor system. This is for advanced users, where you need fine grained
|
||||
* control over the RPC client.
|
||||
*/
|
||||
def withActorSystem(instance: BitcoindInstance)(implicit
|
||||
system: ActorSystem
|
||||
): BitcoindV23RpcClient =
|
||||
new BitcoindV23RpcClient(instance)(system)
|
||||
|
||||
def fromUnknownVersion(
|
||||
rpcClient: BitcoindRpcClient
|
||||
): Try[BitcoindV23RpcClient] =
|
||||
Try {
|
||||
new BitcoindV23RpcClient(rpcClient.instance)(rpcClient.system)
|
||||
}
|
||||
|
||||
}
|
@ -59,9 +59,6 @@ sealed trait BitcoindInstanceLocal extends BitcoindInstance {
|
||||
.last
|
||||
|
||||
foundVersion match {
|
||||
case _: String
|
||||
if foundVersion.startsWith(BitcoindVersion.V23.toString) =>
|
||||
BitcoindVersion.V23
|
||||
case _: String
|
||||
if foundVersion.startsWith(BitcoindVersion.V24.toString) =>
|
||||
BitcoindVersion.V24
|
||||
|
@ -1090,5 +1090,5 @@ object EclairRpcClient {
|
||||
* @see
|
||||
* https://github.com/ACINQ/eclair/releases/tag/v0.8.0
|
||||
*/
|
||||
val bitcoindV: BitcoindVersion = BitcoindVersion.V23
|
||||
val bitcoindV: BitcoindVersion = BitcoindVersion.V24
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.bitcoins.testkit.rpc
|
||||
|
||||
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
|
||||
import org.bitcoins.rpc.client.v23.BitcoindV23RpcClient
|
||||
import org.bitcoins.rpc.client.v24.BitcoindV24RpcClient
|
||||
import org.bitcoins.rpc.util.{NodePair, NodeTriple}
|
||||
import org.bitcoins.testkit.EmbeddedPg
|
||||
@ -48,42 +47,6 @@ trait BitcoindFixturesFundedCached extends BitcoindFixtures {
|
||||
}
|
||||
}
|
||||
|
||||
/** Test trait that caches a [[BitcoindV23RpcClient]] that is funded and
|
||||
* available to use with fixtures
|
||||
*/
|
||||
trait BitcoindFixturesFundedCachedV23
|
||||
extends BitcoinSAsyncFixtureTest
|
||||
with BitcoindFixturesFundedCached
|
||||
with CachedBitcoindV23 {
|
||||
override type FixtureParam = BitcoindV23RpcClient
|
||||
|
||||
override def withFixture(test: OneArgAsyncTest): FutureOutcome = {
|
||||
val f: Future[Outcome] = for {
|
||||
bitcoind <- cachedBitcoindWithFundsF
|
||||
futOutcome = withV23FundedBitcoindCached(test, bitcoind)
|
||||
fut <- futOutcome.toFuture
|
||||
} yield fut
|
||||
new FutureOutcome(f)
|
||||
}
|
||||
|
||||
def withV23FundedBitcoindCached(
|
||||
test: OneArgAsyncTest,
|
||||
bitcoind: BitcoindV23RpcClient
|
||||
): FutureOutcome = {
|
||||
makeDependentFixture[BitcoindV23RpcClient](
|
||||
() => Future.successful(bitcoind),
|
||||
{ case _ =>
|
||||
Future.unit // don't want to destroy anything since it is cached
|
||||
}
|
||||
)(test)
|
||||
}
|
||||
|
||||
override def afterAll(): Unit = {
|
||||
super[CachedBitcoindV23].afterAll()
|
||||
super[BitcoinSAsyncFixtureTest].afterAll()
|
||||
}
|
||||
}
|
||||
|
||||
trait BitcoindFixturesFundedCachedV24
|
||||
extends BitcoinSAsyncFixtureTest
|
||||
with BitcoindFixturesFundedCached
|
||||
|
@ -30,7 +30,6 @@ import org.bitcoins.crypto.{
|
||||
import org.bitcoins.rpc.BitcoindException
|
||||
import org.bitcoins.rpc.client.common.BitcoindVersion._
|
||||
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
|
||||
import org.bitcoins.rpc.client.v23.BitcoindV23RpcClient
|
||||
import org.bitcoins.rpc.client.v24.BitcoindV24RpcClient
|
||||
import org.bitcoins.rpc.config._
|
||||
import org.bitcoins.rpc.util.RpcUtil
|
||||
@ -177,7 +176,7 @@ trait BitcoindRpcTestUtil extends BitcoinSLogger {
|
||||
version match {
|
||||
// default to newest version
|
||||
case Unknown => getBinary(BitcoindVersion.newest, binaryDirectory)
|
||||
case known @ (V23 | V24) =>
|
||||
case known @ (V24) =>
|
||||
val fileList = Files
|
||||
.list(binaryDirectory)
|
||||
.iterator()
|
||||
@ -241,22 +240,6 @@ trait BitcoindRpcTestUtil extends BitcoinSLogger {
|
||||
BitcoindInstanceLocal.fromConfig(conf, binary)
|
||||
}
|
||||
|
||||
def v23Instance(
|
||||
port: Int = RpcUtil.randomPort,
|
||||
rpcPort: Int = RpcUtil.randomPort,
|
||||
zmqConfig: ZmqConfig = RpcUtil.zmqConfig,
|
||||
pruneMode: Boolean = false,
|
||||
binaryDirectory: Path = BitcoindRpcTestClient.sbtBinaryDirectory
|
||||
)(implicit system: ActorSystem): BitcoindInstanceLocal =
|
||||
instance(
|
||||
port = port,
|
||||
rpcPort = rpcPort,
|
||||
zmqConfig = zmqConfig,
|
||||
pruneMode = pruneMode,
|
||||
versionOpt = Some(BitcoindVersion.V23),
|
||||
binaryDirectory = binaryDirectory
|
||||
)
|
||||
|
||||
def v24Instance(
|
||||
port: Int = RpcUtil.randomPort,
|
||||
rpcPort: Int = RpcUtil.randomPort,
|
||||
@ -283,14 +266,6 @@ trait BitcoindRpcTestUtil extends BitcoinSLogger {
|
||||
binaryDirectory: Path = BitcoindRpcTestClient.sbtBinaryDirectory
|
||||
)(implicit system: ActorSystem): BitcoindInstanceLocal = {
|
||||
bitcoindVersion match {
|
||||
case BitcoindVersion.V23 =>
|
||||
BitcoindRpcTestUtil.v23Instance(
|
||||
port,
|
||||
rpcPort,
|
||||
zmqConfig,
|
||||
pruneMode,
|
||||
binaryDirectory = binaryDirectory
|
||||
)
|
||||
case BitcoindVersion.V24 =>
|
||||
BitcoindRpcTestUtil.v24Instance(
|
||||
port,
|
||||
@ -316,7 +291,7 @@ trait BitcoindRpcTestUtil extends BitcoinSLogger {
|
||||
descriptors = version match {
|
||||
case Unknown =>
|
||||
false
|
||||
case V23 | V24 => true
|
||||
case V24 => true
|
||||
}
|
||||
_ <- res.createWallet("", descriptors = descriptors)
|
||||
} yield res
|
||||
@ -641,10 +616,6 @@ trait BitcoindRpcTestUtil extends BitcoinSLogger {
|
||||
val rpc = version match {
|
||||
case BitcoindVersion.Unknown =>
|
||||
BitcoindRpcClient.withActorSystem(BitcoindRpcTestUtil.instance())
|
||||
case BitcoindVersion.V23 =>
|
||||
BitcoindV23RpcClient.withActorSystem(
|
||||
BitcoindRpcTestUtil.v23Instance()
|
||||
)
|
||||
case BitcoindVersion.V24 =>
|
||||
BitcoindV24RpcClient.withActorSystem(
|
||||
BitcoindRpcTestUtil.v24Instance()
|
||||
@ -672,18 +643,6 @@ trait BitcoindRpcTestUtil extends BitcoinSLogger {
|
||||
} yield clients
|
||||
}
|
||||
|
||||
private def createNodePairInternal[T <: BitcoindRpcClient](
|
||||
version: BitcoindVersion,
|
||||
clientAccum: RpcClientAccum
|
||||
)(implicit system: ActorSystem): Future[(T, T)] = {
|
||||
import system.dispatcher
|
||||
|
||||
createNodePairInternal[T](version).map { pair =>
|
||||
clientAccum.++=(Vector(pair._1, pair._2))
|
||||
pair
|
||||
}
|
||||
}
|
||||
|
||||
private def createNodePairInternal[T <: BitcoindRpcClient](
|
||||
version: BitcoindVersion
|
||||
)(implicit system: ActorSystem): Future[(T, T)] = {
|
||||
@ -737,15 +696,6 @@ trait BitcoindRpcTestUtil extends BitcoinSLogger {
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns a pair of
|
||||
* [[org.bitcoins.rpc.client.v23.BitcoindV23RpcClient BitcoindV23RpcClient]]
|
||||
* that are connected with some blocks in the chain
|
||||
*/
|
||||
def createNodePairV23(clientAccum: RpcClientAccum)(implicit
|
||||
system: ActorSystem
|
||||
): Future[(BitcoindV23RpcClient, BitcoindV23RpcClient)] =
|
||||
createNodePairInternal(BitcoindVersion.V23, clientAccum)
|
||||
|
||||
/** Returns a triple of
|
||||
* [[org.bitcoins.rpc.client.common.BitcoindRpcClient BitcoindRpcClient]]
|
||||
* that are connected with some blocks in the chain
|
||||
@ -854,8 +804,6 @@ trait BitcoindRpcTestUtil extends BitcoinSLogger {
|
||||
signer match {
|
||||
case v24: BitcoindV24RpcClient =>
|
||||
v24.signRawTransactionWithWallet(transaction, utxoDeps)
|
||||
case v23: BitcoindV23RpcClient =>
|
||||
v23.signRawTransactionWithWallet(transaction, utxoDeps)
|
||||
case unknown: BitcoindRpcClient =>
|
||||
sys.error(
|
||||
s"Cannot sign tx with unknown version of bitcoind, got=$unknown"
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.bitcoins.testkit.rpc
|
||||
|
||||
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
|
||||
import org.bitcoins.rpc.client.v23.BitcoindV23RpcClient
|
||||
import org.bitcoins.rpc.client.v24.BitcoindV24RpcClient
|
||||
import org.bitcoins.rpc.util.{NodePair, NodeTriple}
|
||||
import org.bitcoins.testkit.fixtures.BitcoinSFixture
|
||||
@ -129,18 +128,6 @@ trait CachedBitcoindBlockFilterRpcNewest
|
||||
}
|
||||
}
|
||||
|
||||
trait CachedBitcoindV23 extends CachedBitcoindFunded[BitcoindV23RpcClient] {
|
||||
_: BitcoinSPekkoAsyncTest =>
|
||||
|
||||
override protected lazy val cachedBitcoindWithFundsF
|
||||
: Future[BitcoindV23RpcClient] = {
|
||||
val _ = isBitcoindUsed.set(true)
|
||||
BitcoinSFixture
|
||||
.createBitcoindWithFunds(Some(BitcoindVersion.V23))
|
||||
.map(_.asInstanceOf[BitcoindV23RpcClient])
|
||||
}
|
||||
}
|
||||
|
||||
trait CachedBitcoindV24 extends CachedBitcoindFunded[BitcoindV24RpcClient] {
|
||||
_: BitcoinSPekkoAsyncTest =>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user