Skip to content

Commit

Permalink
Show bond info, cleanups, handle non-BSQ funds
Browse files Browse the repository at this point in the history
  • Loading branch information
ManfredKarrer committed Jul 12, 2018
1 parent cb6de8c commit 4e5126c
Show file tree
Hide file tree
Showing 12 changed files with 340 additions and 198 deletions.
1 change: 1 addition & 0 deletions src/main/java/bisq/desktop/main/dao/DaoView.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void initialize() {
bondingTab = new Tab(Res.get("dao.tab.bonding"));
proposalsTab.setClosable(false);
votingTab.setClosable(false);
bondingTab.setClosable(false);
root.getTabs().addAll(proposalsTab, votingTab, bondingTab);

if (!BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq() || !DevEnv.isDaoPhase2Activated()) {
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/bisq/desktop/main/dao/bonding/BondingView.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import bisq.desktop.main.MainView;
import bisq.desktop.main.dao.DaoView;
import bisq.desktop.main.dao.bonding.dashboard.BondingDashboardView;
import bisq.desktop.main.dao.bonding.lockup.LockupBSQView;
import bisq.desktop.main.dao.bonding.unlock.UnlockBSQView;
import bisq.desktop.main.dao.bonding.lockup.LockupView;
import bisq.desktop.main.dao.bonding.unlock.UnlockView;

import bisq.core.locale.Res;

Expand Down Expand Up @@ -83,9 +83,9 @@ public void initialize() {
dashboard = new MenuItem(navigation, toggleGroup, Res.get("shared.dashboard"),
BondingDashboardView.class, AwesomeIcon.DASHBOARD, baseNavPath);
lockupBSQ = new MenuItem(navigation, toggleGroup, Res.get("dao.bonding.menuItem.lockupBSQ"),
LockupBSQView.class, AwesomeIcon.LIST_UL, baseNavPath);
LockupView.class, AwesomeIcon.LIST_UL, baseNavPath);
unlockBSQ = new MenuItem(navigation, toggleGroup, Res.get("dao.bonding.menuItem.unlockBSQ"),
UnlockBSQView.class, AwesomeIcon.LIST_UL, baseNavPath);
UnlockView.class, AwesomeIcon.LIST_UL, baseNavPath);
leftVBox.getChildren().addAll(dashboard, lockupBSQ, unlockBSQ);
}

