Skip to content

Commit

Permalink
Sync Height on screen (#3196)
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed May 29, 2021
1 parent 5580771 commit ccc4035
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/gui/src/main/scala/org/bitcoins/gui/GlobalData.scala
Expand Up @@ -5,14 +5,16 @@ import org.bitcoins.core.config._
import org.bitcoins.core.wallet.fee.{FeeUnit, SatoshisPerVirtualByte}
import org.bitcoins.crypto.DoubleSha256DigestBE
import org.bitcoins.gui.settings.Themes
import scalafx.beans.property.StringProperty
import scalafx.beans.property.{LongProperty, StringProperty}

object GlobalData {
val currentConfirmedBalance: StringProperty = StringProperty("0")
val currentUnconfirmedBalance: StringProperty = StringProperty("0")
val currentReservedBalance: StringProperty = StringProperty("0")
val currentTotalBalance: StringProperty = StringProperty("0")

val syncHeight: LongProperty = LongProperty(0L)

var network: BitcoinNetwork = _

val log: StringProperty = StringProperty("")
Expand Down
11 changes: 10 additions & 1 deletion app/gui/src/main/scala/org/bitcoins/gui/WalletGUI.scala
Expand Up @@ -19,6 +19,11 @@ abstract class WalletGUI {
text <== GlobalData.statusText
}

private lazy val infoLabel = new Label {
padding = Insets(top = 0, right = 0, bottom = 10, left = 0)
text <== StringProperty("Sync Height: ") + GlobalData.syncHeight
}

def fetchStartingData(): Unit = {
model.startWalletInfoScheduler()
model.updateFeeRate()
Expand Down Expand Up @@ -82,11 +87,15 @@ abstract class WalletGUI {
children = Vector(balanceBox, getNewAddressButton, sendButton)
}

lazy val bottomStack: StackPane = new StackPane() {
children = Vector(statusLabel, infoLabel)
}

lazy val borderPane: BorderPane = new BorderPane {
top = AppMenuBar.menuBar(model)
left = sidebar
center = dlcPane.borderPane
bottom = statusLabel
bottom = bottomStack
}

lazy val rootView: StackPane = new StackPane {
Expand Down
10 changes: 10 additions & 0 deletions app/gui/src/main/scala/org/bitcoins/gui/WalletGUIModel.scala
Expand Up @@ -32,6 +32,7 @@ class WalletGUIModel()(implicit system: ActorSystem) {
override def run(): Unit = {
Platform.runLater {
updateBalance()
updateWalletInfo()
}
}
}
Expand Down Expand Up @@ -103,6 +104,15 @@ class WalletGUIModel()(implicit system: ActorSystem) {
AboutDialog.showAndWait(parentWindow.value)
}

private def updateWalletInfo(): Unit = {
ConsoleCli.exec(WalletInfo, GlobalData.consoleCliConfig) match {
case Failure(_) => ()
case Success(commandReturn) =>
val json = ujson.read(commandReturn).obj("wallet").obj
GlobalData.syncHeight.value = json("height").num.toLong
}
}

private def updateBalance(): Unit = {
ConsoleCli.exec(GetBalances(isSats = true),
GlobalData.consoleCliConfig) match {
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/main/scala/org/bitcoins/gui/dlc/DLCPane.scala
Expand Up @@ -24,7 +24,7 @@ class DLCPane(glassPane: VBox) {
}

private val resultArea = new BorderPane() {
padding = Insets(10)
padding = Insets(top = 10, right = 0, bottom = 10, left = 0)
center = resultTextArea
}

Expand Down

0 comments on commit ccc4035

Please sign in to comment.