From aa27d443a4cbfca29f8e898344e87e70a2a1fca3 Mon Sep 17 00:00:00 2001 From: sqrrm Date: Sat, 17 Nov 2018 01:24:42 +0100 Subject: [PATCH] Display confiscated bond value --- core/src/main/java/bisq/core/dao/DaoFacade.java | 4 ++++ .../main/java/bisq/core/dao/state/DaoStateService.java | 8 ++++++++ core/src/main/resources/i18n/displayStrings.properties | 1 + .../main/dao/wallet/dashboard/BsqDashboardView.java | 6 +++++- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/bisq/core/dao/DaoFacade.java b/core/src/main/java/bisq/core/dao/DaoFacade.java index 7d3b4fef8c..4126cad716 100644 --- a/core/src/main/java/bisq/core/dao/DaoFacade.java +++ b/core/src/main/java/bisq/core/dao/DaoFacade.java @@ -513,6 +513,10 @@ public class DaoFacade implements DaoSetupService { return daoStateService.getTotalAmountOfUnLockedTxOutputs(); } + public long getTotalAmountOfConfiscatedTxOutputs() { + return daoStateService.getTotalAmountOfConfiscatedTxOutputs(); + } + public Optional getLockTime(String txId) { return daoStateService.getLockTime(txId); } diff --git a/core/src/main/java/bisq/core/dao/state/DaoStateService.java b/core/src/main/java/bisq/core/dao/state/DaoStateService.java index 7ea792fdd8..5bba5977c9 100644 --- a/core/src/main/java/bisq/core/dao/state/DaoStateService.java +++ b/core/src/main/java/bisq/core/dao/state/DaoStateService.java @@ -751,6 +751,14 @@ public class DaoStateService implements DaoSetupService { .sum(); } + public long getTotalAmountOfConfiscatedTxOutputs() { + return daoState.getConfiscatedTxOutputMap() + .values() + .stream() + .mapToLong(TxOutput::getValue) + .sum(); + } + // Confiscate bond public void confiscateBond(String lockupTxId) { Optional optionalTxOutput = getLockupTxOutput(lockupTxId); diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index a6b56b52fe..a334887306 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -1628,6 +1628,7 @@ dao.wallet.dashboard.burntAmount=Burned BSQ (fees) dao.wallet.dashboard.totalLockedUpAmount=Locked up in bonds dao.wallet.dashboard.totalUnlockingAmount=Unlocking BSQ from bonds dao.wallet.dashboard.totalUnlockedAmount=Unlocked BSQ from bonds +dao.wallet.dashboard.totalConfiscatedAmount=Confiscated BSQ from bonds dao.wallet.dashboard.allTx=No. of all BSQ transactions dao.wallet.dashboard.utxo=No. of all unspent transaction outputs dao.wallet.dashboard.compensationIssuanceTx=No. of all compensation request issuance transactions diff --git a/desktop/src/main/java/bisq/desktop/main/dao/wallet/dashboard/BsqDashboardView.java b/desktop/src/main/java/bisq/desktop/main/dao/wallet/dashboard/BsqDashboardView.java index da2192b74a..457250f341 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/wallet/dashboard/BsqDashboardView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/wallet/dashboard/BsqDashboardView.java @@ -65,7 +65,8 @@ public class BsqDashboardView extends ActivatableView implements private int gridRow = 0; private TextField genesisIssueAmountTextField, compRequestIssueAmountTextField, reimbursementAmountTextField, availableAmountTextField, burntAmountTextField, totalLockedUpAmountTextField, totalUnlockingAmountTextField, - totalUnlockedAmountTextField, allTxTextField, burntTxTextField, utxoTextField, compensationIssuanceTxTextField, + totalUnlockedAmountTextField, totalConfiscatedAmountTextField, allTxTextField, burntTxTextField, + utxoTextField, compensationIssuanceTxTextField, reimbursementIssuanceTxTextField, priceTextField, marketCapTextField; private ChangeListener priceChangeListener; private HyperlinkWithIcon hyperlinkWithIcon; @@ -106,6 +107,7 @@ public class BsqDashboardView extends ActivatableView implements totalLockedUpAmountTextField = FormBuilder.addTopLabelReadOnlyTextField(root, gridRow, columnIndex, Res.get("dao.wallet.dashboard.totalLockedUpAmount"), Layout.FIRST_ROW_AND_GROUP_DISTANCE).second; totalUnlockingAmountTextField = FormBuilder.addTopLabelReadOnlyTextField(root, ++gridRow, columnIndex, Res.get("dao.wallet.dashboard.totalUnlockingAmount")).second; totalUnlockedAmountTextField = FormBuilder.addTopLabelReadOnlyTextField(root, ++gridRow, columnIndex, Res.get("dao.wallet.dashboard.totalUnlockedAmount")).second; + totalConfiscatedAmountTextField = FormBuilder.addTopLabelReadOnlyTextField(root, ++gridRow, columnIndex, Res.get("dao.wallet.dashboard.totalConfiscatedAmount")).second; gridRow++; gridRow++; @@ -202,6 +204,7 @@ public class BsqDashboardView extends ActivatableView implements Coin totalLockedUpAmount = Coin.valueOf(daoFacade.getTotalLockupAmount()); Coin totalUnlockingAmount = Coin.valueOf(daoFacade.getTotalAmountOfUnLockingTxOutputs()); Coin totalUnlockedAmount = Coin.valueOf(daoFacade.getTotalAmountOfUnLockedTxOutputs()); + Coin totalConfiscatedAmount = Coin.valueOf(daoFacade.getTotalAmountOfConfiscatedTxOutputs()); Coin availableAmount = issuedAmountFromGenesis.add(issuedAmountFromCompRequests).subtract(burntFee); availableAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(availableAmount)); @@ -209,6 +212,7 @@ public class BsqDashboardView extends ActivatableView implements totalLockedUpAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(totalLockedUpAmount)); totalUnlockingAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(totalUnlockingAmount)); totalUnlockedAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(totalUnlockedAmount)); + totalConfiscatedAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(totalConfiscatedAmount)); allTxTextField.setText(String.valueOf(daoFacade.getTxs().size())); utxoTextField.setText(String.valueOf(daoFacade.getUnspentTxOutputs().size())); compensationIssuanceTxTextField.setText(String.valueOf(daoFacade.getNumIssuanceTransactions(IssuanceType.COMPENSATION)));