Implement rpc password in GUI (#3986)

This commit is contained in:
Chris Stewart 2022-01-15 20:41:27 -06:00 committed by GitHub
parent e520b492bb
commit 2aa6f168eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 3 deletions

View file

@ -105,6 +105,10 @@ object BundleGUI extends WalletGUI with BitcoinSAppJFX3 {
datadirParser.datadir,
serverArgParser)(system)
if (appConfig.rpcPassword.nonEmpty) {
GlobalData.setPassword(appConfig.rpcPassword)
}
validatePreferenceValues()
val landingPane = new LandingPane(glassPane, serverArgParser)

View file

@ -51,25 +51,42 @@ object GlobalData {
var darkThemeEnabled: Boolean = true
def currentStyleSheets: Seq[String] =
def currentStyleSheets: Seq[String] = {
if (GlobalData.darkThemeEnabled) {
Seq(Themes.DarkTheme.fileLocation)
} else {
Seq.empty
}
}
var rpcPortOpt: Option[Int] = None
var debug = false
def consoleCliConfig: Config =
rpcPortOpt match {
private var passwordOpt: Option[String] = None
/** Sets the rpc password for the GUI */
def setPassword(password: String): Unit = {
passwordOpt = Some(password)
}
def consoleCliConfig: Config = {
val rpcConfigAndDebug = rpcPortOpt match {
case None =>
Config(debug = debug)
case Some(rpcPort) =>
Config(debug = debug, rpcPortOpt = Some(rpcPort))
}
val passwordConfig = passwordOpt match {
case Some(password) =>
rpcConfigAndDebug.copy(rpcPassword = password)
case None =>
rpcConfigAndDebug
}
passwordConfig
}
lazy val broadcastUrl: String = GlobalData.network match {
case MainNet =>
"https://blockstream.info/api/tx"