mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-03 10:46:42 +01:00
Remove v18 from bitcoind-rpc
(#4845)
* Remove v18 from bitcoind-rpc * Remove v18 from bitcoind downloads * WIP * Fix submitheader RPC test with v23 bitcoind * Have join psbt handle randomizing input & output ordering * Cleanup Co-authored-by: benthecarman <benthecarman@live.com>
This commit is contained in:
parent
63b05e398a
commit
746635a551
22 changed files with 125 additions and 439 deletions
|
@ -1,85 +0,0 @@
|
|||
package org.bitcoins.rpc.v18
|
||||
|
||||
import org.bitcoins.commons.jsonmodels.bitcoind.{
|
||||
AddressInfoResultPostV18,
|
||||
AddressInfoResultPostV21,
|
||||
AddressInfoResultPreV18
|
||||
}
|
||||
import org.bitcoins.core.api.chain.db.BlockHeaderDbHelper
|
||||
import org.bitcoins.core.protocol.blockchain.RegTestNetChainParams
|
||||
import org.bitcoins.rpc.client.common.BitcoindVersion
|
||||
import org.bitcoins.testkit.chain.BlockHeaderHelper
|
||||
import org.bitcoins.testkit.rpc.BitcoindFixturesFundedCachedV18
|
||||
|
||||
class BitcoindV18RpcClientTest extends BitcoindFixturesFundedCachedV18 {
|
||||
|
||||
behavior of "BitcoindV18RpcClient"
|
||||
|
||||
it should "have extra address information" in { client =>
|
||||
for {
|
||||
address <- client.getNewAddress
|
||||
info <- client.getAddressInfo(address)
|
||||
} yield {
|
||||
info match {
|
||||
case _: AddressInfoResultPreV18 | _: AddressInfoResultPostV21 =>
|
||||
fail("Was expecting AddressInfoResultPostV18")
|
||||
case postV18Info: AddressInfoResultPostV18 =>
|
||||
assert(postV18Info.address == address)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it should "be able to start a V18 bitcoind instance" in { client =>
|
||||
for {
|
||||
v <- client.version
|
||||
} yield assert(v == BitcoindVersion.V18)
|
||||
}
|
||||
|
||||
it should "return active rpc commands" in { client =>
|
||||
val generatedF = client.generate(100)
|
||||
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 =
|
||||
"pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)"
|
||||
|
||||
val descriptorF = client.getDescriptorInfo(descriptor)
|
||||
|
||||
descriptorF.map { result =>
|
||||
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)
|
||||
}
|
||||
}
|
|
@ -2,18 +2,18 @@ package org.bitcoins.rpc.v18
|
|||
|
||||
import org.bitcoins.core.currency.Bitcoins
|
||||
import org.bitcoins.core.psbt.PSBT
|
||||
import org.bitcoins.rpc.client.v18.BitcoindV18RpcClient
|
||||
import org.bitcoins.testkit.rpc.BitcoindFixturesFundedCachedV18
|
||||
import org.bitcoins.rpc.client.common.BitcoindRpcClient
|
||||
import org.bitcoins.testkit.rpc.BitcoindFixturesFundedCachedNewest
|
||||
|
||||
/** Tests for PSBT for RPC calls specific to V18 new PSBT calls
|
||||
* @see https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#test-vectors
|
||||
*/
|
||||
class PsbtRpcTest extends BitcoindFixturesFundedCachedV18 {
|
||||
class PsbtRpcTest extends BitcoindFixturesFundedCachedNewest {
|
||||
|
||||
behavior of "PsbtRpc"
|
||||
|
||||
it should "return something when analyzePsbt is called" in {
|
||||
client: BitcoindV18RpcClient =>
|
||||
client: BitcoindRpcClient =>
|
||||
//PSBT with one P2PKH input and one P2SH-P2WPKH input both with non-final scriptSigs. P2SH-P2WPKH input's redeemScript is available. Outputs filled.
|
||||
val psbt =
|
||||
"cHNidP8BAKACAAAAAqsJSaCMWvfEm4IS9Bfi8Vqz9cM9zxU4IagTn4d6W3vkAAAAAAD+////qwlJoIxa98SbghL0F+LxWrP1wz3PFTghqBOfh3pbe+QBAAAAAP7///8CYDvqCwAAAAAZdqkUdopAu9dAy+gdmI5x3ipNXHE5ax2IrI4kAAAAAAAAGXapFG9GILVT+glechue4O/p+gOcykWXiKwAAAAAAAEA3wIAAAABJoFxNx7f8oXpN63upLN7eAAMBWbLs61kZBcTykIXG/YAAAAAakcwRAIgcLIkUSPmv0dNYMW1DAQ9TGkaXSQ18Jo0p2YqncJReQoCIAEynKnazygL3zB0DsA5BCJCLIHLRYOUV663b8Eu3ZWzASECZX0RjTNXuOD0ws1G23s59tnDjZpwq8ubLeXcjb/kzjH+////AtPf9QUAAAAAGXapFNDFmQPFusKGh2DpD9UhpGZap2UgiKwA4fUFAAAAABepFDVF5uM7gyxHBQ8k0+65PJwDlIvHh7MuEwAAAQEgAOH1BQAAAAAXqRQ1RebjO4MsRwUPJNPuuTycA5SLx4cBBBYAFIXRNTfy4mVAWjTbr6nj3aAfuCMIACICAurVlmh8qAYEPtw94RbN8p1eklfBls0FXPaYyNAr8k6ZELSmumcAAACAAAAAgAIAAIAAIgIDlPYr6d8ZlSxVh3aK63aYBhrSxKJciU9H2MFitNchPQUQtKa6ZwAAAIABAACAAgAAgAA="
|
||||
|
@ -25,7 +25,7 @@ class PsbtRpcTest extends BitcoindFixturesFundedCachedV18 {
|
|||
}
|
||||
}
|
||||
it should "analyze a PSBT and return a non-empty result" in {
|
||||
client: BitcoindV18RpcClient =>
|
||||
client: BitcoindRpcClient =>
|
||||
//PSBT with one P2PKH input and one P2SH-P2WPKH input both with non-final scriptSigs. P2SH-P2WPKH input's redeemScript is available. Outputs filled.
|
||||
|
||||
val psbt =
|
||||
|
@ -45,7 +45,7 @@ class PsbtRpcTest extends BitcoindFixturesFundedCachedV18 {
|
|||
assert(result.next.nonEmpty)
|
||||
}
|
||||
}
|
||||
it should "correctly analyze a psbt " in { client: BitcoindV18RpcClient =>
|
||||
it should "correctly analyze a psbt " in { client: BitcoindRpcClient =>
|
||||
val psbt =
|
||||
//PSBT with one P2PKH input and one P2SH-P2WPKH input both with non-final scriptSigs. P2SH-P2WPKH input's redeemScript is available. Outputs filled.
|
||||
"cHNidP8BAKACAAAAAqsJSaCMWvfEm4IS9Bfi8Vqz9cM9zxU4IagTn4d6W3vkAAAAAAD+////qwlJoIxa98SbghL0F+LxWrP1wz3PFTghqBOfh3pbe+QBAAAAAP7///8CYDvqCwAAAAAZdqkUdopAu9dAy+gdmI5x3ipNXHE5ax2IrI4kAAAAAAAAGXapFG9GILVT+glechue4O/p+gOcykWXiKwAAAAAAAEA3wIAAAABJoFxNx7f8oXpN63upLN7eAAMBWbLs61kZBcTykIXG/YAAAAAakcwRAIgcLIkUSPmv0dNYMW1DAQ9TGkaXSQ18Jo0p2YqncJReQoCIAEynKnazygL3zB0DsA5BCJCLIHLRYOUV663b8Eu3ZWzASECZX0RjTNXuOD0ws1G23s59tnDjZpwq8ubLeXcjb/kzjH+////AtPf9QUAAAAAGXapFNDFmQPFusKGh2DpD9UhpGZap2UgiKwA4fUFAAAAABepFDVF5uM7gyxHBQ8k0+65PJwDlIvHh7MuEwAAAQEgAOH1BQAAAAAXqRQ1RebjO4MsRwUPJNPuuTycA5SLx4cBBBYAFIXRNTfy4mVAWjTbr6nj3aAfuCMIACICAurVlmh8qAYEPtw94RbN8p1eklfBls0FXPaYyNAr8k6ZELSmumcAAACAAAAAgAIAAIAAIgIDlPYr6d8ZlSxVh3aK63aYBhrSxKJciU9H2MFitNchPQUQtKa6ZwAAAIABAACAAgAAgAA="
|
||||
|
@ -72,7 +72,7 @@ class PsbtRpcTest extends BitcoindFixturesFundedCachedV18 {
|
|||
|
||||
//Todo: figure out how to implement a test here
|
||||
it should "check to see if the utxoUpdate input has been updated" in {
|
||||
client: BitcoindV18RpcClient =>
|
||||
client: BitcoindRpcClient =>
|
||||
val psbt =
|
||||
PSBT.fromBase64(
|
||||
"cHNidP8BACoCAAAAAAFAQg8AAAAAABepFG6Rty1Vk+fUOR4v9E6R6YXDFkHwhwAAAAAAAA==")
|
||||
|
@ -88,7 +88,7 @@ class PsbtRpcTest extends BitcoindFixturesFundedCachedV18 {
|
|||
* together the resulting PSBT represented as a string is very different so we can't just search for parts of either
|
||||
* PSBT.
|
||||
*/
|
||||
it should "joinpsbts " in { client: BitcoindV18RpcClient =>
|
||||
it should "joinpsbts" in { client: BitcoindRpcClient =>
|
||||
val seqofpsbts = Vector(
|
||||
PSBT.fromBase64(
|
||||
"cHNidP8BAHUCAAAAASaBcTce3/KF6Tet7qSze3gADAVmy7OtZGQXE8pCFxv2AAAAAAD+////AtPf9QUAAAAAGXapFNDFmQPFusKGh2DpD9UhpGZap2UgiKwA4fUFAAAAABepFDVF5uM7gyxHBQ8k0+65PJwDlIvHh7MuEwAAAQD9pQEBAAAAAAECiaPHHqtNIOA3G7ukzGmPopXJRjr6Ljl/hTPMti+VZ+UBAAAAFxYAFL4Y0VKpsBIDna89p95PUzSe7LmF/////4b4qkOnHf8USIk6UwpyN+9rRgi7st0tAXHmOuxqSJC0AQAAABcWABT+Pp7xp0XpdNkCxDVZQ6vLNL1TU/////8CAMLrCwAAAAAZdqkUhc/xCX/Z4Ai7NK9wnGIZeziXikiIrHL++E4sAAAAF6kUM5cluiHv1irHU6m80GfWx6ajnQWHAkcwRAIgJxK+IuAnDzlPVoMR3HyppolwuAJf3TskAinwf4pfOiQCIAGLONfc0xTnNMkna9b7QPZzMlvEuqFEyADS8vAtsnZcASED0uFWdJQbrUqZY3LLh+GFbTZSYG2YVi/jnF6efkE/IQUCSDBFAiEA0SuFLYXc2WHS9fSrZgZU327tzHlMDDPOXMMJ/7X85Y0CIGczio4OFyXBl/saiK9Z9R5E5CVbIBZ8hoQDHAXR8lkqASECI7cr7vCWXRC+B3jv7NYfysb3mk6haTkzgHNEZPhPKrMAAAAAAAAA"),
|
||||
|
@ -101,11 +101,11 @@ class PsbtRpcTest extends BitcoindFixturesFundedCachedV18 {
|
|||
val joinedF = client.joinPsbts(seqofpsbts)
|
||||
|
||||
joinedF.map { result =>
|
||||
assert(
|
||||
result ==
|
||||
//the expected joined version of these 2 psbts
|
||||
PSBT.fromBase64(
|
||||
"cHNidP8BAP0LAQIAAAADJoFxNx7f8oXpN63upLN7eAAMBWbLs61kZBcTykIXG/YAAAAAAP7///+rCUmgjFr3xJuCEvQX4vFas/XDPc8VOCGoE5+Helt75AAAAAAA/v///6sJSaCMWvfEm4IS9Bfi8Vqz9cM9zxU4IagTn4d6W3vkAQAAAAD+////BNPf9QUAAAAAGXapFNDFmQPFusKGh2DpD9UhpGZap2UgiKwA4fUFAAAAABepFDVF5uM7gyxHBQ8k0+65PJwDlIvHh2A76gsAAAAAGXapFHaKQLvXQMvoHZiOcd4qTVxxOWsdiKyOJAAAAAAAABl2qRRvRiC1U/oJXnIbnuDv6foDnMpFl4isAAAAAAABAMwBAAAAAomjxx6rTSDgNxu7pMxpj6KVyUY6+i45f4UzzLYvlWflAQAAABcWABS+GNFSqbASA52vPafeT1M0nuy5hf////+G+KpDpx3/FEiJOlMKcjfva0YIu7LdLQFx5jrsakiQtAEAAAAXFgAU/j6e8adF6XTZAsQ1WUOryzS9U1P/////AgDC6wsAAAAAGXapFIXP8Ql/2eAIuzSvcJxiGXs4l4pIiKxy/vhOLAAAABepFDOXJboh79Yqx1OpvNBn1semo50FhwAAAAAAAQDfAgAAAAEmgXE3Ht/yhek3re6ks3t4AAwFZsuzrWRkFxPKQhcb9gAAAABqRzBEAiBwsiRRI+a/R01gxbUMBD1MaRpdJDXwmjSnZiqdwlF5CgIgATKcqdrPKAvfMHQOwDkEIkIsgctFg5RXrrdvwS7dlbMBIQJlfRGNM1e44PTCzUbbezn22cONmnCry5st5dyNv+TOMf7///8C09/1BQAAAAAZdqkU0MWZA8W6woaHYOkP1SGkZlqnZSCIrADh9QUAAAAAF6kUNUXm4zuDLEcFDyTT7rk8nAOUi8eHsy4TAAABASAA4fUFAAAAABepFDVF5uM7gyxHBQ8k0+65PJwDlIvHhwEEFgAUhdE1N/LiZUBaNNuvqePdoB+4IwgAAAAiAgLq1ZZofKgGBD7cPeEWzfKdXpJXwZbNBVz2mMjQK/JOmRC0prpnAAAAgAAAAIACAACAACICA5T2K+nfGZUsVYd2iut2mAYa0sSiXIlPR9jBYrTXIT0FELSmumcAAACAAQAAgAIAAIAA"))
|
||||
logger.info(s"result=${result.base64}")
|
||||
val allInputs = seqofpsbts.flatMap(_.transaction.inputs).distinct
|
||||
val allOutputs = seqofpsbts.flatMap(_.transaction.outputs).distinct
|
||||
assert(allInputs.forall(i => result.transaction.inputs.contains(i)))
|
||||
assert(allOutputs.forall(i => result.transaction.outputs.contains(i)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
package org.bitcoins.rpc.v23
|
||||
|
||||
import org.bitcoins.commons.jsonmodels.bitcoind.{
|
||||
AddressInfoResultPostV18,
|
||||
AddressInfoResultPostV21,
|
||||
AddressInfoResultPreV18
|
||||
}
|
||||
import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.AddressType
|
||||
import org.bitcoins.core.api.chain.db.BlockHeaderDbHelper
|
||||
import org.bitcoins.core.protocol.Bech32mAddress
|
||||
import org.bitcoins.core.protocol.blockchain.RegTestNetChainParams
|
||||
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 {
|
||||
|
@ -34,4 +42,68 @@ class BitcoindV23RpcClientTest extends BitcoindFixturesFundedCachedV23 {
|
|||
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 =
|
||||
"pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)"
|
||||
|
||||
val descriptorF = client.getDescriptorInfo(descriptor)
|
||||
|
||||
descriptorF.map { result =>
|
||||
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)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ TaskKeys.downloadBitcoind := {
|
|||
}
|
||||
|
||||
val versions =
|
||||
List("23.0", "22.0", "0.21.1", "0.20.1", "0.19.0.1", "0.18.1")
|
||||
List("23.0", "22.0", "0.21.1", "0.20.1", "0.19.0.1")
|
||||
|
||||
logger.debug(
|
||||
s"(Maybe) downloading Bitcoin Core binaries for versions: ${versions.mkString(",")}")
|
||||
|
@ -99,8 +99,7 @@ TaskKeys.downloadBitcoind := {
|
|||
"22.0" -> "59ebd25dd82a51638b7a6bb914586201e67db67b919b2a1ff08925a7936d1b16",
|
||||
"0.21.1" -> "366eb44a7a0aa5bd342deea215ec19a184a11f2ca22220304ebb20b9c8917e2b",
|
||||
"0.20.1" -> "376194f06596ecfa40331167c39bc70c355f960280bd2a645fdbf18f66527397",
|
||||
"0.19.0.1" -> "732cc96ae2e5e25603edf76b8c8af976fe518dd925f7e674710c6c8ee5189204",
|
||||
"0.18.1" -> "600d1db5e751fa85903e935a01a74f5cc57e1e7473c15fd3e17ed21e202cfe5a"
|
||||
"0.19.0.1" -> "732cc96ae2e5e25603edf76b8c8af976fe518dd925f7e674710c6c8ee5189204"
|
||||
)
|
||||
else if (Properties.isMac)
|
||||
Map(
|
||||
|
@ -111,8 +110,7 @@ TaskKeys.downloadBitcoind := {
|
|||
"22.0" -> "2744d199c3343b2d94faffdfb2c94d75a630ba27301a70e47b0ad30a7e0155e9",
|
||||
"0.21.1" -> "1ea5cedb64318e9868a66d3ab65de14516f9ada53143e460d50af428b5aec3c7",
|
||||
"0.20.1" -> "b9024dde373ea7dad707363e07ec7e265383204127539ae0c234bff3a61da0d1",
|
||||
"0.19.0.1" -> "a64e4174e400f3a389abd76f4d6b1853788730013ab1dedc0e64b0a0025a0923",
|
||||
"0.18.1" -> "b7bbcee7a7540f711b171d6981f939ca8482005fde22689bc016596d80548bb1"
|
||||
"0.19.0.1" -> "a64e4174e400f3a389abd76f4d6b1853788730013ab1dedc0e64b0a0025a0923"
|
||||
)
|
||||
else if (Properties.isWin)
|
||||
Map(
|
||||
|
@ -120,8 +118,7 @@ TaskKeys.downloadBitcoind := {
|
|||
"22.0" -> "9485e4b52ed6cebfe474ab4d7d0c1be6d0bb879ba7246a8239326b2230a77eb1",
|
||||
"0.21.1" -> "94c80f90184cdc7e7e75988a55b38384de262336abd80b1b30121c6e965dc74e",
|
||||
"0.20.1" -> "e59fba67afce011d32b5d723a3a0be12da1b8a34f5d7966e504520c48d64716d",
|
||||
"0.19.0.1" -> "7706593de727d893e4b1e750dc296ea682ccee79acdd08bbc81eaacf3b3173cf",
|
||||
"0.18.1" -> "b0f94ab43c068bac9c10a59cb3f1b595817256a00b84f0b724f8504b44e1314f"
|
||||
"0.19.0.1" -> "7706593de727d893e4b1e750dc296ea682ccee79acdd08bbc81eaacf3b3173cf"
|
||||
)
|
||||
else sys.error(s"Unsupported OS: ${Properties.osName}")
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.bitcoins.crypto.{
|
|||
DoubleSha256DigestBE,
|
||||
StringFactory
|
||||
}
|
||||
import org.bitcoins.rpc.client.v18.BitcoindV18RpcClient
|
||||
import org.bitcoins.rpc.client.v19.BitcoindV19RpcClient
|
||||
import org.bitcoins.rpc.client.v20.BitcoindV20RpcClient
|
||||
import org.bitcoins.rpc.client.v21.BitcoindV21RpcClient
|
||||
|
@ -344,7 +343,6 @@ object BitcoindRpcClient {
|
|||
def fromVersion(version: BitcoindVersion, instance: BitcoindInstance)(implicit
|
||||
system: ActorSystem): BitcoindRpcClient = {
|
||||
val bitcoind = version match {
|
||||
case BitcoindVersion.V18 => BitcoindV18RpcClient.withActorSystem(instance)
|
||||
case BitcoindVersion.V19 => BitcoindV19RpcClient.withActorSystem(instance)
|
||||
case BitcoindVersion.V20 => BitcoindV20RpcClient.withActorSystem(instance)
|
||||
case BitcoindVersion.V21 => BitcoindV21RpcClient.withActorSystem(instance)
|
||||
|
@ -373,14 +371,10 @@ object BitcoindVersion extends StringFactory[BitcoindVersion] with Logging {
|
|||
val newest: BitcoindVersion = V23
|
||||
|
||||
val standard: Vector[BitcoindVersion] =
|
||||
Vector(V18, V19, V20, V21, V22, V23)
|
||||
Vector(V19, V20, V21, V22, V23)
|
||||
|
||||
val known: Vector[BitcoindVersion] = standard
|
||||
|
||||
case object V18 extends BitcoindVersion {
|
||||
override def toString: String = "v0.18"
|
||||
}
|
||||
|
||||
case object V19 extends BitcoindVersion {
|
||||
override def toString: String = "v0.19"
|
||||
}
|
||||
|
@ -419,7 +413,6 @@ object BitcoindVersion extends StringFactory[BitcoindVersion] with Logging {
|
|||
def fromNetworkVersion(int: Int): BitcoindVersion = {
|
||||
//need to translate the int 210100 (as an example) to a BitcoindVersion
|
||||
int.toString.substring(0, 2) match {
|
||||
case "18" => V18
|
||||
case "19" => V19
|
||||
case "20" => V20
|
||||
case "21" => V21
|
||||
|
|
|
@ -29,8 +29,6 @@ trait BlockchainRpc { self: Client =>
|
|||
|
||||
def getBlockChainInfo: Future[GetBlockChainInfoResult] = {
|
||||
self.version.flatMap {
|
||||
case V18 =>
|
||||
bitcoindCall[GetBlockChainInfoResultPreV19]("getblockchaininfo")
|
||||
case V22 | V21 | V20 | V19 =>
|
||||
bitcoindCall[GetBlockChainInfoResultPostV19]("getblockchaininfo")
|
||||
case V23 | Unknown =>
|
||||
|
@ -85,7 +83,7 @@ trait BlockchainRpc { self: Client =>
|
|||
"getblock",
|
||||
List(JsString(headerHash.hex), isVerboseJsonObject))
|
||||
|
||||
case V18 | V19 | V20 | V21 =>
|
||||
case V19 | V20 | V21 =>
|
||||
bitcoindCall[GetBlockWithTransactionsResultPreV22](
|
||||
"getblock",
|
||||
List(JsString(headerHash.hex), isVerboseJsonObject))
|
||||
|
|
|
@ -40,10 +40,6 @@ trait MempoolRpc { self: Client =>
|
|||
bitcoindCall[Map[DoubleSha256DigestBE, GetMemPoolResultPostV19]](
|
||||
"getmempoolancestors",
|
||||
List(JsString(txid.hex), JsBoolean(true)))
|
||||
case V18 =>
|
||||
bitcoindCall[Map[DoubleSha256DigestBE, GetMemPoolResultPreV19]](
|
||||
"getmempoolancestors",
|
||||
List(JsString(txid.hex), JsBoolean(true)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,10 +71,6 @@ trait MempoolRpc { self: Client =>
|
|||
bitcoindCall[Map[DoubleSha256DigestBE, GetMemPoolResultPostV19]](
|
||||
"getmempooldescendants",
|
||||
List(JsString(txid.hex), JsBoolean(true)))
|
||||
case V18 =>
|
||||
bitcoindCall[Map[DoubleSha256DigestBE, GetMemPoolResultPreV19]](
|
||||
"getmempooldescendants",
|
||||
List(JsString(txid.hex), JsBoolean(true)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,9 +89,6 @@ trait MempoolRpc { self: Client =>
|
|||
case V22 | V21 | V20 | V19 | Unknown =>
|
||||
bitcoindCall[GetMemPoolEntryResultPostV19]("getmempoolentry",
|
||||
List(JsString(txid.hex)))
|
||||
case V18 =>
|
||||
bitcoindCall[GetMemPoolEntryResultPreV19]("getmempoolentry",
|
||||
List(JsString(txid.hex)))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -144,10 +133,6 @@ trait MempoolRpc { self: Client =>
|
|||
bitcoindCall[Map[DoubleSha256DigestBE, GetMemPoolResultPostV19]](
|
||||
"getrawmempool",
|
||||
List(JsBoolean(true)))
|
||||
case V18 =>
|
||||
bitcoindCall[Map[DoubleSha256DigestBE, GetMemPoolResultPreV19]](
|
||||
"getrawmempool",
|
||||
List(JsBoolean(true)))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ trait MultisigRpc { self: Client =>
|
|||
"addmultisigaddress",
|
||||
params,
|
||||
uriExtensionOpt = walletNameOpt.map(walletExtension))
|
||||
case V18 | V19 =>
|
||||
case V19 =>
|
||||
bitcoindCall[MultiSigResultPreV20]("addmultisigaddress",
|
||||
params,
|
||||
uriExtensionOpt =
|
||||
|
@ -92,7 +92,7 @@ trait MultisigRpc { self: Client =>
|
|||
Json.toJson(addressType)),
|
||||
uriExtensionOpt = walletNameOpt.map(walletExtension)
|
||||
)
|
||||
case V18 | V19 =>
|
||||
case V19 =>
|
||||
bitcoindCall[MultiSigResultPreV20](
|
||||
"createmultisig",
|
||||
List(JsNumber(minSignatures), Json.toJson(keys.map(_.hex))),
|
||||
|
|
|
@ -68,7 +68,7 @@ trait P2PRpc { self: Client =>
|
|||
bitcoindCall[Vector[PeerPostV21]]("getpeerinfo")
|
||||
case V20 =>
|
||||
bitcoindCall[Vector[PeerV20]]("getpeerinfo")
|
||||
case V18 | V19 =>
|
||||
case V19 =>
|
||||
bitcoindCall[Vector[PeerPreV20]]("getpeerinfo")
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ trait P2PRpc { self: Client =>
|
|||
bitcoindCall[Vector[NodeBanPostV22]]("listbanned")
|
||||
case V21 | V20 =>
|
||||
bitcoindCall[Vector[NodeBanPostV20]]("listbanned")
|
||||
case V18 | V19 =>
|
||||
case V19 =>
|
||||
bitcoindCall[Vector[NodeBanPreV20]]("listbanned")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import org.bitcoins.core.protocol.transaction.{Transaction, TransactionInput}
|
|||
import org.bitcoins.core.psbt.PSBT
|
||||
import org.bitcoins.rpc.client.common.BitcoindVersion.{
|
||||
Unknown,
|
||||
V18,
|
||||
V19,
|
||||
V20,
|
||||
V21,
|
||||
|
@ -96,7 +95,7 @@ trait PsbtRpc {
|
|||
self.version.flatMap {
|
||||
case V22 | V23 | Unknown =>
|
||||
bitcoindCall[DecodePsbtResultV22]("decodepsbt", List(Json.toJson(psbt)))
|
||||
case V18 | V19 | V20 | V21 =>
|
||||
case V19 | V20 | V21 =>
|
||||
bitcoindCall[DecodePsbtResultPreV22]("decodepsbt",
|
||||
List(Json.toJson(psbt)))
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ trait RawTransactionRpc { self: Client =>
|
|||
bitcoindCall[RpcTransactionV22]("decoderawtransaction",
|
||||
List(JsString(transaction.hex)))
|
||||
|
||||
case V18 | V19 | V20 | V21 =>
|
||||
case V19 | V20 | V21 =>
|
||||
bitcoindCall[RpcTransactionPreV22]("decoderawtransaction",
|
||||
List(JsString(transaction.hex)))
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ trait RawTransactionRpc { self: Client =>
|
|||
self.version.flatMap {
|
||||
case V22 | V23 | Unknown =>
|
||||
bitcoindCall[GetRawTransactionResultV22]("getrawtransaction", params)
|
||||
case V18 | V19 | V20 | V21 =>
|
||||
case V19 | V20 | V21 =>
|
||||
bitcoindCall[GetRawTransactionResultPreV22]("getrawtransaction", params)
|
||||
}
|
||||
|
||||
|
@ -131,8 +131,6 @@ trait RawTransactionRpc { self: Client =>
|
|||
val feeParameterF = self.version.map {
|
||||
case V23 | V22 | V21 | V20 | V19 | Unknown =>
|
||||
JsNumber(maxfeerate)
|
||||
case V18 =>
|
||||
JsBoolean(maxfeerate == 0)
|
||||
}
|
||||
|
||||
feeParameterF.flatMap { feeParameter =>
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.bitcoins.core.protocol.blockchain.MerkleBlock
|
|||
import org.bitcoins.crypto.{DoubleSha256Digest, DoubleSha256DigestBE}
|
||||
import org.bitcoins.rpc.client.common.BitcoindVersion.{
|
||||
Unknown,
|
||||
V18,
|
||||
V19,
|
||||
V20,
|
||||
V21,
|
||||
|
@ -94,7 +93,7 @@ trait TransactionRpc { self: Client =>
|
|||
"gettxout",
|
||||
List(JsString(txid.hex), JsNumber(vout), JsBoolean(includeMemPool)))
|
||||
|
||||
case V18 | V19 | V20 | V21 =>
|
||||
case V19 | V20 | V21 =>
|
||||
bitcoindCall[GetTxOutResultPreV22](
|
||||
"gettxout",
|
||||
List(JsString(txid.hex), JsNumber(vout), JsBoolean(includeMemPool)))
|
||||
|
@ -112,7 +111,7 @@ trait TransactionRpc { self: Client =>
|
|||
"gettxout",
|
||||
List(JsString(txid.hex), JsNumber(vout), JsBoolean(includeMemPool)))
|
||||
|
||||
case V18 | V19 | V20 | V21 =>
|
||||
case V19 | V20 | V21 =>
|
||||
bitcoindCall[GetTxOutResultPreV22](
|
||||
"gettxout",
|
||||
List(JsString(txid.hex), JsNumber(vout), JsBoolean(includeMemPool)))
|
||||
|
|
|
@ -25,7 +25,7 @@ trait UtilRpc { self: Client =>
|
|||
case V22 | V23 | Unknown =>
|
||||
bitcoindCall[DecodeScriptResultV22]("decodescript",
|
||||
List(Json.toJson(script)))
|
||||
case V18 | V19 | V20 | V21 =>
|
||||
case V19 | V20 | V21 =>
|
||||
bitcoindCall[DecodeScriptResultPreV22]("decodescript",
|
||||
List(Json.toJson(script)))
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ trait UtilRpc { self: Client =>
|
|||
version.flatMap {
|
||||
case V23 | V22 | V21 | Unknown =>
|
||||
bitcoindCall[Map[String, IndexInfoResult]]("getindexinfo")
|
||||
case V18 | V19 | V20 =>
|
||||
case V19 | V20 =>
|
||||
Future.failed(
|
||||
new RuntimeException(
|
||||
s"getIndexInfo is only for version V21+, got $version"))
|
||||
|
@ -49,7 +49,7 @@ trait UtilRpc { self: Client =>
|
|||
bitcoindCall[Map[String, IndexInfoResult]](
|
||||
"getindexinfo",
|
||||
List(JsString(indexName))).map(_.head._2)
|
||||
case V18 | V19 | V20 =>
|
||||
case V19 | V20 =>
|
||||
Future.failed(
|
||||
new RuntimeException(
|
||||
s"getIndexInfo is only for version V21+, got $version"))
|
||||
|
|
|
@ -169,8 +169,7 @@ trait WalletRpc { self: Client =>
|
|||
bitcoindCall[GetWalletInfoResultPostV22](
|
||||
"getwalletinfo",
|
||||
uriExtensionOpt = walletName.map(walletExtension))
|
||||
case BitcoindVersion.V18 | BitcoindVersion.V19 | BitcoindVersion.V20 |
|
||||
BitcoindVersion.V21 =>
|
||||
case BitcoindVersion.V19 | BitcoindVersion.V20 | BitcoindVersion.V21 =>
|
||||
bitcoindCall[GetWalletInfoResultPreV22](
|
||||
"getwalletinfo",
|
||||
uriExtensionOpt = walletName.map(walletExtension))
|
||||
|
@ -316,40 +315,25 @@ trait WalletRpc { self: Client =>
|
|||
walletNameOpt: Option[String] = None
|
||||
): Future[SetWalletFlagResult] = {
|
||||
|
||||
self.version.flatMap {
|
||||
case V23 | V22 | V21 | V20 | V19 | Unknown =>
|
||||
bitcoindCall[SetWalletFlagResult](
|
||||
"setwalletflag",
|
||||
List(JsString(flag.toString), Json.toJson(value)),
|
||||
uriExtensionOpt = walletNameOpt.map(walletExtension))
|
||||
case V18 =>
|
||||
Future.failed(
|
||||
new UnsupportedOperationException(
|
||||
"setwalletflag is not available for versions before 0.19"))
|
||||
self.version.flatMap { case V23 | V22 | V21 | V20 | V19 | Unknown =>
|
||||
bitcoindCall[SetWalletFlagResult](
|
||||
"setwalletflag",
|
||||
List(JsString(flag.toString), Json.toJson(value)),
|
||||
uriExtensionOpt = walletNameOpt.map(walletExtension))
|
||||
}
|
||||
}
|
||||
|
||||
def getBalances: Future[GetBalancesResult] = {
|
||||
self.version.flatMap {
|
||||
case V23 | V22 | V21 | V20 | V19 | Unknown =>
|
||||
bitcoindCall[GetBalancesResult]("getbalances")
|
||||
case V18 =>
|
||||
Future.failed(
|
||||
new UnsupportedOperationException(
|
||||
"getbalances is not available for versions before 0.19"))
|
||||
self.version.flatMap { case V23 | V22 | V21 | V20 | V19 | Unknown =>
|
||||
bitcoindCall[GetBalancesResult]("getbalances")
|
||||
}
|
||||
}
|
||||
|
||||
def getBalances(walletName: String): Future[GetBalancesResult] = {
|
||||
self.version.flatMap {
|
||||
case V23 | V22 | V21 | V20 | V19 | Unknown =>
|
||||
bitcoindCall[GetBalancesResult]("getbalances",
|
||||
uriExtensionOpt =
|
||||
Some(walletExtension(walletName)))
|
||||
case V18 =>
|
||||
Future.failed(
|
||||
new UnsupportedOperationException(
|
||||
"getbalances is not available for versions before 0.19"))
|
||||
self.version.flatMap { case V23 | V22 | V21 | V20 | V19 | Unknown =>
|
||||
bitcoindCall[GetBalancesResult]("getbalances",
|
||||
uriExtensionOpt =
|
||||
Some(walletExtension(walletName)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -436,19 +420,13 @@ trait WalletRpc { self: Client =>
|
|||
JsString(passphrase),
|
||||
JsBoolean(avoidReuse))
|
||||
)
|
||||
case V18 =>
|
||||
require(passphrase.isEmpty,
|
||||
"passphrase should not be set for versions before v19")
|
||||
bitcoindCall[CreateWalletResult](
|
||||
"createwallet",
|
||||
List(JsString(walletName), JsBoolean(disablePrivateKeys)))
|
||||
}
|
||||
|
||||
def getAddressInfo(
|
||||
address: BitcoinAddress,
|
||||
walletNameOpt: Option[String] = None): Future[AddressInfoResult] = {
|
||||
self.version.flatMap {
|
||||
case V18 | V19 | V20 | Unknown =>
|
||||
case V19 | V20 | Unknown =>
|
||||
bitcoindCall[AddressInfoResultPostV18](
|
||||
"getaddressinfo",
|
||||
List(JsString(address.value)),
|
||||
|
|
|
@ -1,130 +0,0 @@
|
|||
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.api.chain.ChainQueryApi
|
||||
import org.bitcoins.core.api.chain.db.{CompactFilterDb, CompactFilterHeaderDb}
|
||||
import org.bitcoins.core.protocol.transaction.Transaction
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, ECPrivateKey, HashType}
|
||||
import org.bitcoins.rpc.client.common.{
|
||||
BitcoindRpcClient,
|
||||
BitcoindVersion,
|
||||
DescriptorRpc,
|
||||
PsbtRpc
|
||||
}
|
||||
import org.bitcoins.rpc.config.BitcoindInstance
|
||||
import play.api.libs.json._
|
||||
|
||||
import scala.concurrent.Future
|
||||
import scala.util.Try
|
||||
|
||||
/** Class for creating a BitcoindV18 instance that can access RPCs
|
||||
* @param instance
|
||||
* @param actorSystem
|
||||
*/
|
||||
class BitcoindV18RpcClient(override val instance: BitcoindInstance)(implicit
|
||||
actorSystem: ActorSystem)
|
||||
extends BitcoindRpcClient(instance)
|
||||
with DescriptorRpc
|
||||
with PsbtRpc
|
||||
with V18AssortedRpc {
|
||||
|
||||
override lazy val version: Future[BitcoindVersion.V18.type] =
|
||||
Future.successful(BitcoindVersion.V18)
|
||||
|
||||
override def getFilterCount(): Future[Int] = filtersUnsupported
|
||||
|
||||
override def getFiltersBetweenHeights(
|
||||
startHeight: Int,
|
||||
endHeight: Int): Future[Vector[ChainQueryApi.FilterResponse]] =
|
||||
filtersUnsupported
|
||||
|
||||
override def getFilterHeaderCount(): Future[Int] = filtersUnsupported
|
||||
|
||||
override def getFilterHeadersAtHeight(
|
||||
height: Int): Future[Vector[CompactFilterHeaderDb]] = filtersUnsupported
|
||||
|
||||
override def getBestFilterHeader(): Future[Option[CompactFilterHeaderDb]] =
|
||||
filtersUnsupported
|
||||
|
||||
override def getFilterHeader(
|
||||
blockHash: DoubleSha256DigestBE): Future[Option[CompactFilterHeaderDb]] =
|
||||
filtersUnsupported
|
||||
|
||||
override def getFilter(
|
||||
hash: DoubleSha256DigestBE): Future[Option[CompactFilterDb]] =
|
||||
filtersUnsupported
|
||||
|
||||
override def getFiltersAtHeight(
|
||||
height: Int): Future[Vector[CompactFilterDb]] = filtersUnsupported
|
||||
|
||||
/** $signRawTx
|
||||
*
|
||||
* This RPC call signs the raw transaction with keys found in
|
||||
* the Bitcoin Core wallet.
|
||||
*/
|
||||
def signRawTransactionWithWallet(
|
||||
transaction: Transaction,
|
||||
utxoDeps: Vector[RpcOpts.SignRawTransactionOutputParameter] =
|
||||
Vector.empty,
|
||||
sigHash: HashType = HashType.sigHashAll
|
||||
): Future[SignRawTransactionResult] =
|
||||
bitcoindCall[SignRawTransactionResult]("signrawtransactionwithwallet",
|
||||
List(JsString(transaction.hex),
|
||||
Json.toJson(utxoDeps),
|
||||
Json.toJson(sigHash)))
|
||||
|
||||
/** $signRawTx
|
||||
*
|
||||
* This RPC call signs the raw transaction with keys provided
|
||||
* manually.
|
||||
*/
|
||||
def signRawTransactionWithKey(
|
||||
transaction: Transaction,
|
||||
keys: Vector[ECPrivateKey],
|
||||
utxoDeps: Vector[RpcOpts.SignRawTransactionOutputParameter] =
|
||||
Vector.empty,
|
||||
sigHash: HashType = HashType.sigHashAll
|
||||
): Future[SignRawTransactionResult] =
|
||||
bitcoindCall[SignRawTransactionResult]("signrawtransactionwithkey",
|
||||
List(JsString(transaction.hex),
|
||||
Json.toJson(keys),
|
||||
Json.toJson(utxoDeps),
|
||||
Json.toJson(sigHash)))
|
||||
|
||||
}
|
||||
|
||||
object BitcoindV18RpcClient {
|
||||
|
||||
/** 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): BitcoindV18RpcClient = {
|
||||
implicit val system = 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): BitcoindV18RpcClient =
|
||||
new BitcoindV18RpcClient(instance)(system)
|
||||
|
||||
def fromUnknownVersion(
|
||||
rpcClient: BitcoindRpcClient): Try[BitcoindV18RpcClient] =
|
||||
Try {
|
||||
new BitcoindV18RpcClient(rpcClient.instance)(rpcClient.system)
|
||||
}
|
||||
|
||||
}
|
|
@ -33,8 +33,7 @@ trait V18AssortedRpc {
|
|||
bitcoindCall[Vector[GetNodeAddressesResultPostV22]](
|
||||
"getnodeaddresses",
|
||||
List(Json.toJson(count)))
|
||||
case BitcoindVersion.V18 | BitcoindVersion.V19 | BitcoindVersion.V20 |
|
||||
BitcoindVersion.V21 =>
|
||||
case BitcoindVersion.V19 | BitcoindVersion.V20 | BitcoindVersion.V21 =>
|
||||
bitcoindCall[Vector[GetNodeAddressesResultPreV22]](
|
||||
"getnodeaddresses",
|
||||
List(Json.toJson(count)))
|
||||
|
|
|
@ -39,7 +39,7 @@ trait V20MultisigRpc extends MultisigRpc { self: Client =>
|
|||
self.version.flatMap {
|
||||
case V20 | V21 | V22 | V23 | Unknown =>
|
||||
bitcoindCall[MultiSigResultPostV20]("addmultisigaddress", params)
|
||||
case version @ (V18 | V19) =>
|
||||
case version @ V19 =>
|
||||
throw new RuntimeException(
|
||||
s"Cannot use v20MultisigRpc on an older version, got $version")
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ trait V20MultisigRpc extends MultisigRpc { self: Client =>
|
|||
Json.toJson(addressType)),
|
||||
uriExtensionOpt = walletNameOpt.map(walletExtension)
|
||||
)
|
||||
case version @ (V18 | V19) =>
|
||||
case version @ V19 =>
|
||||
throw new RuntimeException(
|
||||
s"Cannot use v20MultisigRpc on an older version, got $version")
|
||||
}
|
||||
|
|
|
@ -55,8 +55,6 @@ sealed trait BitcoindInstanceLocal extends BitcoindInstance {
|
|||
.last
|
||||
|
||||
foundVersion match {
|
||||
case _: String if foundVersion.startsWith(BitcoindVersion.V18.toString) =>
|
||||
BitcoindVersion.V18
|
||||
case _: String if foundVersion.startsWith(BitcoindVersion.V19.toString) =>
|
||||
BitcoindVersion.V19
|
||||
case _: String if foundVersion.startsWith(BitcoindVersion.V20.toString) =>
|
||||
|
|
|
@ -114,7 +114,7 @@ abstract class BlockHeaderHelper {
|
|||
val prevHash = prevHeader.blockHeader.hash
|
||||
val blockHeader = {
|
||||
BlockHeader(
|
||||
version = Int32.one,
|
||||
version = Int32(5),
|
||||
previousBlockHash = prevHash,
|
||||
//get random 32 bytes
|
||||
merkleRootHash =
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.bitcoins.testkit.rpc
|
||||
|
||||
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
|
||||
import org.bitcoins.rpc.client.v18.BitcoindV18RpcClient
|
||||
import org.bitcoins.rpc.client.v19.BitcoindV19RpcClient
|
||||
import org.bitcoins.rpc.client.v20.BitcoindV20RpcClient
|
||||
import org.bitcoins.rpc.client.v21.BitcoindV21RpcClient
|
||||
|
@ -50,41 +49,6 @@ trait BitcoindFixturesFundedCached extends BitcoindFixtures {
|
|||
}
|
||||
}
|
||||
|
||||
/** Test trait that caches a [[BitcoindV18RpcClient]] that is funded
|
||||
* and available to use with fixtures
|
||||
*/
|
||||
trait BitcoindFixturesFundedCachedV18
|
||||
extends BitcoinSAsyncFixtureTest
|
||||
with BitcoindFixturesFundedCached
|
||||
with CachedBitcoindV18 {
|
||||
|
||||
override type FixtureParam = BitcoindV18RpcClient
|
||||
|
||||
override def withFixture(test: OneArgAsyncTest): FutureOutcome = {
|
||||
val f: Future[Outcome] = for {
|
||||
bitcoind <- cachedBitcoindWithFundsF
|
||||
futOutcome = withV18FundedBitcoindCached(test, bitcoind)
|
||||
fut <- futOutcome.toFuture
|
||||
} yield fut
|
||||
new FutureOutcome(f)
|
||||
}
|
||||
|
||||
def withV18FundedBitcoindCached(
|
||||
test: OneArgAsyncTest,
|
||||
bitcoind: BitcoindV18RpcClient): FutureOutcome = {
|
||||
makeDependentFixture[BitcoindV18RpcClient](
|
||||
() => Future.successful(bitcoind),
|
||||
{ case _ =>
|
||||
Future.unit // don't want to destroy anything since it is cached
|
||||
})(test)
|
||||
}
|
||||
|
||||
override def afterAll(): Unit = {
|
||||
super[CachedBitcoindV18].afterAll()
|
||||
super[BitcoinSAsyncFixtureTest].afterAll()
|
||||
}
|
||||
}
|
||||
|
||||
/** Test trait that caches a [[BitcoindV19RpcClient]] that is funded
|
||||
* and available to use with fixtures
|
||||
*/
|
||||
|
@ -298,29 +262,6 @@ trait BitcoindFixturesCachedPair[T <: BitcoindRpcClient]
|
|||
}
|
||||
}
|
||||
|
||||
/** Bitcoind fixtures with two cached [[BitcoindV18RpcClient]] that are connected via p2p */
|
||||
trait BitcoindFixturesCachedPairV18
|
||||
extends BitcoinSAsyncFixtureTest
|
||||
with BitcoindFixturesCachedPair[BitcoindV18RpcClient] {
|
||||
override type FixtureParam = NodePair[BitcoindV18RpcClient]
|
||||
|
||||
override val version: BitcoindVersion = BitcoindVersion.V18
|
||||
|
||||
override def withFixture(test: OneArgAsyncTest): FutureOutcome = {
|
||||
val futOutcome = for {
|
||||
pair <- clientsF
|
||||
futOutcome = with2BitcoindsCached(test, pair)
|
||||
f <- futOutcome.toFuture
|
||||
} yield f
|
||||
new FutureOutcome(futOutcome)
|
||||
}
|
||||
|
||||
override def afterAll(): Unit = {
|
||||
super[BitcoindFixturesCachedPair].afterAll()
|
||||
super[BitcoinSAsyncFixtureTest].afterAll()
|
||||
}
|
||||
}
|
||||
|
||||
trait BitcoindFixturesCachedPairV19
|
||||
extends BitcoinSAsyncFixtureTest
|
||||
with BitcoindFixturesCachedPair[BitcoindV19RpcClient] {
|
||||
|
|
|
@ -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.v18.BitcoindV18RpcClient
|
||||
import org.bitcoins.rpc.client.v19.BitcoindV19RpcClient
|
||||
import org.bitcoins.rpc.client.v20.BitcoindV20RpcClient
|
||||
import org.bitcoins.rpc.client.v21.BitcoindV21RpcClient
|
||||
|
@ -175,7 +174,7 @@ trait BitcoindRpcTestUtil extends Logging {
|
|||
version match {
|
||||
// default to newest version
|
||||
case Unknown => getBinary(BitcoindVersion.newest, binaryDirectory)
|
||||
case known @ (V18 | V19 | V20 | V21 | V22 | V23) =>
|
||||
case known @ (V19 | V20 | V21 | V22 | V23) =>
|
||||
val fileList = Files
|
||||
.list(binaryDirectory)
|
||||
.iterator()
|
||||
|
@ -220,8 +219,6 @@ trait BitcoindRpcTestUtil extends Logging {
|
|||
false
|
||||
} else {
|
||||
versionOpt match {
|
||||
case Some(V18) =>
|
||||
false
|
||||
case Some(V19) | Some(V20) | Some(V21) | Some(V22) | Some(V23) | Some(
|
||||
Unknown) | None =>
|
||||
true
|
||||
|
@ -251,20 +248,6 @@ trait BitcoindRpcTestUtil extends Logging {
|
|||
BitcoindInstanceLocal.fromConfig(conf, binary)
|
||||
}
|
||||
|
||||
def v18Instance(
|
||||
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.V18),
|
||||
binaryDirectory = binaryDirectory)
|
||||
|
||||
def v19Instance(
|
||||
port: Int = RpcUtil.randomPort,
|
||||
rpcPort: Int = RpcUtil.randomPort,
|
||||
|
@ -345,12 +328,6 @@ trait BitcoindRpcTestUtil extends Logging {
|
|||
binaryDirectory: Path = BitcoindRpcTestClient.sbtBinaryDirectory)(implicit
|
||||
system: ActorSystem): BitcoindInstanceLocal = {
|
||||
bitcoindVersion match {
|
||||
case BitcoindVersion.V18 =>
|
||||
BitcoindRpcTestUtil.v18Instance(port,
|
||||
rpcPort,
|
||||
zmqConfig,
|
||||
pruneMode,
|
||||
binaryDirectory = binaryDirectory)
|
||||
case BitcoindVersion.V19 =>
|
||||
BitcoindRpcTestUtil.v19Instance(port,
|
||||
rpcPort,
|
||||
|
@ -394,7 +371,7 @@ trait BitcoindRpcTestUtil extends Logging {
|
|||
val createWalletF = for {
|
||||
version <- server.version
|
||||
descriptors = version match {
|
||||
case V18 | V19 | V20 | V21 | V22 | Unknown =>
|
||||
case V19 | V20 | V21 | V22 | Unknown =>
|
||||
false
|
||||
case V23 => true
|
||||
}
|
||||
|
@ -696,9 +673,6 @@ trait BitcoindRpcTestUtil extends Logging {
|
|||
val rpc = version match {
|
||||
case BitcoindVersion.Unknown =>
|
||||
BitcoindRpcClient.withActorSystem(BitcoindRpcTestUtil.instance())
|
||||
case BitcoindVersion.V18 =>
|
||||
BitcoindV18RpcClient.withActorSystem(
|
||||
BitcoindRpcTestUtil.v18Instance())
|
||||
case BitcoindVersion.V19 =>
|
||||
BitcoindV19RpcClient.withActorSystem(
|
||||
BitcoindRpcTestUtil.v19Instance())
|
||||
|
@ -795,13 +769,6 @@ trait BitcoindRpcTestUtil extends Logging {
|
|||
}
|
||||
}
|
||||
|
||||
/** Returns a pair of [[org.bitcoins.rpc.client.v18.BitcoindV18RpcClient BitcoindV18RpcClient]]
|
||||
* that are connected with some blocks in the chain
|
||||
*/
|
||||
def createNodePairV18(clientAccum: RpcClientAccum)(implicit
|
||||
system: ActorSystem): Future[(BitcoindV18RpcClient, BitcoindV18RpcClient)] =
|
||||
createNodePairInternal(BitcoindVersion.V18, clientAccum)
|
||||
|
||||
/** Returns a pair of [[org.bitcoins.rpc.client.v19.BitcoindV19RpcClient BitcoindV19RpcClient]]
|
||||
* that are connected with some blocks in the chain
|
||||
*/
|
||||
|
@ -886,13 +853,6 @@ trait BitcoindRpcTestUtil extends Logging {
|
|||
createNodeTripleInternal(version)
|
||||
}
|
||||
|
||||
def createNodeTripleV18(
|
||||
clientAccum: RpcClientAccum
|
||||
)(implicit system: ActorSystem): Future[
|
||||
(BitcoindV18RpcClient, BitcoindV18RpcClient, BitcoindV18RpcClient)] = {
|
||||
createNodeTripleInternal(BitcoindVersion.V18, clientAccum)
|
||||
}
|
||||
|
||||
def createNodeTripleV19(
|
||||
clientAccum: RpcClientAccum
|
||||
)(implicit system: ActorSystem): Future[
|
||||
|
@ -951,16 +911,13 @@ trait BitcoindRpcTestUtil extends Logging {
|
|||
case v21: BitcoindV21RpcClient =>
|
||||
v21.signRawTransactionWithWallet(transaction, utxoDeps)
|
||||
case unknown: BitcoindRpcClient =>
|
||||
val v18T = BitcoindV18RpcClient.fromUnknownVersion(unknown)
|
||||
val v19T = BitcoindV19RpcClient.fromUnknownVersion(unknown)
|
||||
(v18T, v19T) match {
|
||||
case (Failure(_), Failure(_)) =>
|
||||
v19T match {
|
||||
case Failure(_) =>
|
||||
throw new RuntimeException(
|
||||
"Could not figure out version of provided bitcoind RPC client!" +
|
||||
"This should not happen, managed to construct different versioned RPC clients from one single client")
|
||||
case (Success(v18), _) =>
|
||||
v18.signRawTransactionWithWallet(transaction, utxoDeps)
|
||||
case (_, Success(v19)) =>
|
||||
case Success(v19) =>
|
||||
v19.signRawTransactionWithWallet(transaction, utxoDeps)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.bitcoins.testkit.rpc
|
||||
|
||||
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
|
||||
import org.bitcoins.rpc.client.v18.BitcoindV18RpcClient
|
||||
import org.bitcoins.rpc.client.v19.{BitcoindV19RpcClient, V19BlockFilterRpc}
|
||||
import org.bitcoins.rpc.client.v20.BitcoindV20RpcClient
|
||||
import org.bitcoins.rpc.client.v21.BitcoindV21RpcClient
|
||||
|
@ -133,18 +132,6 @@ trait CachedBitcoindBlockFilterRpcNewest
|
|||
}
|
||||
}
|
||||
|
||||
trait CachedBitcoindV18 extends CachedBitcoindFunded[BitcoindV18RpcClient] {
|
||||
_: BitcoinSAkkaAsyncTest =>
|
||||
|
||||
override protected lazy val cachedBitcoindWithFundsF: Future[
|
||||
BitcoindV18RpcClient] = {
|
||||
val _ = isBitcoindUsed.set(true)
|
||||
BitcoinSFixture
|
||||
.createBitcoindWithFunds(Some(BitcoindVersion.V18))
|
||||
.map(_.asInstanceOf[BitcoindV18RpcClient])
|
||||
}
|
||||
}
|
||||
|
||||
trait CachedBitcoindV19 extends CachedBitcoindFunded[BitcoindV19RpcClient] {
|
||||
_: BitcoinSAkkaAsyncTest =>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue