Add debug window button to unreserve all utxos (#3633)

This commit is contained in:
user411 2021-08-30 11:31:38 -06:00 committed by GitHub
parent 2d429db60d
commit 11dd28085a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,16 +1,19 @@
package org.bitcoins.gui.dialog
import grizzled.slf4j.Logging
import org.bitcoins.gui.GlobalData
import org.bitcoins.cli.CliCommand.LockUnspent
import org.bitcoins.cli.ConsoleCli
import org.bitcoins.gui.{GlobalData, TaskRunner}
import scalafx.Includes._
import scalafx.scene.control.{Button, ButtonType, Dialog}
import scalafx.geometry.Pos
import scalafx.scene.control.{Button, ButtonType, Dialog, ProgressIndicator}
import scalafx.scene.layout.VBox
import scalafx.stage.{Modality, Window}
import java.awt.Desktop
import java.io.File
import java.nio.file.{Files, Paths}
import scala.util.Properties
import scala.util.{Failure, Properties, Success}
object DebugDialog extends Logging {
@ -59,12 +62,41 @@ object DebugDialog extends Logging {
}
}
dialog.dialogPane().content = new VBox {
val unreserveAllUTXOsButton = new Button("Unreserve All UTXOs")
val content = new VBox {
minWidth = 300
minHeight = 300
children = Seq(openLogButton)
spacing = 10
children = Seq(openLogButton, unreserveAllUTXOsButton)
}
val glassPane = new VBox {
children = new ProgressIndicator {
progress = ProgressIndicator.IndeterminateProgress
visible = true
}
alignment = Pos.Center
visible = false
}
lazy val taskRunner = new TaskRunner(content, glassPane)
unreserveAllUTXOsButton.onAction = _ => {
taskRunner.run(
"Unreserve All UTXOs", {
ConsoleCli.exec(LockUnspent(true, Vector.empty),
GlobalData.consoleCliConfig) match {
case Success(_) => ()
case Failure(err) =>
throw err
}
}
)
}
dialog.dialogPane().content = content
val _ = dialog.show()
}
}