diff --git a/src/main/java/bisq/desktop/main/dao/bonding/lockup/LockupView.java b/src/main/java/bisq/desktop/main/dao/bonding/lockup/LockupView.java index f889cbb01b3..2e26def51da 100644 --- a/src/main/java/bisq/desktop/main/dao/bonding/lockup/LockupView.java +++ b/src/main/java/bisq/desktop/main/dao/bonding/lockup/LockupView.java @@ -109,7 +109,6 @@ private LockupView(BsqWalletService bsqWalletService, @Override public void initialize() { - // TODO: Show balance locked up in bonds gridRow = bsqBalanceUtil.addGroup(root, gridRow); addTitledGroupBg(root, ++gridRow, 4, Res.get("dao.bonding.lock.lockBSQ"), Layout.GROUP_DISTANCE); @@ -129,7 +128,7 @@ public void initialize() { bsqWalletService.getAvailableNonBsqBalance(), bsqWalletService.getUnverifiedBalance(), bsqWalletService.getLockedForVotingBalance(), - bsqWalletService.getLockedInBondsBalance(), + bsqWalletService.getLockupBondsBalance(), bsqWalletService.getUnlockingBondsBalance()); }; @@ -189,7 +188,7 @@ protected void activate() { bsqWalletService.getAvailableNonBsqBalance(), bsqWalletService.getUnverifiedBalance(), bsqWalletService.getLockedForVotingBalance(), - bsqWalletService.getLockedInBondsBalance(), + bsqWalletService.getLockupBondsBalance(), bsqWalletService.getUnlockingBondsBalance()); } @@ -205,7 +204,7 @@ public void onUpdateBalances(Coin confirmedBalance, Coin availableNonBsqBalance, Coin pendingBalance, Coin lockedForVotingBalance, - Coin lockedInBondsBalance, + Coin lockupBondsBalance, Coin unlockingBondsBalance) { bsqValidator.setAvailableBalance(confirmedBalance); boolean isValid = bsqValidator.validate(amountInputTextField.getText()).isValid; diff --git a/src/main/java/bisq/desktop/main/dao/bonding/unlock/LockedTxListItem.java b/src/main/java/bisq/desktop/main/dao/bonding/unlock/LockupTxListItem.java similarity index 92% rename from src/main/java/bisq/desktop/main/dao/bonding/unlock/LockedTxListItem.java rename to src/main/java/bisq/desktop/main/dao/bonding/unlock/LockupTxListItem.java index dde2eaea57d..8af2df71d7d 100644 --- a/src/main/java/bisq/desktop/main/dao/bonding/unlock/LockedTxListItem.java +++ b/src/main/java/bisq/desktop/main/dao/bonding/unlock/LockupTxListItem.java @@ -45,7 +45,7 @@ import static com.google.common.base.Preconditions.checkNotNull; @Data -class LockedTxListItem { +class LockupTxListItem { private final Transaction transaction; private final BsqWalletService bsqWalletService; private final BtcWalletService btcWalletService; @@ -64,7 +64,7 @@ class LockedTxListItem { private TxConfidenceListener txConfidenceListener; private boolean issuanceTx; - LockedTxListItem(Transaction transaction, + LockupTxListItem(Transaction transaction, BsqWalletService bsqWalletService, BtcWalletService btcWalletService, DaoFacade daoFacade, @@ -89,8 +89,7 @@ class LockedTxListItem { stateService.getLockupTxOutput(transaction.getHashAsString()).ifPresent( out -> amount = Coin.valueOf(out.getValue())); - //TODO SQ: use DaoFacade instead of direct access to stateService - Optional opLockTime = stateService.getLockTime(transaction.getHashAsString()); + Optional opLockTime = daoFacade.getLockTime(transaction.getHashAsString()); lockTime = opLockTime.orElse(-1); button = new AutoTooltipButton(); @@ -125,7 +124,7 @@ private void updateConfidence(TransactionConfidence confidence, Tooltip tooltip) } } - public boolean isLockedAndUnspent() { + public boolean isLockupAndUnspent() { return !isSpent() && getTxType() == TxType.LOCKUP; } @@ -133,9 +132,8 @@ public void cleanup() { bsqWalletService.removeTxConfidenceListener(txConfidenceListener); } - // TODO SQ use daoFacade public boolean isSpent() { - Optional optionalTxOutput = stateService.getLockupTxOutput(txId); + Optional optionalTxOutput = daoFacade.getLockupTxOutput(txId); if (!optionalTxOutput.isPresent()) return true; diff --git a/src/main/java/bisq/desktop/main/dao/bonding/unlock/UnlockView.java b/src/main/java/bisq/desktop/main/dao/bonding/unlock/UnlockView.java index 16b1e7aa6b1..edc577aec69 100644 --- a/src/main/java/bisq/desktop/main/dao/bonding/unlock/UnlockView.java +++ b/src/main/java/bisq/desktop/main/dao/bonding/unlock/UnlockView.java @@ -82,7 +82,7 @@ @FxmlView public class UnlockView extends ActivatableView implements BsqBalanceListener, BlockListener { - private TableView tableView; + private TableView tableView; private final BsqWalletService bsqWalletService; private final BtcWalletService btcWalletService; @@ -98,10 +98,10 @@ public class UnlockView extends ActivatableView implements BsqBa private int gridRow = 0; private boolean synced; - private LockedTxListItem selectedItem; + private LockupTxListItem selectedItem; - private final ObservableList observableList = FXCollections.observableArrayList(); - private final FilteredList lockedTxs = new FilteredList<>(observableList); + private final ObservableList observableList = FXCollections.observableArrayList(); + private final FilteredList lockupTxs = new FilteredList<>(observableList); private ListChangeListener walletBsqTransactionsListener; private ChangeListener walletChainHeightListener; @@ -138,7 +138,6 @@ private UnlockView(BsqWalletService bsqWalletService, @Override public void initialize() { - // TODO: Show balance locked up in bonds gridRow = bsqBalanceUtil.addGroup(root, gridRow); tableView = new TableView<>(); @@ -149,7 +148,7 @@ public void initialize() { addLockTimeColumn(); addUnlockColumn(); - lockedTxs.setPredicate(LockedTxListItem::isLockedAndUnspent); + lockupTxs.setPredicate(LockupTxListItem::isLockupAndUnspent); walletBsqTransactionsListener = change -> updateList(); walletChainHeightListener = (observable, oldValue, newValue) -> onUpdateAnyChainHeight(); @@ -164,22 +163,22 @@ public void initialize() { } private void addTxIdColumn() { - TableColumn column = new AutoTooltipTableColumn<>(Res.get("shared.txId")); + TableColumn column = new AutoTooltipTableColumn<>(Res.get("shared.txId")); column.setCellValueFactory(item -> new ReadOnlyObjectWrapper<>(item.getValue())); column.setMinWidth(60); column.setCellFactory( - new Callback, TableCell>() { + new Callback, TableCell>() { @Override - public TableCell call(TableColumn column) { - return new TableCell() { + public TableCell call(TableColumn column) { + return new TableCell() { private HyperlinkWithIcon hyperlinkWithIcon; @Override - public void updateItem(final LockedTxListItem item, boolean empty) { + public void updateItem(final LockupTxListItem item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) { @@ -201,22 +200,22 @@ public void updateItem(final LockedTxListItem item, boolean empty) { } private void addAmountColumn() { - TableColumn column = + TableColumn column = new AutoTooltipTableColumn<>(Res.get("shared.amountWithCur", "BSQ")); column.setMinWidth(120); column.setMaxWidth(column.getMinWidth()); column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue())); - column.setCellFactory(new Callback, - TableCell>() { + column.setCellFactory(new Callback, + TableCell>() { @Override - public TableCell call(TableColumn column) { - return new TableCell() { + public TableCell call(TableColumn column) { + return new TableCell() { @Override - public void updateItem(final LockedTxListItem item, boolean empty) { + public void updateItem(final LockupTxListItem item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) { TxType txType = item.getTxType(); @@ -233,22 +232,22 @@ public void updateItem(final LockedTxListItem item, boolean empty) { } private void addLockTimeColumn() { - TableColumn column = + TableColumn column = new AutoTooltipTableColumn<>(Res.get("dao.bonding.unlock.time")); column.setMinWidth(120); column.setMaxWidth(column.getMinWidth()); column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue())); - column.setCellFactory(new Callback, - TableCell>() { + column.setCellFactory(new Callback, + TableCell>() { @Override - public TableCell call(TableColumn column) { - return new TableCell() { + public TableCell call(TableColumn column) { + return new TableCell() { @Override - public void updateItem(final LockedTxListItem item, boolean empty) { + public void updateItem(final LockupTxListItem item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) { TxType txType = item.getTxType(); @@ -265,23 +264,23 @@ public void updateItem(final LockedTxListItem item, boolean empty) { } private void addUnlockColumn() { - TableColumn unlockColumn = new TableColumn<>(); + TableColumn unlockColumn = new TableColumn<>(); unlockColumn.setMinWidth(130); unlockColumn.setMaxWidth(unlockColumn.getMinWidth()); unlockColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue())); - unlockColumn.setCellFactory(new Callback, - TableCell>() { + unlockColumn.setCellFactory(new Callback, + TableCell>() { @Override - public TableCell call(TableColumn column) { - return new TableCell() { + public TableCell call(TableColumn column) { + return new TableCell() { Button button; @Override - public void updateItem(final LockedTxListItem item, boolean empty) { + public void updateItem(final LockupTxListItem item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) { @@ -304,22 +303,20 @@ public void updateItem(final LockedTxListItem item, boolean empty) { }; } }); - unlockColumn.setComparator(Comparator.comparing(LockedTxListItem::getConfirmations)); + unlockColumn.setComparator(Comparator.comparing(LockupTxListItem::getConfirmations)); tableView.getColumns().add(unlockColumn); } private void onButtonClick() { if (GUIUtil.isReadyForTxBroadcast(p2PService, walletsSetup)) { - // TODO SQ use daoFacade - Optional lockedTxOutput = stateService.getLockupTxOutput(selectedItem.getTxId()); - if (!lockedTxOutput.isPresent()) { - log.warn("Locked output not found, txId = ", selectedItem.getTxId()); + Optional lockupTxOutput = daoFacade.getLockupTxOutput(selectedItem.getTxId()); + if (!lockupTxOutput.isPresent()) { + log.warn("Lockup output not found, txId = ", selectedItem.getTxId()); return; } - Coin unlockAmount = Coin.valueOf(lockedTxOutput.get().getValue()); - //TODO SQ: use DaoFacade instead of direct access to stateService - Optional opLockTime = stateService.getLockTime(selectedItem.getTxId()); + Coin unlockAmount = Coin.valueOf(lockupTxOutput.get().getValue()); + Optional opLockTime = daoFacade.getLockTime(selectedItem.getTxId()); int lockTime = opLockTime.isPresent() ? opLockTime.get() : -1; try { @@ -360,7 +357,7 @@ private void onButtonClick() { log.info("unlock tx: {}", selectedItem.getTxId()); } - private void openTxInBlockExplorer(LockedTxListItem item) { + private void openTxInBlockExplorer(LockupTxListItem item) { if (item.getTxId() != null) GUIUtil.openWebPage(preferences.getBsqBlockChainExplorer().txUrl + item.getTxId()); } @@ -373,14 +370,14 @@ protected void activate() { bsqWalletService.getAvailableNonBsqBalance(), bsqWalletService.getUnverifiedBalance(), bsqWalletService.getLockedForVotingBalance(), - bsqWalletService.getLockedInBondsBalance(), + bsqWalletService.getLockupBondsBalance(), bsqWalletService.getUnlockingBondsBalance()); bsqWalletService.getWalletTransactions().addListener(walletBsqTransactionsListener); bsqWalletService.addBsqBalanceListener(this); btcWalletService.getChainHeightProperty().addListener(walletChainHeightListener); - tableView.setItems(lockedTxs); + tableView.setItems(lockupTxs); daoFacade.addBlockListener(this); @@ -403,13 +400,13 @@ private void onUpdateAnyChainHeight() { } private void updateList() { - observableList.forEach(LockedTxListItem::cleanup); + observableList.forEach(LockupTxListItem::cleanup); // copy list to avoid ConcurrentModificationException final List walletTransactions = new ArrayList<>(bsqWalletService.getWalletTransactions()); - List items = walletTransactions.stream() + List items = walletTransactions.stream() .map(transaction -> { - return new LockedTxListItem(transaction, + return new LockupTxListItem(transaction, bsqWalletService, btcWalletService, daoFacade, @@ -426,13 +423,13 @@ protected void deactivate() { bsqBalanceUtil.deactivate(); bsqWalletService.removeBsqBalanceListener(this); - lockedTxs.predicateProperty().unbind(); + lockupTxs.predicateProperty().unbind(); bsqWalletService.getWalletTransactions().removeListener(walletBsqTransactionsListener); bsqWalletService.removeBsqBalanceListener(this); btcWalletService.getChainHeightProperty().removeListener(walletChainHeightListener); daoFacade.removeBlockListener(this); - observableList.forEach(LockedTxListItem::cleanup); + observableList.forEach(LockupTxListItem::cleanup); } @Override @@ -440,7 +437,7 @@ public void onUpdateBalances(Coin confirmedBalance, Coin availableNonBsqBalance, Coin pendingBalance, Coin lockedForVotingBalance, - Coin lockedInBondsBalance, + Coin lockupBondsBalance, Coin unlockingBondsBalance) { bsqValidator.setAvailableBalance(confirmedBalance); } diff --git a/src/main/java/bisq/desktop/main/dao/voting/active/ActiveBallotsView.java b/src/main/java/bisq/desktop/main/dao/voting/active/ActiveBallotsView.java index 8cc9fc33ca1..1bf63b9210b 100644 --- a/src/main/java/bisq/desktop/main/dao/voting/active/ActiveBallotsView.java +++ b/src/main/java/bisq/desktop/main/dao/voting/active/ActiveBallotsView.java @@ -115,7 +115,7 @@ protected void activate() { bsqWalletService.getAvailableNonBsqBalance(), bsqWalletService.getUnverifiedBalance(), bsqWalletService.getLockedForVotingBalance(), - bsqWalletService.getLockedInBondsBalance(), + bsqWalletService.getLockupBondsBalance(), bsqWalletService.getUnlockingBondsBalance()); voteButton.setOnAction(e -> onVote()); @@ -144,7 +144,7 @@ public void onUpdateBalances(Coin confirmedBalance, Coin availableNonBsqBalance, Coin pendingBalance, Coin lockedForVotingBalance, - Coin lockedInBondsBalance, + Coin lockupBondsBalance, Coin unlockingBondsBalance) { stakeInputTextField.setPromptText(Res.get("dao.proposal.myVote.stake.prompt", bsqFormatter.formatCoinWithCode(confirmedBalance))); diff --git a/src/main/java/bisq/desktop/main/dao/wallet/BsqBalanceUtil.java b/src/main/java/bisq/desktop/main/dao/wallet/BsqBalanceUtil.java index 51d8d23e520..3014f451d65 100644 --- a/src/main/java/bisq/desktop/main/dao/wallet/BsqBalanceUtil.java +++ b/src/main/java/bisq/desktop/main/dao/wallet/BsqBalanceUtil.java @@ -46,7 +46,7 @@ public class BsqBalanceUtil implements BsqBalanceListener { lockedInBondsBalanceTextField, totalBalanceTextField; // Displaying bond dashboard info - private TextField lockedAmountTextField, unlockingAmountTextField; + private TextField lockupAmountTextField, unlockingAmountTextField; @Inject private BsqBalanceUtil(BsqWalletService bsqWalletService, @@ -84,11 +84,11 @@ public int addGroup(GridPane gridPane, int gridRow) { } public int addBondBalanceGroup(GridPane gridPane, int gridRow) { - addTitledGroupBg(gridPane, ++gridRow, 2, Res.get("dao.bonding.dashboard.lockedHeadline"), Layout.GROUP_DISTANCE); + addTitledGroupBg(gridPane, ++gridRow, 2, Res.get("dao.bonding.dashboard.bondsHeadline"), Layout.GROUP_DISTANCE); - lockedAmountTextField = addLabelTextField(gridPane, gridRow, Res.get("dao.bonding.dashboard.lockedAmount"), + lockupAmountTextField = addLabelTextField(gridPane, gridRow, Res.get("dao.bonding.dashboard.lockupAmount"), Layout.FIRST_ROW_DISTANCE + Layout.GROUP_DISTANCE).second; - lockedAmountTextField.setMouseTransparent(false); + lockupAmountTextField.setMouseTransparent(false); unlockingAmountTextField = addLabelTextField(gridPane, ++gridRow, Res.get("dao.bonding.dashboard.unlockingAmount")).second; unlockingAmountTextField.setMouseTransparent(false); @@ -101,7 +101,7 @@ public void activate() { bsqWalletService.getAvailableNonBsqBalance(), bsqWalletService.getUnverifiedBalance(), bsqWalletService.getLockedForVotingBalance(), - bsqWalletService.getLockedInBondsBalance(), + bsqWalletService.getLockupBondsBalance(), bsqWalletService.getUnlockingBondsBalance()); bsqWalletService.addBsqBalanceListener(this); } @@ -116,24 +116,24 @@ public void onUpdateBalances(Coin availableBalance, Coin availableNonBsqBalance, Coin unverifiedBalance, Coin lockedForVotingBalance, - Coin lockedInBondsBalance, + Coin lockupBondsBalance, Coin unlockingBondsBalance) { availableBalanceTextField.setText(bsqFormatter.formatCoinWithCode(availableBalance)); availableNonBsqBalanceTextField.setText(bsqFormatter.formatBtcSatoshi(availableNonBsqBalance.value)); unverifiedBalanceTextField.setText(bsqFormatter.formatCoinWithCode(unverifiedBalance)); lockedForVoteBalanceTextField.setText(bsqFormatter.formatCoinWithCode(lockedForVotingBalance)); lockedInBondsBalanceTextField.setText(bsqFormatter.formatCoinWithCode( - lockedInBondsBalance.add(unlockingBondsBalance))); + lockupBondsBalance.add(unlockingBondsBalance))); - if (lockedAmountTextField != null && unlockingAmountTextField != null) { - lockedAmountTextField.setText(bsqFormatter.formatCoinWithCode(lockedInBondsBalance)); + if (lockupAmountTextField != null && unlockingAmountTextField != null) { + lockupAmountTextField.setText(bsqFormatter.formatCoinWithCode(lockupBondsBalance)); unlockingAmountTextField.setText(bsqFormatter.formatCoinWithCode(unlockingBondsBalance)); } final Coin total = availableBalance .add(unverifiedBalance) .add(lockedForVotingBalance) - .add(lockedInBondsBalance) + .add(lockupBondsBalance) .add(unlockingBondsBalance); totalBalanceTextField.setText(bsqFormatter.formatCoinWithCode(total)); } diff --git a/src/main/java/bisq/desktop/main/dao/wallet/dashboard/BsqDashboardView.java b/src/main/java/bisq/desktop/main/dao/wallet/dashboard/BsqDashboardView.java index 2fdafd4fb27..ed0c4e82277 100644 --- a/src/main/java/bisq/desktop/main/dao/wallet/dashboard/BsqDashboardView.java +++ b/src/main/java/bisq/desktop/main/dao/wallet/dashboard/BsqDashboardView.java @@ -167,7 +167,7 @@ private void updateWithBsqBlockChainData() { compRequestIssueAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(issuedAmountFromCompRequests)); Coin burntFee = Coin.valueOf(daoFacade.getTotalBurntFee()); - Coin totalLockedUpAmount = Coin.valueOf(daoFacade.getTotalLockedUpAmount()); + Coin totalLockedUpAmount = Coin.valueOf(daoFacade.getTotalLockupAmount()); Coin totalUnlockingAmount = Coin.valueOf(daoFacade.getTotalAmountOfUnLockingTxOutputs()); Coin totalUnlockedAmount = Coin.valueOf(daoFacade.getTotalAmountOfUnLockedTxOutputs()); Coin availableAmount = issuedAmountFromGenesis.add(issuedAmountFromCompRequests).subtract(burntFee); diff --git a/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java b/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java index 67e5ddcbab0..693fd9ebcaf 100644 --- a/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java +++ b/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java @@ -142,7 +142,7 @@ public void initialize() { bsqWalletService.getAvailableNonBsqBalance(), bsqWalletService.getUnverifiedBalance(), bsqWalletService.getLockedForVotingBalance(), - bsqWalletService.getLockedInBondsBalance(), + bsqWalletService.getLockupBondsBalance(), bsqWalletService.getUnlockingBondsBalance()); }; @@ -164,7 +164,7 @@ protected void activate() { bsqWalletService.getAvailableNonBsqBalance(), bsqWalletService.getUnverifiedBalance(), bsqWalletService.getLockedForVotingBalance(), - bsqWalletService.getLockedInBondsBalance(), + bsqWalletService.getLockupBondsBalance(), bsqWalletService.getUnlockingBondsBalance()); } @@ -182,7 +182,7 @@ public void onUpdateBalances(Coin availableBalance, Coin availableNonBsqBalance, Coin unverifiedBalance, Coin lockedForVotingBalance, - Coin lockedInBondsBalance, + Coin lockupBondsBalance, Coin unlockingBondsBalance) { bsqValidator.setAvailableBalance(availableBalance); boolean isValid = bsqAddressValidator.validate(receiversAddressInputTextField.getText()).isValid && @@ -215,7 +215,7 @@ private void addSendBsqGroup() { bsqWalletService.getAvailableNonBsqBalance(), bsqWalletService.getUnverifiedBalance(), bsqWalletService.getLockedForVotingBalance(), - bsqWalletService.getLockedInBondsBalance(), + bsqWalletService.getLockupBondsBalance(), bsqWalletService.getUnlockingBondsBalance()); }; diff --git a/src/main/java/bisq/desktop/main/dao/wallet/tx/BsqTxView.java b/src/main/java/bisq/desktop/main/dao/wallet/tx/BsqTxView.java index ee3a403b00a..fcbc943a49e 100644 --- a/src/main/java/bisq/desktop/main/dao/wallet/tx/BsqTxView.java +++ b/src/main/java/bisq/desktop/main/dao/wallet/tx/BsqTxView.java @@ -195,7 +195,7 @@ public void onUpdateBalances(Coin confirmedBalance, Coin availableNonBsqBalance, Coin pendingBalance, Coin lockedForVotingBalance, - Coin lockedInBondsBalance, + Coin lockupBondsBalance, Coin unlockingBondsBalance) { updateList(); }