Fix rpc bind address from config (#2542)

* Fix rpc bind address from config

* Add to oracle server
This commit is contained in:
benthecarman 2021-01-21 17:21:54 -06:00 committed by GitHub
parent 906387c469
commit 09937e6ecf
4 changed files with 33 additions and 6 deletions

View File

@ -15,6 +15,11 @@ class OracleServerMain(override val args: Array[String])
implicit val conf: DLCOracleAppConfig =
DLCOracleAppConfig(datadir, baseConfig)
val bindConfOpt = rpcBindOpt match {
case Some(rpcbind) => Some(rpcbind)
case None => conf.rpcBindOpt
}
for {
_ <- conf.start()
oracle <- conf.initialize()
@ -24,17 +29,17 @@ class OracleServerMain(override val args: Array[String])
case Some(rpcport) =>
Server(conf = conf,
handlers = routes,
rpcbindOpt = rpcBindOpt,
rpcbindOpt = bindConfOpt,
rpcport = rpcport)
case None =>
conf.rpcPortOpt match {
case Some(rpcport) =>
Server(conf = conf,
handlers = routes,
rpcbindOpt = rpcBindOpt,
rpcbindOpt = bindConfOpt,
rpcport = rpcport)
case None =>
Server(conf = conf, handlers = routes, rpcbindOpt = rpcBindOpt)
Server(conf = conf, handlers = routes, rpcbindOpt = bindConfOpt)
}
}

View File

@ -74,6 +74,14 @@ case class BitcoinSAppConfig(
None
}
}
def rpcBindOpt: Option[String] = {
if (config.hasPath("bitcoin-s.server.rpcbind")) {
Some(config.getString("bitcoin-s.server.rpcbind"))
} else {
None
}
}
}
/**

View File

@ -286,13 +286,19 @@ class BitcoinSServerMain(override val args: Array[String])
val nodeRoutes = NodeRoutes(nodeApi)
val chainRoutes = ChainRoutes(chainApi, nodeConf.network)
val coreRoutes = CoreRoutes(Core)
val bindConfOpt = rpcbindOpt match {
case Some(rpcbind) => Some(rpcbind)
case None => conf.rpcBindOpt
}
val server = {
rpcPortOpt match {
case Some(rpcport) =>
Server(conf = nodeConf,
handlers =
Seq(walletRoutes, nodeRoutes, chainRoutes, coreRoutes),
rpcbindOpt = rpcbindOpt,
rpcbindOpt = bindConfOpt,
rpcport = rpcport)
case None =>
conf.rpcPortOpt match {
@ -300,13 +306,13 @@ class BitcoinSServerMain(override val args: Array[String])
Server(conf = nodeConf,
handlers =
Seq(walletRoutes, nodeRoutes, chainRoutes, coreRoutes),
rpcbindOpt = rpcbindOpt,
rpcbindOpt = bindConfOpt,
rpcport = rpcport)
case None =>
Server(conf = nodeConf,
handlers =
Seq(walletRoutes, nodeRoutes, chainRoutes, coreRoutes),
rpcbindOpt = rpcbindOpt)
rpcbindOpt = bindConfOpt)
}
}
}

View File

@ -100,6 +100,14 @@ case class DLCOracleAppConfig(
}
}
def rpcBindOpt: Option[String] = {
if (config.hasPath("bitcoin-s.server.rpcbind")) {
Some(config.getString("bitcoin-s.server.rpcbind"))
} else {
None
}
}
lazy val kmParams: KeyManagerParams =
KeyManagerParams(kmConf.seedPath,
HDPurpose(DLCOracle.R_VALUE_PURPOSE),