mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-01-18 21:34:39 +01:00
cd3006c020
* Update lnd to v0.14.1 * Verify binary download sha256 sums
70 lines
2.0 KiB
Scala
70 lines
2.0 KiB
Scala
import java.nio.file._
|
|
import java.security.MessageDigest
|
|
import scala.util.Properties
|
|
|
|
name := "bitcoin-s-eclair-rpc"
|
|
|
|
libraryDependencies ++= Deps.eclairRpc
|
|
|
|
CommonSettings.prodSettings
|
|
|
|
TaskKeys.downloadEclair := {
|
|
val logger = streams.value.log
|
|
import scala.sys.process._
|
|
|
|
val binaryDir = CommonSettings.binariesPath.resolve("eclair")
|
|
|
|
if (Files.notExists(binaryDir)) {
|
|
logger.info(s"Creating directory for Eclair binaires: $binaryDir")
|
|
Files.createDirectories(binaryDir)
|
|
}
|
|
|
|
val version = "0.6.2"
|
|
val commit = "6817d6f"
|
|
|
|
logger.debug(s"(Maybe) downloading Eclair binaries for version: $version")
|
|
|
|
val versionDir = binaryDir resolve version
|
|
val location =
|
|
s"https://github.com/ACINQ/eclair/releases/download/v$version/eclair-node-$version-$commit-bin.zip"
|
|
|
|
if (Files.exists(versionDir)) {
|
|
logger.debug(
|
|
s"Directory $versionDir already exists, skipping download of Eclair $version")
|
|
} else {
|
|
logger.info(s"Creating directory $version")
|
|
Files.createDirectories(versionDir)
|
|
|
|
val archiveLocation = versionDir resolve s"eclair-node-$version-$commit.zip"
|
|
logger.info(
|
|
s"Downloading Eclair $version from location: $location, to destination: $archiveLocation")
|
|
(url(location) #> archiveLocation.toFile).!!
|
|
|
|
val bytes = Files.readAllBytes(archiveLocation)
|
|
val hash = MessageDigest
|
|
.getInstance("SHA-256")
|
|
.digest(bytes)
|
|
.map("%02x" format _)
|
|
.mkString
|
|
|
|
val expectedHash =
|
|
"e2407173036d9e2176c129f2328018c543c732a96d1f05c0fb35864c15efc9ba"
|
|
|
|
if (hash.equalsIgnoreCase(expectedHash)) {
|
|
logger.info(s"Download complete and verified, unzipping result")
|
|
|
|
val extractCommand = s"unzip $archiveLocation -d $versionDir"
|
|
logger.info(s"Extracting archive with command: $extractCommand")
|
|
extractCommand.!!
|
|
} else {
|
|
logger.error(
|
|
s"Downloaded invalid version of eclair, got $hash, expected $expectedHash")
|
|
}
|
|
|
|
logger.info(s"Deleting archive")
|
|
Files.delete(archiveLocation)
|
|
|
|
logger.info(s"Download complete")
|
|
}
|
|
}
|