mirror of
https://github.com/ACINQ/eclair.git
synced 2025-02-22 22:25:26 +01:00
Support for custom Electrum server (#739)
We can now use the `overrideDefaults` parameter in `Setup` to programmatically provide a custom electrum address when starting eclair, by setting the `eclair.electrum.host` and `eclair.electrum.port` entries in the configuration. When these entries are set, eclair-core will always try to connect to this server instead of relying on a random server picked from the preset lists.
This commit is contained in:
parent
2bdf258c78
commit
3a221e7e98
1 changed files with 18 additions and 9 deletions
|
@ -46,12 +46,12 @@ import scala.concurrent.duration._
|
|||
import scala.concurrent._
|
||||
|
||||
/**
|
||||
* Setup eclair from a datadir.
|
||||
* Setup eclair from a data directory.
|
||||
*
|
||||
* Created by PM on 25/01/2016.
|
||||
*
|
||||
* @param datadir directory where eclair-core will write/read its data
|
||||
* @param overrideDefaults
|
||||
* @param datadir directory where eclair-core will write/read its data.
|
||||
* @param overrideDefaults use this parameter to programmatically override the node configuration .
|
||||
* @param seed_opt optional seed, if set eclair will use it instead of generating one and won't create a seed.dat file.
|
||||
*/
|
||||
class Setup(datadir: File,
|
||||
|
@ -122,13 +122,22 @@ class Setup(datadir: File,
|
|||
Bitcoind(bitcoinClient)
|
||||
case ELECTRUM =>
|
||||
logger.warn("EXPERIMENTAL ELECTRUM MODE ENABLED!!!")
|
||||
val addressesFile = nodeParams.chainHash match {
|
||||
case Block.RegtestGenesisBlock.hash => "/electrum/servers_regtest.json"
|
||||
case Block.TestnetGenesisBlock.hash => "/electrum/servers_testnet.json"
|
||||
case Block.LivenetGenesisBlock.hash => "/electrum/servers_mainnet.json"
|
||||
val addresses = config.hasPath("eclair.electrum") match {
|
||||
case true =>
|
||||
val host = config.getString("eclair.electrum.host")
|
||||
val port = config.getInt("eclair.electrum.port")
|
||||
val address = InetSocketAddress.createUnresolved(host, port)
|
||||
logger.info(s"override electrum default with server=$address")
|
||||
Set(address)
|
||||
case false =>
|
||||
val addressesFile = nodeParams.chainHash match {
|
||||
case Block.RegtestGenesisBlock.hash => "/electrum/servers_regtest.json"
|
||||
case Block.TestnetGenesisBlock.hash => "/electrum/servers_testnet.json"
|
||||
case Block.LivenetGenesisBlock.hash => "/electrum/servers_mainnet.json"
|
||||
}
|
||||
val stream = classOf[Setup].getResourceAsStream(addressesFile)
|
||||
ElectrumClientPool.readServerAddresses(stream)
|
||||
}
|
||||
val stream = classOf[Setup].getResourceAsStream(addressesFile)
|
||||
val addresses = ElectrumClientPool.readServerAddresses(stream)
|
||||
val electrumClient = system.actorOf(SimpleSupervisor.props(Props(new ElectrumClientPool(addresses)), "electrum-client", SupervisorStrategy.Resume))
|
||||
Electrum(electrumClient)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue