mirror of
https://github.com/ACINQ/eclair.git
synced 2025-02-24 14:50:46 +01:00
(gui) Remove the millisatoshis part from milli-bitcoin amounts (#153)
* (gui) Added localized decimal patterns for amounts * balance and capacity in channel pane are formatted with the milliBTC pattern * (gui) using vm default locale is fine with DecimalFormat
This commit is contained in:
parent
c94cb13dd3
commit
c24b9f0c22
2 changed files with 21 additions and 5 deletions
|
@ -13,6 +13,7 @@ import fr.acinq.bitcoin._
|
||||||
import fr.acinq.eclair.blockchain.zmq.{ZMQConnected, ZMQDisconnected}
|
import fr.acinq.eclair.blockchain.zmq.{ZMQConnected, ZMQDisconnected}
|
||||||
import fr.acinq.eclair.channel._
|
import fr.acinq.eclair.channel._
|
||||||
import fr.acinq.eclair.gui.controllers._
|
import fr.acinq.eclair.gui.controllers._
|
||||||
|
import fr.acinq.eclair.gui.utils.CoinFormat
|
||||||
import fr.acinq.eclair.payment.{PaymentReceived, PaymentRelayed, PaymentSent}
|
import fr.acinq.eclair.payment.{PaymentReceived, PaymentRelayed, PaymentSent}
|
||||||
import fr.acinq.eclair.router._
|
import fr.acinq.eclair.router._
|
||||||
import fr.acinq.eclair.wire.NodeAnnouncement
|
import fr.acinq.eclair.wire.NodeAnnouncement
|
||||||
|
@ -50,8 +51,8 @@ class GUIUpdater(mainController: MainController) extends Actor with ActorLogging
|
||||||
|
|
||||||
def updateBalance(channelPaneController: ChannelPaneController, commitments: Commitments) = {
|
def updateBalance(channelPaneController: ChannelPaneController, commitments: Commitments) = {
|
||||||
val spec = commitments.localCommit.spec
|
val spec = commitments.localCommit.spec
|
||||||
channelPaneController.capacity.setText(s"${millisatoshi2millibtc(MilliSatoshi(spec.totalFunds)).amount}")
|
channelPaneController.capacity.setText(s"${CoinFormat.MILLI_BTC_FORMAT.format(millisatoshi2millibtc(MilliSatoshi(spec.totalFunds)).amount)}")
|
||||||
channelPaneController.amountUs.setText(s"${millisatoshi2millibtc(MilliSatoshi(spec.toLocalMsat)).amount}")
|
channelPaneController.amountUs.setText(s"${CoinFormat.MILLI_BTC_FORMAT.format(millisatoshi2millibtc(MilliSatoshi(spec.toLocalMsat)).amount)}")
|
||||||
channelPaneController.balanceBar.setProgress(spec.toLocalMsat.toDouble / spec.totalFunds)
|
channelPaneController.balanceBar.setProgress(spec.toLocalMsat.toDouble / spec.totalFunds)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +92,7 @@ class GUIUpdater(mainController: MainController) extends Actor with ActorLogging
|
||||||
val channelPaneController = m(channel)
|
val channelPaneController = m(channel)
|
||||||
Platform.runLater(new Runnable() {
|
Platform.runLater(new Runnable() {
|
||||||
override def run = {
|
override def run = {
|
||||||
channelPaneController.close.setText( if (OFFLINE == currentState) "Force close" else "Close")
|
channelPaneController.close.setText(if (OFFLINE == currentState) "Force close" else "Close")
|
||||||
channelPaneController.state.setText(currentState.toString)
|
channelPaneController.state.setText(currentState.toString)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -113,7 +114,7 @@ class GUIUpdater(mainController: MainController) extends Actor with ActorLogging
|
||||||
|
|
||||||
case NodeDiscovered(nodeAnnouncement) =>
|
case NodeDiscovered(nodeAnnouncement) =>
|
||||||
log.debug(s"peer node discovered with node id=${nodeAnnouncement.nodeId}")
|
log.debug(s"peer node discovered with node id=${nodeAnnouncement.nodeId}")
|
||||||
if(!mainController.networkNodesList.exists(na => na.nodeId == nodeAnnouncement.nodeId)) {
|
if (!mainController.networkNodesList.exists(na => na.nodeId == nodeAnnouncement.nodeId)) {
|
||||||
mainController.networkNodesList.add(nodeAnnouncement)
|
mainController.networkNodesList.add(nodeAnnouncement)
|
||||||
m.foreach(f => if (nodeAnnouncement.nodeId.toString.equals(f._2.theirNodeIdValue)) {
|
m.foreach(f => if (nodeAnnouncement.nodeId.toString.equals(f._2.theirNodeIdValue)) {
|
||||||
Platform.runLater(new Runnable() {
|
Platform.runLater(new Runnable() {
|
||||||
|
@ -142,7 +143,7 @@ class GUIUpdater(mainController: MainController) extends Actor with ActorLogging
|
||||||
|
|
||||||
case ChannelDiscovered(channelAnnouncement, _) =>
|
case ChannelDiscovered(channelAnnouncement, _) =>
|
||||||
log.debug(s"peer channel discovered with channel id=${channelAnnouncement.shortChannelId}")
|
log.debug(s"peer channel discovered with channel id=${channelAnnouncement.shortChannelId}")
|
||||||
if(!mainController.networkChannelsList.exists(c => c.announcement.shortChannelId == channelAnnouncement.shortChannelId)) {
|
if (!mainController.networkChannelsList.exists(c => c.announcement.shortChannelId == channelAnnouncement.shortChannelId)) {
|
||||||
mainController.networkChannelsList.add(new ChannelInfo(channelAnnouncement, None, None))
|
mainController.networkChannelsList.add(new ChannelInfo(channelAnnouncement, None, None))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package fr.acinq.eclair.gui.utils
|
||||||
|
|
||||||
|
import java.text.DecimalFormat
|
||||||
|
|
||||||
|
object CoinFormat {
|
||||||
|
/**
|
||||||
|
* Always 5 decimals
|
||||||
|
*/
|
||||||
|
val MILLI_BTC_PATTERN = "###,##0.00000"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Localized formatter for milli-bitcoin amounts. Uses `MILLI_BTC_PATTERN`.
|
||||||
|
*/
|
||||||
|
val MILLI_BTC_FORMAT: DecimalFormat = new DecimalFormat(MILLI_BTC_PATTERN)
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue