use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.
the class TakeOfferDataModel method onTakeOffer.
// /////////////////////////////////////////////////////////////////////////////////////////
// UI actions
// /////////////////////////////////////////////////////////////////////////////////////////
// errorMessageHandler is used only in the check availability phase. As soon we have a trade we write the error msg in the trade object as we want to
// have it persisted as well.
void onTakeOffer(TradeResultHandler tradeResultHandler) {
checkNotNull(txFeeFromFeeService, "txFeeFromFeeService must not be null");
checkNotNull(getTakerFee(), "takerFee must not be null");
Coin fundsNeededForTrade = getSecurityDeposit().add(txFeeFromFeeService).add(txFeeFromFeeService);
if (isBuyOffer())
fundsNeededForTrade = fundsNeededForTrade.add(amount.get());
if (filterManager.isCurrencyBanned(offer.getCurrencyCode())) {
new Popup<>().warning(Res.get("offerbook.warning.currencyBanned")).show();
} else if (filterManager.isPaymentMethodBanned(offer.getPaymentMethod())) {
new Popup<>().warning(Res.get("offerbook.warning.paymentMethodBanned")).show();
} else if (filterManager.isOfferIdBanned(offer.getId())) {
new Popup<>().warning(Res.get("offerbook.warning.offerBlocked")).show();
} else if (filterManager.isNodeAddressBanned(offer.getMakerNodeAddress())) {
new Popup<>().warning(Res.get("offerbook.warning.nodeBlocked")).show();
} else {
tradeManager.onTakeOffer(amount.get(), txFeeFromFeeService, getTakerFee(), isCurrencyForTakerFeeBtc(), tradePrice.getValue(), fundsNeededForTrade, offer, paymentAccount.getId(), useSavingsWallet, tradeResultHandler, errorMessage -> {
log.warn(errorMessage);
new Popup<>().warning(errorMessage).show();
});
}
}
use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.
the class WithdrawalView method onWithdraw.
// /////////////////////////////////////////////////////////////////////////////////////////
// UI handlers
// /////////////////////////////////////////////////////////////////////////////////////////
@FXML
public void onWithdraw() {
if (GUIUtil.isReadyForTxBroadcast(p2PService, walletsSetup)) {
try {
// We do not know sendersAmount if senderPaysFee is true. We repeat fee calculation after first attempt if senderPaysFee is true.
Transaction feeEstimationTransaction = walletService.getFeeEstimationTransactionForMultipleAddresses(fromAddresses, amountAsCoin);
if (feeExcluded && feeEstimationTransaction != null) {
sendersAmount = amountAsCoin.add(feeEstimationTransaction.getFee());
feeEstimationTransaction = walletService.getFeeEstimationTransactionForMultipleAddresses(fromAddresses, sendersAmount);
}
checkNotNull(feeEstimationTransaction, "feeEstimationTransaction must not be null");
Coin fee = feeEstimationTransaction.getFee();
sendersAmount = feeExcluded ? amountAsCoin.add(fee) : amountAsCoin;
Coin receiverAmount = feeExcluded ? amountAsCoin : amountAsCoin.subtract(fee);
if (areInputsValid()) {
int txSize = feeEstimationTransaction.bitcoinSerialize().length;
log.info("Fee for tx with size {}: {} " + Res.getBaseCurrencyCode() + "", txSize, fee.toPlainString());
if (receiverAmount.isPositive()) {
double feePerByte = CoinUtil.getFeePerByte(fee, txSize);
double kb = txSize / 1000d;
new Popup<>().headLine(Res.get("funds.withdrawal.confirmWithdrawalRequest")).confirmation(Res.get("shared.sendFundsDetailsWithFee", formatter.formatCoinWithCode(sendersAmount), withdrawFromTextField.getText(), withdrawToTextField.getText(), formatter.formatCoinWithCode(fee), feePerByte, kb, formatter.formatCoinWithCode(receiverAmount))).actionButtonText(Res.get("shared.yes")).onAction(() -> doWithdraw(sendersAmount, fee, new FutureCallback<Transaction>() {
@Override
public void onSuccess(@javax.annotation.Nullable Transaction transaction) {
if (transaction != null) {
log.debug("onWithdraw onSuccess tx ID:" + transaction.getHashAsString());
} else {
log.error("onWithdraw transaction is null");
}
List<Trade> trades = new ArrayList<>(tradeManager.getTradableList());
trades.stream().filter(Trade::isPayoutPublished).forEach(trade -> {
walletService.getAddressEntry(trade.getId(), AddressEntry.Context.TRADE_PAYOUT).ifPresent(addressEntry -> {
if (walletService.getBalanceForAddress(addressEntry.getAddress()).isZero())
tradeManager.addTradeToClosedTrades(trade);
});
});
}
@Override
public void onFailure(@NotNull Throwable t) {
log.error("onWithdraw onFailure");
}
})).closeButtonText(Res.get("shared.cancel")).show();
} else {
new Popup<>().warning(Res.get("portfolio.pending.step5_buyer.amountTooLow")).show();
}
}
} catch (InsufficientFundsException e) {
new Popup<>().warning(Res.get("funds.withdrawal.warn.amountExceeds") + "\n\nError message:\n" + e.getMessage()).show();
} catch (Throwable e) {
e.printStackTrace();
log.error(e.toString());
new Popup<>().warning(e.toString()).show();
}
} else {
GUIUtil.showNotReadyForTxBroadcastPopups(p2PService, walletsSetup);
}
}
use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.
the class MakeProposalView method publishProposal.
private void publishProposal(ProposalType type) {
try {
Proposal proposal = createProposal(type);
Transaction tx = Objects.requireNonNull(proposal).getTx();
Coin miningFee = Objects.requireNonNull(tx).getFee();
int txSize = tx.bitcoinSerialize().length;
validateInputs();
new Popup<>().headLine(Res.get("dao.proposal.create.confirm")).confirmation(Res.get("dao.proposal.create.confirm.info", bsqFormatter.formatCoinWithCode(ProposalConsensus.getCreateCompensationRequestFee(readableBsqBlockChain)), btcFormatter.formatCoinWithCode(miningFee), CoinUtil.getFeePerByte(miningFee, txSize), (txSize / 1000d))).actionButtonText(Res.get("shared.yes")).onAction(() -> {
proposalCollectionsService.publishProposal(proposal, new FutureCallback<Transaction>() {
@Override
public void onSuccess(@Nullable Transaction transaction) {
proposalDisplay.clearForm();
proposalTypeComboBox.getSelectionModel().clearSelection();
new Popup<>().confirmation(Res.get("dao.tx.published.success")).show();
}
@Override
public void onFailure(@NotNull Throwable t) {
log.error(t.toString());
new Popup<>().warning(t.toString()).show();
}
});
}).closeButtonText(Res.get("shared.cancel")).show();
} catch (InsufficientMoneyException e) {
BSFormatter formatter = e instanceof InsufficientBsqException ? bsqFormatter : btcFormatter;
new Popup<>().warning(Res.get("dao.proposal.create.missingFunds", formatter.formatCoinWithCode(e.missing))).show();
} catch (CompensationAmountException e) {
new Popup<>().warning(Res.get("validation.bsq.amountBelowMinAmount", bsqFormatter.formatCoinWithCode(e.required))).show();
} catch (TransactionVerificationException | WalletException e) {
log.error(e.toString());
e.printStackTrace();
new Popup<>().warning(e.toString()).show();
} catch (ChangeBelowDustException e) {
// TODO
e.printStackTrace();
}
}
use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.
the class WesternUnionForm method addFormForAddAccount.
@Override
public void addFormForAddAccount() {
gridRowFrom = gridRow + 1;
Tuple3<Label, ComboBox, ComboBox> tuple3 = FormBuilder.addLabelComboBoxComboBox(gridPane, ++gridRow, Res.get("payment.country"));
// noinspection unchecked,unchecked,unchecked
ComboBox<Region> regionComboBox = tuple3.second;
regionComboBox.setPromptText(Res.get("payment.select.region"));
regionComboBox.setConverter(new StringConverter<Region>() {
@Override
public String toString(Region region) {
return region.name;
}
@Override
public Region fromString(String s) {
return null;
}
});
regionComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllRegions()));
// noinspection unchecked,unchecked,unchecked
ComboBox<Country> countryComboBox = tuple3.third;
countryComboBox.setVisibleRowCount(15);
countryComboBox.setDisable(true);
countryComboBox.setPromptText(Res.get("payment.select.country"));
countryComboBox.setConverter(new StringConverter<Country>() {
@Override
public String toString(Country country) {
return country.name + " (" + country.code + ")";
}
@Override
public Country fromString(String s) {
return null;
}
});
countryComboBox.setOnAction(e -> {
Country selectedItem = countryComboBox.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
getCountryBasedPaymentAccount().setCountry(selectedItem);
String countryCode = selectedItem.code;
TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(countryCode);
paymentAccount.setSingleTradeCurrency(currency);
currencyComboBox.setDisable(false);
currencyComboBox.getSelectionModel().select(currency);
updateFromInputs();
applyIsStateRequired();
cityInputTextField.setText("");
stateInputTextField.setText("");
}
});
regionComboBox.setOnAction(e -> {
Region selectedItem = regionComboBox.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
countryComboBox.setDisable(false);
countryComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllCountriesForRegion(selectedItem)));
}
});
// noinspection unchecked
currencyComboBox = FormBuilder.addLabelComboBox(gridPane, ++gridRow, Res.getWithCol("shared.currency")).second;
currencyComboBox.setPromptText(Res.get("list.currency.select"));
currencyComboBox.setItems(FXCollections.observableArrayList(CurrencyUtil.getAllSortedFiatCurrencies()));
currencyComboBox.setOnAction(e -> {
TradeCurrency selectedItem = currencyComboBox.getSelectionModel().getSelectedItem();
FiatCurrency defaultCurrency = CurrencyUtil.getCurrencyByCountryCode(countryComboBox.getSelectionModel().getSelectedItem().code);
if (!defaultCurrency.equals(selectedItem)) {
new Popup<>().warning(Res.get("payment.foreign.currency")).actionButtonText(Res.get("shared.yes")).onAction(() -> {
paymentAccount.setSingleTradeCurrency(selectedItem);
autoFillNameTextField();
}).closeButtonText(Res.get("payment.restore.default")).onClose(() -> currencyComboBox.getSelectionModel().select(defaultCurrency)).show();
} else {
paymentAccount.setSingleTradeCurrency(selectedItem);
autoFillNameTextField();
}
});
currencyComboBox.setConverter(new StringConverter<TradeCurrency>() {
@Override
public String toString(TradeCurrency currency) {
return currency.getNameAndCode();
}
@Override
public TradeCurrency fromString(String string) {
return null;
}
});
currencyComboBox.setDisable(true);
holderNameInputTextField = FormBuilder.addLabelInputTextField(gridPane, ++gridRow, Res.getWithCol("payment.account.fullName")).second;
holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
westernUnionAccountPayload.setHolderName(newValue);
updateFromInputs();
});
holderNameInputTextField.setValidator(inputValidator);
cityInputTextField = FormBuilder.addLabelInputTextField(gridPane, ++gridRow, Res.get("payment.account.city")).second;
cityInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
westernUnionAccountPayload.setCity(newValue);
updateFromInputs();
});
final Tuple2<Label, InputTextField> tuple2 = FormBuilder.addLabelInputTextField(gridPane, ++gridRow, Res.get("payment.account.state"));
stateLabel = tuple2.first;
stateInputTextField = tuple2.second;
stateInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
westernUnionAccountPayload.setState(newValue);
updateFromInputs();
});
applyIsStateRequired();
emailInputTextField = FormBuilder.addLabelInputTextField(gridPane, ++gridRow, Res.get("payment.email")).second;
emailInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
westernUnionAccountPayload.setEmail(newValue);
updateFromInputs();
});
emailInputTextField.setValidator(emailValidator);
addLimitations();
addAccountNameTextFieldWithAutoFillCheckBox();
updateFromInputs();
}
use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.
the class MainView method createFooter.
private AnchorPane createFooter() {
// line
Separator separator = new Separator();
separator.setId("footer-pane-line");
separator.setPrefHeight(1);
setLeftAnchor(separator, 0d);
setRightAnchor(separator, 0d);
setTopAnchor(separator, 0d);
// BTC
Label btcInfoLabel = new AutoTooltipLabel();
btcInfoLabel.setId("footer-pane");
btcInfoLabel.textProperty().bind(model.btcInfo);
ProgressBar blockchainSyncIndicator = new ProgressBar(-1);
blockchainSyncIndicator.setPrefWidth(120);
blockchainSyncIndicator.setMaxHeight(10);
blockchainSyncIndicator.progressProperty().bind(model.btcSyncProgress);
model.walletServiceErrorMsg.addListener((ov, oldValue, newValue) -> {
if (newValue != null) {
btcInfoLabel.setId("splash-error-state-msg");
btcInfoLabel.getStyleClass().add("error-text");
if (btcNetworkWarnMsgPopup == null) {
btcNetworkWarnMsgPopup = new Popup<>().warning(newValue);
btcNetworkWarnMsgPopup.show();
}
} else {
btcInfoLabel.setId("footer-pane");
if (btcNetworkWarnMsgPopup != null)
btcNetworkWarnMsgPopup.hide();
}
});
model.btcSyncProgress.addListener((ov, oldValue, newValue) -> {
if ((double) newValue >= 1) {
blockchainSyncIndicator.setVisible(false);
blockchainSyncIndicator.setManaged(false);
}
});
HBox blockchainSyncBox = new HBox();
blockchainSyncBox.setSpacing(10);
blockchainSyncBox.setAlignment(Pos.CENTER);
blockchainSyncBox.getChildren().addAll(btcInfoLabel, blockchainSyncIndicator);
setLeftAnchor(blockchainSyncBox, 10d);
setBottomAnchor(blockchainSyncBox, 7d);
// version
versionLabel = new AutoTooltipLabel();
versionLabel.setId("footer-pane");
versionLabel.setTextAlignment(TextAlignment.CENTER);
versionLabel.setAlignment(Pos.BASELINE_CENTER);
versionLabel.setText("v" + Version.VERSION);
root.widthProperty().addListener((ov, oldValue, newValue) -> {
versionLabel.setLayoutX(((double) newValue - versionLabel.getWidth()) / 2);
});
setBottomAnchor(versionLabel, 7d);
model.newVersionAvailableProperty.addListener((observable, oldValue, newValue) -> {
versionLabel.getStyleClass().removeAll("version-new", "version");
if (newValue) {
versionLabel.getStyleClass().add("version-new");
versionLabel.setOnMouseClicked(e -> model.openDownloadWindow());
versionLabel.setText("v" + Version.VERSION + " " + Res.get("mainView.version.update"));
} else {
versionLabel.getStyleClass().add("version");
versionLabel.setOnMouseClicked(null);
versionLabel.setText("v" + Version.VERSION);
}
});
// P2P Network
Label p2PNetworkLabel = new AutoTooltipLabel();
p2PNetworkLabel.setId("footer-pane");
setRightAnchor(p2PNetworkLabel, 33d);
setBottomAnchor(p2PNetworkLabel, 7d);
p2PNetworkLabel.textProperty().bind(model.p2PNetworkInfo);
ImageView p2PNetworkIcon = new ImageView();
setRightAnchor(p2PNetworkIcon, 10d);
setBottomAnchor(p2PNetworkIcon, 7d);
p2PNetworkIcon.setOpacity(0.4);
p2PNetworkIcon.idProperty().bind(model.p2PNetworkIconId);
p2PNetworkLabel.idProperty().bind(model.p2pNetworkLabelId);
model.p2pNetworkWarnMsg.addListener((ov, oldValue, newValue) -> {
if (newValue != null) {
p2PNetworkWarnMsgPopup = new Popup<>().warning(newValue);
p2PNetworkWarnMsgPopup.show();
} else if (p2PNetworkWarnMsgPopup != null) {
p2PNetworkWarnMsgPopup.hide();
}
});
model.bootstrapComplete.addListener((observable, oldValue, newValue) -> {
p2PNetworkIcon.setOpacity(1);
});
return new AnchorPane(separator, blockchainSyncBox, versionLabel, p2PNetworkLabel, p2PNetworkIcon) {
{
setId("footer-pane");
setMinHeight(30);
setMaxHeight(30);
}
};
}
Aggregations