Merge pull request #563 from cwaldron97/2019-07-02-Windows-implementation-for-bitcoind

Add windows compatability to bitcoind RPC client
This commit is contained in:
Torkel Rogstad 2019-07-04 10:19:45 +02:00 committed by GitHub
commit 53ae772cb3
2 changed files with 22 additions and 8 deletions

View file

@ -331,7 +331,12 @@ object BitcoindConfig extends BitcoinSLogger {
"Library", "Library",
"Application Support", "Application Support",
"Bitcoin") "Bitcoin")
} else { } else if (Properties.isWin) {
Paths.get("C:",
"Program Files",
"Bitcoin")
}
else {
Paths.get(Properties.userHome, ".bitcoin") Paths.get(Properties.userHome, ".bitcoin")
} }
path.toFile path.toFile

View file

@ -9,7 +9,8 @@ import org.bitcoins.rpc.client.common.BitcoindVersion
import scala.sys.process._ import scala.sys.process._
import org.bitcoins.core.util.BitcoinSLogger import org.bitcoins.core.util.BitcoinSLogger
import org.bitcoins.core.config.NetworkParameters import org.bitcoins.core.config.NetworkParameters
import scala.util.Try
import scala.util.{Properties, Try}
import java.nio.file.Files import java.nio.file.Files
/** /**
@ -38,7 +39,9 @@ sealed trait BitcoindInstance extends BitcoinSLogger {
def getVersion: BitcoindVersion = { def getVersion: BitcoindVersion = {
val binaryPath = binary.getAbsolutePath val binaryPath = binary.getAbsolutePath
val foundVersion = Seq(binaryPath, "--version").!!.split("\n").head
val foundVersion =
Seq(binaryPath, "--version").!!.split(Properties.lineSeparator).head
.split(" ") .split(" ")
.last .last
@ -84,9 +87,15 @@ object BitcoindInstance {
} }
lazy val DEFAULT_BITCOIND_LOCATION: File = { lazy val DEFAULT_BITCOIND_LOCATION: File = {
val path = Try("which bitcoind".!!)
.getOrElse( val cmd =
throw new RuntimeException("Could not locate bitcoind on user PATH")) if (Properties.isWin) {
"which bitcoind.exe".!!
} else {
"which bitcoind".!!
}
val path = cmd
new File(path.trim) new File(path.trim)
} }