Expand All @@ -100,7 +100,7 @@ protected void activate() {
if (viewPath.size() == 3 && viewPath.indexOf(BondingView.class) == 2 ||
viewPath.size() == 2 && viewPath.indexOf(DaoView.class) == 1) {
if (selectedViewClass == null)
selectedViewClass = LockupBSQView.class;
selectedViewClass = LockupView.class;

loadView(selectedViewClass);

Expand All @@ -124,7 +124,7 @@ private void loadView(Class<? extends View> viewClass) {
content.getChildren().setAll(view.getRoot());

if (view instanceof BondingDashboardView) dashboard.setSelected(true);
else if (view instanceof LockupBSQView) lockupBSQ.setSelected(true);
else if (view instanceof UnlockBSQView) unlockBSQ.setSelected(true);
else if (view instanceof LockupView) lockupBSQ.setSelected(true);
else if (view instanceof UnlockView) unlockBSQ.setSelected(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.bonding.lockup.LockupBSQView"
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.bonding.lockup.LockupView"
hgap="5.0" vgap="5.0"
AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0"
AnchorPane.rightAnchor="25.0" AnchorPane.topAnchor="20.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.btc.wallet.WalletsSetup;
import bisq.core.dao.DaoFacade;
import bisq.core.dao.state.ext.Param;
import bisq.core.dao.bonding.BondingConsensus;
import bisq.core.locale.Res;
import bisq.core.util.BsqFormatter;
import bisq.core.util.validation.IntegerValidator;

import bisq.network.p2p.P2PService;

Expand All @@ -56,7 +57,7 @@
import static bisq.desktop.util.FormBuilder.addTitledGroupBg;

@FxmlView
public class LockupBSQView extends ActivatableView<GridPane, Void> implements BsqBalanceListener {
public class LockupView extends ActivatableView<GridPane, Void> implements BsqBalanceListener {
private final BsqWalletService bsqWalletService;
private final WalletsSetup walletsSetup;
private final P2PService p2PService;
Expand All @@ -65,6 +66,7 @@ public class LockupBSQView extends ActivatableView<GridPane, Void> implements Bs
private final BsqBalanceUtil bsqBalanceUtil;
private final BsqValidator bsqValidator;
private final DaoFacade daoFacade;
private final IntegerValidator integerValidator;

private int gridRow = 0;
private InputTextField amountInputTextField;
Expand All @@ -78,14 +80,14 @@ public class LockupBSQView extends ActivatableView<GridPane, Void> implements Bs
///////////////////////////////////////////////////////////////////////////////////////////

@Inject
private LockupBSQView(BsqWalletService bsqWalletService,
WalletsSetup walletsSetup,
P2PService p2PService,
BsqFormatter bsqFormatter,
Navigation navigation,
BsqBalanceUtil bsqBalanceUtil,
BsqValidator bsqValidator,
DaoFacade daoFacade) {
private LockupView(BsqWalletService bsqWalletService,
WalletsSetup walletsSetup,
P2PService p2PService,
BsqFormatter bsqFormatter,
Navigation navigation,
BsqBalanceUtil bsqBalanceUtil,
BsqValidator bsqValidator,
DaoFacade daoFacade) {
this.bsqWalletService = bsqWalletService;
this.walletsSetup = walletsSetup;
this.p2PService = p2PService;
Expand All @@ -94,6 +96,15 @@ private LockupBSQView(BsqWalletService bsqWalletService,
this.bsqBalanceUtil = bsqBalanceUtil;
this.bsqValidator = bsqValidator;
this.daoFacade = daoFacade;


integerValidator = new IntegerValidator();
// In the UI we don't allow 0 as that would mean that the tx gets spent
// in the same block as the unspent tx and we don't support unconfirmed txs in the DAO. Technically though 0
// works as well.
integerValidator.setMinValue(BondingConsensus.getMinLockTime());
// Max value is max of a short int as we use only 2 bytes in the opReturn for the lockTime
integerValidator.setMaxValue(BondingConsensus.getMaxLockTime());
}

@Override
Expand All @@ -105,19 +116,18 @@ public void initialize() {

amountInputTextField = addLabelInputTextField(root, gridRow, Res.get("dao.bonding.lock.amount"),
Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
amountInputTextField.setPromptText(Res.get("dao.bonding.lock.setAmount", Restrictions.getMinNonDustOutput().value));
amountInputTextField.setPromptText(Res.get("dao.bonding.lock.setAmount", bsqFormatter.formatCoinWithCode(Restrictions.getMinNonDustOutput())));
amountInputTextField.setValidator(bsqValidator);
timeInputTextField = addLabelInputTextField(root, ++gridRow, Res.get("dao.bonding.lock.time"), Layout.GRID_GAP).second;
timeInputTextField.setPromptText(Res.get("dao.bonding.lock.setTime",
Param.LOCK_TIME_MIN.getDefaultValue(), Param.LOCK_TIME_MAX.getDefaultValue()));
// TODO: add some int validator
// timeInputTextField.setValidator(bsqValidator);
String.valueOf(BondingConsensus.getMinLockTime()), String.valueOf(BondingConsensus.getMaxLockTime())));
timeInputTextField.setValidator(integerValidator);

focusOutListener = (observable, oldValue, newValue) -> {
if (!newValue)
onUpdateBalances(bsqWalletService.getAvailableBalance(),
bsqWalletService.getAvailableNonBsqBalance(),
bsqWalletService.getPendingBalance(),
bsqWalletService.getUnverifiedBalance(),
bsqWalletService.getLockedForVotingBalance(),
bsqWalletService.getLockedInBondsBalance(),
bsqWalletService.getUnlockingBondsBalance());
Expand Down Expand Up @@ -145,6 +155,7 @@ public void initialize() {
errorMessage -> new Popup<>().warning(errorMessage.toString()).show()
);
amountInputTextField.setText("");
timeInputTextField.setText("");
})
.closeButtonText(Res.get("shared.cancel"))
.show();
Expand Down Expand Up @@ -176,7 +187,7 @@ protected void activate() {
bsqWalletService.addBsqBalanceListener(this);
onUpdateBalances(bsqWalletService.getAvailableBalance(),
bsqWalletService.getAvailableNonBsqBalance(),
bsqWalletService.getPendingBalance(),
bsqWalletService.getUnverifiedBalance(),
bsqWalletService.getLockedForVotingBalance(),
bsqWalletService.getLockedInBondsBalance(),
bsqWalletService.getUnlockingBondsBalance());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import static com.google.common.base.Preconditions.checkNotNull;

@Data
class LockedBsqTxListItem {
class LockedTxListItem {
private final Transaction transaction;
private final BsqWalletService bsqWalletService;
private final BtcWalletService btcWalletService;
Expand All @@ -64,13 +64,13 @@ class LockedBsqTxListItem {
private TxConfidenceListener txConfidenceListener;
private boolean issuanceTx;

LockedBsqTxListItem(Transaction transaction,
BsqWalletService bsqWalletService,
BtcWalletService btcWalletService,
DaoFacade daoFacade,
StateService stateService,
Date date,
BsqFormatter bsqFormatter) {
LockedTxListItem(Transaction transaction,
BsqWalletService bsqWalletService,
BtcWalletService btcWalletService,
DaoFacade daoFacade,
StateService stateService,
Date date,
BsqFormatter bsqFormatter) {
this.transaction = transaction;
this.bsqWalletService = bsqWalletService;
this.btcWalletService = btcWalletService;
Expand Down Expand Up @@ -132,6 +132,7 @@ public void cleanup() {
bsqWalletService.removeTxConfidenceListener(txConfidenceListener);
}

// TODO SQ use daoFacade
public boolean isSpent() {
Optional<TxOutput> optionalTxOutput = stateService.getLockupTxOutput(txId);
if (!optionalTxOutput.isPresent())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.bonding.unlock.UnlockBSQView"
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.bonding.unlock.UnlockView"
hgap="5.0" vgap="5.0"
AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0"
AnchorPane.rightAnchor="25.0" AnchorPane.topAnchor="20.0"
Expand Down
Loading

0 comments on commit 4e5126c

Please sign in to comment.