From ce44cfe8771069a4bf83ac2a8a7c5019b9256af2 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 15 Dec 2022 16:37:33 +0200 Subject: [PATCH] export 8 decimal places when exporting a csv in btc units --- src/main/java/com/sparrowwallet/sparrow/UnitFormat.java | 4 ++++ .../sparrowwallet/sparrow/wallet/TransactionsController.java | 2 +- .../com/sparrowwallet/sparrow/wallet/UtxosController.java | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/UnitFormat.java b/src/main/java/com/sparrowwallet/sparrow/UnitFormat.java index 41a1afb2..85ec8331 100644 --- a/src/main/java/com/sparrowwallet/sparrow/UnitFormat.java +++ b/src/main/java/com/sparrowwallet/sparrow/UnitFormat.java @@ -82,6 +82,10 @@ public enum UnitFormat { return getBtcFormat().format(amount.doubleValue() / Transaction.SATOSHIS_PER_BITCOIN); } + public String tableFormatBtcValue(Long amount) { + return getTableBtcFormat().format(amount.doubleValue() / Transaction.SATOSHIS_PER_BITCOIN); + } + public String formatSatsValue(Long amount) { return getSatsFormat().format(amount); } diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/TransactionsController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/TransactionsController.java index 6463f6ac..52d8dcc6 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/TransactionsController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/TransactionsController.java @@ -142,7 +142,7 @@ public class TransactionsController extends WalletFormController implements Init private String getCoinValue(Long value) { UnitFormat format = Config.get().getUnitFormat() == null ? UnitFormat.DOT : Config.get().getUnitFormat(); - return BitcoinUnit.BTC.equals(transactionsTable.getBitcoinUnit()) ? format.formatBtcValue(value) : String.format(Locale.ENGLISH, "%d", value); + return BitcoinUnit.BTC.equals(transactionsTable.getBitcoinUnit()) ? format.tableFormatBtcValue(value) : String.format(Locale.ENGLISH, "%d", value); } private void logMessage(String logMessage) { diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java index a80ee786..109ae174 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java @@ -491,7 +491,7 @@ public class UtxosController extends WalletFormController implements Initializab private String getCoinValue(Long value) { UnitFormat format = Config.get().getUnitFormat() == null ? UnitFormat.DOT : Config.get().getUnitFormat(); - return BitcoinUnit.BTC.equals(utxosTable.getBitcoinUnit()) ? format.formatBtcValue(value) : String.format(Locale.ENGLISH, "%d", value); + return BitcoinUnit.BTC.equals(utxosTable.getBitcoinUnit()) ? format.tableFormatBtcValue(value) : String.format(Locale.ENGLISH, "%d", value); } private static Glyph getExternalGlyph() {