mirror of
https://github.com/ACINQ/eclair.git
synced 2024-11-20 10:39:19 +01:00
Check configuration for obsolete keys in startup (#1175)
* Check configuration for obsolete keys on startup We now check the loaded configuration for obsolete keys (that have been moved to a new section) and throw an error if any are found, which will prevent eclair from starting.
This commit is contained in:
parent
bdb093a7a8
commit
5ff8828d07
@ -128,6 +128,15 @@ object NodeParams {
|
||||
}
|
||||
|
||||
def makeNodeParams(config: Config, keyManager: KeyManager, torAddress_opt: Option[NodeAddress], database: Databases, blockCount: AtomicLong, feeEstimator: FeeEstimator): NodeParams = {
|
||||
// check configuration for keys that have been renamed in v0.3.2
|
||||
val deprecatedKeyPaths = Map(
|
||||
"default-feerates" -> "on-chain-fees.default-feerates",
|
||||
"max-feerate-mismatch" -> "on-chain-fees.max-feerate-mismatch",
|
||||
"update-fee_min-diff-ratio" -> "on-chain-fees.update-fee-min-diff-ratio"
|
||||
)
|
||||
deprecatedKeyPaths.foreach {
|
||||
case (old, new_) => require(!config.hasPath(old), s"configuration key '$old' has been replaced by '$new_'")
|
||||
}
|
||||
|
||||
val chain = config.getString("chain")
|
||||
val chainHash = makeChainHash(chain)
|
||||
|
@ -18,15 +18,28 @@ package fr.acinq.eclair
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import com.typesafe.config.{ConfigFactory, ConfigValue}
|
||||
import fr.acinq.bitcoin.Block
|
||||
import fr.acinq.eclair.crypto.LocalKeyManager
|
||||
import org.scalatest.FunSuite
|
||||
|
||||
import scala.collection.JavaConversions._
|
||||
import scala.util.Try
|
||||
|
||||
class StartupSpec extends FunSuite {
|
||||
|
||||
test("check configuration") {
|
||||
val blockCount = new AtomicLong(0)
|
||||
val keyManager = new LocalKeyManager(seed = randomBytes32, chainHash = Block.TestnetGenesisBlock.hash)
|
||||
val conf = ConfigFactory.load().getConfig("eclair")
|
||||
assert(Try(NodeParams.makeNodeParams(conf, keyManager, None, TestConstants.inMemoryDb(), blockCount, new TestConstants.TestFeeEstimator)).isSuccess)
|
||||
|
||||
val conf1 = conf.withFallback(ConfigFactory.parseMap(Map("max-feerate-mismatch" -> 42)))
|
||||
intercept[RuntimeException] {
|
||||
NodeParams.makeNodeParams(conf1, keyManager, None, TestConstants.inMemoryDb(), blockCount, new TestConstants.TestFeeEstimator)
|
||||
}
|
||||
}
|
||||
|
||||
test("NodeParams should fail if the alias is illegal (over 32 bytes)") {
|
||||
|
||||
val threeBytesUTFChar = '\u20AC' // €
|
||||
|
Loading…
Reference in New Issue
Block a user