use of io.bitsquare.gui.main.overlays.notifications.Notification in project bitsquare by bitsquare.
the class TakeOfferDataModel method updateBalance.
void updateBalance() {
Coin tradeWalletBalance = walletService.getBalanceForAddress(addressEntry.getAddress());
if (useSavingsWallet) {
Coin savingWalletBalance = walletService.getSavingWalletBalance();
totalAvailableBalance = savingWalletBalance.add(tradeWalletBalance);
if (totalToPayAsCoin.get() != null) {
if (totalAvailableBalance.compareTo(totalToPayAsCoin.get()) > 0)
balance.set(totalToPayAsCoin.get());
else
balance.set(totalAvailableBalance);
}
} else {
balance.set(tradeWalletBalance);
}
if (totalToPayAsCoin.get() != null) {
missingCoin.set(totalToPayAsCoin.get().subtract(balance.get()));
if (missingCoin.get().isNegative())
missingCoin.set(Coin.ZERO);
}
log.debug("missingCoin " + missingCoin.get().toFriendlyString());
isWalletFunded.set(isBalanceSufficient(balance.get()));
if (totalToPayAsCoin.get() != null && isWalletFunded.get() && walletFundedNotification == null && !DevFlags.DEV_MODE) {
walletFundedNotification = new Notification().headLine("Trading wallet update").notification("Your trading wallet is sufficiently funded.\n" + "Amount: " + formatter.formatCoinWithCode(totalToPayAsCoin.get())).autoClose();
walletFundedNotification.show();
}
}
use of io.bitsquare.gui.main.overlays.notifications.Notification in project bitsquare by bitsquare.
the class CreateOfferDataModel method updateBalance.
void updateBalance() {
Coin tradeWalletBalance = walletService.getBalanceForAddress(addressEntry.getAddress());
if (useSavingsWallet) {
Coin savingWalletBalance = walletService.getSavingWalletBalance();
totalAvailableBalance = savingWalletBalance.add(tradeWalletBalance);
if (totalToPayAsCoin.get() != null) {
if (totalAvailableBalance.compareTo(totalToPayAsCoin.get()) > 0)
balance.set(totalToPayAsCoin.get());
else
balance.set(totalAvailableBalance);
}
} else {
balance.set(tradeWalletBalance);
}
if (totalToPayAsCoin.get() != null) {
missingCoin.set(totalToPayAsCoin.get().subtract(balance.get()));
if (missingCoin.get().isNegative())
missingCoin.set(Coin.ZERO);
}
log.debug("missingCoin " + missingCoin.get().toFriendlyString());
isWalletFunded.set(isBalanceSufficient(balance.get()));
if (totalToPayAsCoin.get() != null && isWalletFunded.get() && walletFundedNotification == null && !DevFlags.DEV_MODE) {
walletFundedNotification = new Notification().headLine("Trading wallet update").notification("Your trading wallet is sufficiently funded.\n" + "Amount: " + formatter.formatCoinWithCode(totalToPayAsCoin.get())).autoClose();
walletFundedNotification.show();
}
}
use of io.bitsquare.gui.main.overlays.notifications.Notification in project bitsquare by bitsquare.
the class TakeOfferView method onShowPayFundsScreen.
private void onShowPayFundsScreen() {
model.onShowPayFundsScreen();
amountTextField.setMouseTransparent(true);
amountTextField.setFocusTraversable(false);
priceTextField.setMouseTransparent(true);
priceAsPercentageTextField.setMouseTransparent(true);
volumeTextField.setMouseTransparent(true);
balanceTextField.setTargetAmount(model.dataModel.totalToPayAsCoin.get());
if (!DevFlags.DEV_MODE) {
String key = "securityDepositInfo";
new Popup().backgroundInfo("To ensure that both traders follow the trade protocol they need to pay a security deposit.\n\n" + "The deposit will stay in your local trading wallet until the offer gets accepted by another trader.\n" + "It will be refunded to you after the trade has successfully completed.").actionButtonText("Visit FAQ web page").onAction(() -> GUIUtil.openWebPage("https://bitsquare.io/faq#6")).closeButtonText("I understand").dontShowAgainId(key, preferences).show();
key = "takeOfferFundWalletInfo";
String tradeAmountText = model.isSeller() ? "- Trade amount: " + model.getAmount() + "\n" : "";
new Popup().headLine("Fund your trade").instruction("You need to deposit " + model.totalToPay.get() + " for taking this offer.\n\n" + "The amount is the sum of:\n" + tradeAmountText + "- Security deposit: " + model.getSecurityDeposit() + "\n" + "- Trading fee: " + model.getTakerFee() + "\n" + "- Bitcoin mining fee: " + model.getNetworkFee() + "\n\n" + "You can choose between two options when funding your trade:\n" + "- Use your Bitsquare wallet (convenient, but transactions may be linkable) OR\n" + "- Transfer from an external wallet (potentially more private)\n\n" + "You will see all funding options and details after closing this popup.").dontShowAgainId(key, preferences).show();
}
nextButton.setVisible(false);
offerAvailabilityBusyAnimation.stop();
cancelButton1.setVisible(false);
cancelButton1.setOnAction(null);
cancelButton2.setVisible(true);
waitingForFundsBusyAnimation.play();
payFundsPane.setVisible(true);
totalToPayLabel.setVisible(true);
totalToPayInfoIconLabel.setVisible(true);
totalToPayTextField.setVisible(true);
addressLabel.setVisible(true);
addressTextField.setVisible(true);
qrCodeImageView.setVisible(true);
balanceLabel.setVisible(true);
balanceTextField.setVisible(true);
setupTotalToPayInfoIconLabel();
if (model.dataModel.isWalletFunded.get()) {
if (walletFundedNotification == null) {
walletFundedNotification = new Notification().headLine("Trading wallet update").notification("Your trading wallet was already sufficiently funded from an earlier take offer attempt.\n" + "Amount: " + formatter.formatCoinWithCode(model.dataModel.totalToPayAsCoin.get())).autoClose();
walletFundedNotification.show();
}
}
final byte[] imageBytes = QRCode.from(getBitcoinURI()).withSize(98, // code has 41 elements 8 px is border with 98 we get double scale and min. border
98).to(ImageType.PNG).stream().toByteArray();
Image qrImage = new Image(new ByteArrayInputStream(imageBytes));
qrCodeImageView.setImage(qrImage);
}
use of io.bitsquare.gui.main.overlays.notifications.Notification in project bitsquare by bitsquare.
the class BuyerStep5View method addContent.
///////////////////////////////////////////////////////////////////////////////////////////
// Content
///////////////////////////////////////////////////////////////////////////////////////////
@Override
protected void addContent() {
addTitledGroupBg(gridPane, gridRow, 4, "Summary of completed trade ", 0);
Tuple2<Label, TextField> btcTradeAmountPair = addLabelTextField(gridPane, gridRow, getBtcTradeAmountLabel(), model.getTradeVolume(), Layout.FIRST_ROW_DISTANCE);
btcTradeAmountLabel = btcTradeAmountPair.first;
Tuple2<Label, TextField> fiatTradeAmountPair = addLabelTextField(gridPane, ++gridRow, getFiatTradeAmountLabel(), model.getFiatVolume());
fiatTradeAmountLabel = fiatTradeAmountPair.first;
addLabelTextField(gridPane, ++gridRow, "Total fees paid:", model.getTotalFees());
addLabelTextField(gridPane, ++gridRow, "Refunded security deposit:", model.getSecurityDeposit());
addTitledGroupBg(gridPane, ++gridRow, 2, "Withdraw your bitcoins", Layout.GROUP_DISTANCE);
addLabelTextField(gridPane, gridRow, "Amount to withdraw:", model.getPayoutAmount(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
withdrawAddressTextField = addLabelInputTextField(gridPane, ++gridRow, "Withdraw to address:").second;
HBox hBox = new HBox();
hBox.setSpacing(10);
useSavingsWalletButton = new Button("Move funds to Bitsquare wallet");
useSavingsWalletButton.setDefaultButton(false);
Label label = new Label("OR");
label.setPadding(new Insets(5, 0, 0, 0));
withdrawToExternalWalletButton = new Button("Withdraw to external wallet");
withdrawToExternalWalletButton.setDefaultButton(false);
hBox.getChildren().addAll(useSavingsWalletButton, label, withdrawToExternalWalletButton);
GridPane.setRowIndex(hBox, ++gridRow);
GridPane.setColumnIndex(hBox, 1);
GridPane.setMargin(hBox, new Insets(15, 10, 0, 0));
gridPane.getChildren().add(hBox);
useSavingsWalletButton.setOnAction(e -> {
model.dataModel.walletService.swapTradeEntryToAvailableEntry(trade.getId(), AddressEntry.Context.TRADE_PAYOUT);
handleTradeCompleted();
model.dataModel.tradeManager.addTradeToClosedTrades(trade);
});
withdrawToExternalWalletButton.setOnAction(e -> reviewWithdrawal());
if (DevFlags.DEV_MODE) {
withdrawAddressTextField.setText("mjYhQYSbET2bXJDyCdNqYhqSye5QX2WHPz");
} else {
String key = "tradeCompleted" + trade.getId();
if (!DevFlags.DEV_MODE && preferences.showAgain(key)) {
preferences.dontShowAgain(key, true);
new Notification().headLine("Trade completed").notification("You can withdraw your funds now to your external Bitcoin wallet or transfer it to the Bitsquare wallet.").autoClose().show();
}
}
}
Aggregations