mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-20 10:22:18 +01:00
Check if BSQ wallet is funded when using BSQ for trade fee
This commit is contained in:
parent
c8c900e190
commit
f885716a3d
@ -1176,6 +1176,8 @@ popup.warning.noPriceFeedAvailable=There is no price feed available for that cur
|
||||
popup.warning.sendMsgFailed=Sending message to your trading partner failed.\nPlease try again and if it continue to fail report a bug.
|
||||
popup.warning.insufficientBtcFundsForBsqTx=You don''t have sufficient BTC funds for paying the tx fee for that BSQ transaction.\n\
|
||||
Please fund your BTC wallet to be able to transfer BSQ.\nMissing funds: {0}
|
||||
popup.warning.insufficientBsqFundsForBtcFeePayment=You don''t have sufficient BSQ funds for paying the tx fee in BSQ.\n\
|
||||
You can pay the fee in BTC or you need to fund your BSQ wallet.\nMissing BSQ funds: {0}
|
||||
|
||||
popup.info.securityDepositInfo=To ensure that both traders follow the trade protocol they need to pay a security deposit.\n\nThe deposit will stay in your local trading wallet until the offer gets accepted by another trader.\nIt will be refunded to you after the trade has successfully completed.\n\nPlease note that you need to keep you application running if you have an open offer.\nWhen another trader wants to take your offer it requires that your application is online and able to react.\nBe sure that you have standby mode deactivated as that would disconnect your client from the network (standby of the monitor is not a problem).
|
||||
|
||||
@ -1305,6 +1307,7 @@ navigation.funds.depositFunds=\"Funds/Deposit funds\"
|
||||
navigation.settings.preferences=\"Settings/Preferences\"
|
||||
navigation.funds.transactions=\"Funds/Transactions\"
|
||||
navigation.support=\"Support\"
|
||||
navigation.dao.wallet.receive=\"DAO/BSQ Wallet/Receive\"
|
||||
|
||||
|
||||
####################################################################
|
||||
|
@ -27,16 +27,10 @@ public class ProvidersRepository {
|
||||
if (providers.isEmpty()) {
|
||||
if (useLocalhostForP2P) {
|
||||
// If we run in localhost mode we don't have the tor node running, so we need a clearnet host
|
||||
// providers = "http://95.85.11.205:8080/";
|
||||
|
||||
// Use localhost for using a locally running priceprovider
|
||||
// providers = "http://localhost:8080/, http://51.15.47.83:8080/";
|
||||
providers = "http://localhost:8080/";
|
||||
// Use localhost for using a locally running provider
|
||||
providers = "http://localhost:8080/, 146.185.175.243:8080/";
|
||||
} else {
|
||||
// TODO atm we dont have it running as HS...
|
||||
// providers = "http://localhost:8080/, http://51.15.47.83:8080/";
|
||||
providers = "http://localhost:8080/";
|
||||
//providers = "http://t4wlzy7l6k4hnolg.onion/, http://g27szt7aw2vrtowe.onion/";
|
||||
providers = "http://kijf4m2pqd54tbck.onion/";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,8 @@ import io.bisq.common.util.Utilities;
|
||||
import io.bisq.core.btc.AddressEntry;
|
||||
import io.bisq.core.btc.Restrictions;
|
||||
import io.bisq.core.btc.listeners.BalanceListener;
|
||||
import io.bisq.core.btc.wallet.BsqBalanceListener;
|
||||
import io.bisq.core.btc.wallet.BsqWalletService;
|
||||
import io.bisq.core.btc.wallet.BtcWalletService;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
@ -68,7 +70,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
class CreateOfferDataModel extends ActivatableDataModel {
|
||||
private final OpenOfferManager openOfferManager;
|
||||
private final BtcWalletService walletService;
|
||||
private final BtcWalletService btcWalletService;
|
||||
private BsqWalletService bsqWalletService;
|
||||
private final Preferences preferences;
|
||||
private final User user;
|
||||
private final KeyRing keyRing;
|
||||
@ -81,7 +84,8 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
private final AddressEntry addressEntry;
|
||||
private Coin makerFee;
|
||||
private boolean isCurrencyForMakerFeeBtc;
|
||||
private final BalanceListener balanceListener;
|
||||
private final BalanceListener btcBalanceListener;
|
||||
private final BsqBalanceListener bsqBalanceListener;
|
||||
private final SetChangeListener<PaymentAccount> paymentAccountsChangeListener;
|
||||
|
||||
private Offer.Direction direction;
|
||||
@ -91,7 +95,8 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
private final StringProperty tradeCurrencyCode = new SimpleStringProperty();
|
||||
private final StringProperty btcCode = new SimpleStringProperty();
|
||||
|
||||
private final BooleanProperty isWalletFunded = new SimpleBooleanProperty();
|
||||
private final BooleanProperty isBtcWalletFunded = new SimpleBooleanProperty();
|
||||
final BooleanProperty allowBsqFeePayment = new SimpleBooleanProperty(false);
|
||||
private final BooleanProperty useMarketBasedPrice = new SimpleBooleanProperty();
|
||||
//final BooleanProperty isMainNet = new SimpleBooleanProperty();
|
||||
//final BooleanProperty isFeeFromFundingTxSufficient = new SimpleBooleanProperty();
|
||||
@ -123,11 +128,13 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
CreateOfferDataModel(OpenOfferManager openOfferManager, BtcWalletService walletService,
|
||||
Preferences preferences, User user, KeyRing keyRing, P2PService p2PService, PriceFeedService priceFeedService,
|
||||
CreateOfferDataModel(OpenOfferManager openOfferManager, BtcWalletService btcWalletService, BsqWalletService bsqWalletService,
|
||||
Preferences preferences, User user, KeyRing keyRing, P2PService p2PService,
|
||||
PriceFeedService priceFeedService,
|
||||
FeeService feeService, BSFormatter formatter) {
|
||||
this.openOfferManager = openOfferManager;
|
||||
this.walletService = walletService;
|
||||
this.btcWalletService = btcWalletService;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.preferences = preferences;
|
||||
this.user = user;
|
||||
this.keyRing = keyRing;
|
||||
@ -140,13 +147,13 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
UUID.randomUUID().toString() + "-" +
|
||||
Version.VERSION.replace(".", "");
|
||||
shortOfferId = Utilities.getShortId(offerId);
|
||||
addressEntry = walletService.getOrCreateAddressEntry(offerId, AddressEntry.Context.OFFER_FUNDING);
|
||||
addressEntry = btcWalletService.getOrCreateAddressEntry(offerId, AddressEntry.Context.OFFER_FUNDING);
|
||||
|
||||
useMarketBasedPrice.set(preferences.isUsePercentageBasedPrice());
|
||||
buyerSecurityDeposit.set(preferences.getBuyerSecurityDepositAsCoin());
|
||||
sellerSecurityDeposit = Restrictions.SELLER_SECURITY_DEPOSIT;
|
||||
|
||||
balanceListener = new BalanceListener(getAddressEntry().getAddress()) {
|
||||
btcBalanceListener = new BalanceListener(getAddressEntry().getAddress()) {
|
||||
@Override
|
||||
public void onBalanceChanged(Coin balance, Transaction tx) {
|
||||
updateBalance();
|
||||
@ -175,6 +182,10 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
}
|
||||
};
|
||||
|
||||
bsqBalanceListener = (availableBalance, unverifiedBalance) -> {
|
||||
updateBalance();
|
||||
};
|
||||
|
||||
paymentAccountsChangeListener = change -> fillPaymentAccounts();
|
||||
isCurrencyForMakerFeeBtc = preferences.getPayFeeInBtc();
|
||||
}
|
||||
@ -205,13 +216,15 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
}
|
||||
|
||||
private void addListeners() {
|
||||
walletService.addBalanceListener(balanceListener);
|
||||
btcWalletService.addBalanceListener(btcBalanceListener);
|
||||
bsqWalletService.addBsqBalanceListener(bsqBalanceListener);
|
||||
user.getPaymentAccountsAsObservable().addListener(paymentAccountsChangeListener);
|
||||
}
|
||||
|
||||
|
||||
private void removeListeners() {
|
||||
walletService.removeBalanceListener(balanceListener);
|
||||
btcWalletService.removeBalanceListener(btcBalanceListener);
|
||||
bsqWalletService.removeBsqBalanceListener(bsqBalanceListener);
|
||||
user.getPaymentAccountsAsObservable().removeListener(paymentAccountsChangeListener);
|
||||
}
|
||||
|
||||
@ -272,7 +285,8 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
|
||||
calculateVolume();
|
||||
calculateTotalToPay();
|
||||
|
||||
updateBalance();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -367,7 +381,7 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
bankId,
|
||||
acceptedBanks,
|
||||
Version.VERSION,
|
||||
walletService.getLastBlockSeenHeight(),
|
||||
btcWalletService.getLastBlockSeenHeight(),
|
||||
txFeeFromFeeService.value,
|
||||
makerFee.value,
|
||||
isCurrencyForMakerFeeBtc,
|
||||
@ -441,7 +455,7 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
void fundFromSavingsWallet() {
|
||||
this.useSavingsWallet = true;
|
||||
updateBalance();
|
||||
if (!isWalletFunded.get()) {
|
||||
if (!isBtcWalletFunded.get()) {
|
||||
this.useSavingsWallet = false;
|
||||
updateBalance();
|
||||
}
|
||||
@ -576,9 +590,9 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
}
|
||||
|
||||
private void updateBalance() {
|
||||
Coin tradeWalletBalance = walletService.getBalanceForAddress(addressEntry.getAddress());
|
||||
Coin tradeWalletBalance = btcWalletService.getBalanceForAddress(addressEntry.getAddress());
|
||||
if (useSavingsWallet) {
|
||||
Coin savingWalletBalance = walletService.getSavingWalletBalance();
|
||||
Coin savingWalletBalance = btcWalletService.getSavingWalletBalance();
|
||||
totalAvailableBalance = savingWalletBalance.add(tradeWalletBalance);
|
||||
if (totalToPayAsCoin.get() != null) {
|
||||
if (totalAvailableBalance.compareTo(totalToPayAsCoin.get()) > 0)
|
||||
@ -598,9 +612,9 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
|
||||
log.debug("missingCoin " + missingCoin.get().toFriendlyString());
|
||||
|
||||
isWalletFunded.set(isBalanceSufficient(balance.get()));
|
||||
isBtcWalletFunded.set(isBalanceSufficient(balance.get()));
|
||||
//noinspection PointlessBooleanExpression,ConstantConditions
|
||||
if (totalToPayAsCoin.get() != null && isWalletFunded.get() && walletFundedNotification == null && !DevEnv.DEV_MODE) {
|
||||
if (totalToPayAsCoin.get() != null && isBtcWalletFunded.get() && walletFundedNotification == null && !DevEnv.DEV_MODE) {
|
||||
walletFundedNotification = new Notification()
|
||||
.headLine(Res.get("notification.walletUpdate.headline"))
|
||||
.notification(Res.get("notification.walletUpdate.msg", formatter.formatCoinWithCode(totalToPayAsCoin.get())))
|
||||
@ -608,6 +622,14 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
|
||||
walletFundedNotification.show();
|
||||
}
|
||||
updateAllowBsqFeePayment();
|
||||
}
|
||||
|
||||
void updateAllowBsqFeePayment() {
|
||||
if (makerFee != null && bsqWalletService.getAvailableBalance() != null)
|
||||
allowBsqFeePayment.set(bsqWalletService.getAvailableBalance().compareTo(makerFee) >= 0);
|
||||
else
|
||||
allowBsqFeePayment.set(true); //TODO shoudl it be false by default?
|
||||
}
|
||||
|
||||
private boolean isBalanceSufficient(Coin balance) {
|
||||
@ -630,8 +652,8 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
}
|
||||
|
||||
public void swapTradeToSavings() {
|
||||
walletService.swapTradeEntryToAvailableEntry(offerId, AddressEntry.Context.OFFER_FUNDING);
|
||||
walletService.swapTradeEntryToAvailableEntry(offerId, AddressEntry.Context.RESERVED_FOR_TRADE);
|
||||
btcWalletService.swapTradeEntryToAvailableEntry(offerId, AddressEntry.Context.OFFER_FUNDING);
|
||||
btcWalletService.swapTradeEntryToAvailableEntry(offerId, AddressEntry.Context.RESERVED_FOR_TRADE);
|
||||
}
|
||||
|
||||
private void fillPaymentAccounts() {
|
||||
@ -723,8 +745,8 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
return btcCode;
|
||||
}
|
||||
|
||||
ReadOnlyBooleanProperty getIsWalletFunded() {
|
||||
return isWalletFunded;
|
||||
ReadOnlyBooleanProperty getIsBtcWalletFunded() {
|
||||
return isBtcWalletFunded;
|
||||
}
|
||||
|
||||
ReadOnlyBooleanProperty getUseMarketBasedPrice() {
|
||||
@ -754,4 +776,8 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
public boolean getCurrencyForMakerFeeBtc() {
|
||||
return isCurrencyForMakerFeeBtc;
|
||||
}
|
||||
|
||||
public Coin getBsqBalance() {
|
||||
return bsqWalletService.getAvailableBalance();
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,9 @@ import io.bisq.gui.main.account.AccountView;
|
||||
import io.bisq.gui.main.account.content.arbitratorselection.ArbitratorSelectionView;
|
||||
import io.bisq.gui.main.account.content.fiataccounts.FiatAccountsView;
|
||||
import io.bisq.gui.main.account.settings.AccountSettingsView;
|
||||
import io.bisq.gui.main.dao.DaoView;
|
||||
import io.bisq.gui.main.dao.wallet.BsqWalletView;
|
||||
import io.bisq.gui.main.dao.wallet.receive.BsqReceiveView;
|
||||
import io.bisq.gui.main.funds.FundsView;
|
||||
import io.bisq.gui.main.funds.withdrawal.WithdrawalView;
|
||||
import io.bisq.gui.main.offer.OfferView;
|
||||
@ -47,10 +50,7 @@ import io.bisq.gui.main.overlays.windows.OfferDetailsWindow;
|
||||
import io.bisq.gui.main.overlays.windows.QRCodeWindow;
|
||||
import io.bisq.gui.main.portfolio.PortfolioView;
|
||||
import io.bisq.gui.main.portfolio.openoffer.OpenOffersView;
|
||||
import io.bisq.gui.util.BSFormatter;
|
||||
import io.bisq.gui.util.GUIUtil;
|
||||
import io.bisq.gui.util.Layout;
|
||||
import io.bisq.gui.util.Transitions;
|
||||
import io.bisq.gui.util.*;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.event.ActionEvent;
|
||||
@ -88,6 +88,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
private final Transitions transitions;
|
||||
private final OfferDetailsWindow offerDetailsWindow;
|
||||
private final BSFormatter btcFormatter;
|
||||
private final BsqFormatter bsqFormatter;
|
||||
|
||||
private ScrollPane scrollPane;
|
||||
private GridPane gridPane;
|
||||
@ -135,13 +136,14 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
|
||||
@Inject
|
||||
private CreateOfferView(CreateOfferViewModel model, Navigation navigation, Transitions transitions,
|
||||
OfferDetailsWindow offerDetailsWindow, BSFormatter btcFormatter) {
|
||||
OfferDetailsWindow offerDetailsWindow, BSFormatter btcFormatter, BsqFormatter bsqFormatter) {
|
||||
super(model);
|
||||
|
||||
this.navigation = navigation;
|
||||
this.transitions = transitions;
|
||||
this.offerDetailsWindow = offerDetailsWindow;
|
||||
this.btcFormatter = btcFormatter;
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -205,12 +207,6 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
onPaymentAccountsComboBoxSelected();
|
||||
|
||||
balanceTextField.setTargetAmount(model.dataModel.totalToPayAsCoinProperty().get());
|
||||
|
||||
// if (DevFlags.STRESS_TEST_MODE)
|
||||
// UserThread.runAfter(this::onShowPayFundsScreen, 200, TimeUnit.MILLISECONDS);
|
||||
|
||||
updateMarketPriceAvailable();
|
||||
updateFeeToggleButtons(model.dataModel.getCurrencyForMakerFeeBtc());
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,6 +266,14 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
placeOfferButton.setText(Res.get("createOffer.placeOfferButton", Res.get("shared.sell")));
|
||||
nextButton.setId("sell-button");
|
||||
}
|
||||
|
||||
updateMarketPriceAvailable();
|
||||
if (!model.dataModel.allowBsqFeePayment.get() && !model.dataModel.getCurrencyForMakerFeeBtc()) {
|
||||
showInsufficientBsqFundsForBtcFeePaymentPopup();
|
||||
updateFeeToggleButtons(true);
|
||||
} else {
|
||||
updateFeeToggleButtons(model.dataModel.getCurrencyForMakerFeeBtc() || !model.dataModel.allowBsqFeePayment.get());
|
||||
}
|
||||
}
|
||||
|
||||
// called form parent as the view does not get notified when the tab is closed
|
||||
@ -295,30 +299,43 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
|
||||
private void onPlaceOffer() {
|
||||
if (model.isBootstrapped()) {
|
||||
if (model.hasAcceptedArbitrators()) {
|
||||
Offer offer = model.createAndGetOffer();
|
||||
//noinspection PointlessBooleanExpression
|
||||
if (!DevEnv.DEV_MODE)
|
||||
offerDetailsWindow.onPlaceOffer(() ->
|
||||
model.onPlaceOffer(offer, offerDetailsWindow::hide))
|
||||
.show(offer);
|
||||
else
|
||||
model.onPlaceOffer(offer, () -> {
|
||||
});
|
||||
model.dataModel.updateAllowBsqFeePayment();
|
||||
if (model.dataModel.allowBsqFeePayment.get() || model.dataModel.getCurrencyForMakerFeeBtc()) {
|
||||
if (model.hasAcceptedArbitrators()) {
|
||||
Offer offer = model.createAndGetOffer();
|
||||
//noinspection PointlessBooleanExpression
|
||||
if (!DevEnv.DEV_MODE)
|
||||
offerDetailsWindow.onPlaceOffer(() ->
|
||||
model.onPlaceOffer(offer, offerDetailsWindow::hide))
|
||||
.show(offer);
|
||||
else
|
||||
model.onPlaceOffer(offer, () -> {
|
||||
});
|
||||
} else {
|
||||
new Popup<>().headLine(Res.get("popup.warning.noArbitratorSelected.headline"))
|
||||
.instruction(Res.get("popup.warning.noArbitratorSelected.msg"))
|
||||
.actionButtonTextWithGoTo("navigation.arbitratorSelection")
|
||||
.onAction(() -> {
|
||||
navigation.setReturnPath(navigation.getCurrentPath());
|
||||
navigation.navigateTo(MainView.class, AccountView.class, AccountSettingsView.class, ArbitratorSelectionView.class);
|
||||
}).show();
|
||||
}
|
||||
} else {
|
||||
new Popup<>().headLine(Res.get("popup.warning.noArbitratorSelected.headline"))
|
||||
.instruction(Res.get("popup.warning.noArbitratorSelected.msg"))
|
||||
.actionButtonTextWithGoTo("navigation.arbitratorSelection")
|
||||
.onAction(() -> {
|
||||
navigation.setReturnPath(navigation.getCurrentPath());
|
||||
navigation.navigateTo(MainView.class, AccountView.class, AccountSettingsView.class, ArbitratorSelectionView.class);
|
||||
}).show();
|
||||
showInsufficientBsqFundsForBtcFeePaymentPopup();
|
||||
}
|
||||
} else {
|
||||
new Popup<>().information(Res.get("popup.warning.notFullyConnected")).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void showInsufficientBsqFundsForBtcFeePaymentPopup() {
|
||||
new Popup<>().warning(Res.get("popup.warning.insufficientBsqFundsForBtcFeePayment",
|
||||
bsqFormatter.formatCoinWithCode(model.dataModel.getMakerFee().subtract(model.dataModel.getBsqBalance()))))
|
||||
.actionButtonTextWithGoTo("navigation.dao.wallet.receive")
|
||||
.onAction(() -> navigation.navigateTo(MainView.class, DaoView.class, BsqWalletView.class, BsqReceiveView.class))
|
||||
.show();
|
||||
}
|
||||
|
||||
private void onShowPayFundsScreen() {
|
||||
model.onShowPayFundsScreen();
|
||||
|
||||
@ -473,11 +490,11 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
buyerSecurityDepositInputTextField.validationResultProperty().bind(model.buyerSecurityDepositValidationResult);
|
||||
|
||||
// funding
|
||||
fundingHBox.visibleProperty().bind(model.dataModel.getIsWalletFunded().not().and(model.showPayFundsScreenDisplayed));
|
||||
fundingHBox.managedProperty().bind(model.dataModel.getIsWalletFunded().not().and(model.showPayFundsScreenDisplayed));
|
||||
fundingHBox.visibleProperty().bind(model.dataModel.getIsBtcWalletFunded().not().and(model.showPayFundsScreenDisplayed));
|
||||
fundingHBox.managedProperty().bind(model.dataModel.getIsBtcWalletFunded().not().and(model.showPayFundsScreenDisplayed));
|
||||
waitingForFundsLabel.textProperty().bind(model.waitingForFundsText);
|
||||
placeOfferButton.visibleProperty().bind(model.dataModel.getIsWalletFunded().and(model.showPayFundsScreenDisplayed));
|
||||
placeOfferButton.managedProperty().bind(model.dataModel.getIsWalletFunded().and(model.showPayFundsScreenDisplayed));
|
||||
placeOfferButton.visibleProperty().bind(model.dataModel.getIsBtcWalletFunded().and(model.showPayFundsScreenDisplayed));
|
||||
placeOfferButton.managedProperty().bind(model.dataModel.getIsBtcWalletFunded().and(model.showPayFundsScreenDisplayed));
|
||||
placeOfferButton.disableProperty().bind(model.isPlaceOfferButtonDisabled);
|
||||
cancelButton2.disableProperty().bind(model.cancelButtonDisabled);
|
||||
|
||||
@ -880,7 +897,18 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
payFeeInBsqButton.setId("toggle-price-left");
|
||||
payFeeInBsqButton.setToggleGroup(feeToggleGroup);
|
||||
payFeeInBsqButton.selectedProperty().addListener((ov, oldValue, newValue) -> {
|
||||
updateFeeToggleButtons(!newValue);
|
||||
if (newValue && model.dataModel.allowBsqFeePayment.get())
|
||||
updateFeeToggleButtons(false);
|
||||
else
|
||||
updateFeeToggleButtons(true);
|
||||
});
|
||||
payFeeInBsqButton.setOnAction(ev -> {
|
||||
if (model.dataModel.allowBsqFeePayment.get()) {
|
||||
updateFeeToggleButtons(false);
|
||||
} else {
|
||||
showInsufficientBsqFundsForBtcFeePaymentPopup();
|
||||
updateFeeToggleButtons(true);
|
||||
}
|
||||
});
|
||||
|
||||
payFeeInBtcButton = new ToggleButton("BTC");
|
||||
@ -1037,7 +1065,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
|
||||
cancelButton2 = addButton(gridPane, ++gridRow, Res.get("shared.cancel"));
|
||||
cancelButton2.setOnAction(e -> {
|
||||
if (model.dataModel.getIsWalletFunded().get()) {
|
||||
if (model.dataModel.getIsBtcWalletFunded().get()) {
|
||||
new Popup<>().warning(Res.get("createOffer.warnCancelOffer"))
|
||||
.closeButtonText(Res.get("shared.no"))
|
||||
.actionButtonText(Res.get("shared.yesCancel"))
|
||||
@ -1241,19 +1269,23 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
|
||||
private void updateFeeToggleButtons(boolean btcSelected) {
|
||||
model.setCurrencyForMakerFeeBtc(btcSelected);
|
||||
if (btcSelected || model.dataModel.allowBsqFeePayment.get()) {
|
||||
if (!payFeeInBtcButton.isSelected() && btcSelected)
|
||||
payFeeInBtcButton.setSelected(true);
|
||||
if (payFeeInBsqButton.isSelected() && !btcSelected)
|
||||
payFeeInBsqButton.setSelected(false);
|
||||
|
||||
if (!payFeeInBtcButton.isSelected() && btcSelected)
|
||||
payFeeInBtcButton.setSelected(true);
|
||||
if (payFeeInBsqButton.isSelected() && !btcSelected)
|
||||
payFeeInBsqButton.setSelected(false);
|
||||
payFeeInBtcButton.setMouseTransparent(btcSelected);
|
||||
payFeeInBsqButton.setMouseTransparent(!btcSelected);
|
||||
|
||||
payFeeInBtcButton.setMouseTransparent(btcSelected);
|
||||
payFeeInBsqButton.setMouseTransparent(!btcSelected);
|
||||
|
||||
payFeeInBtcButton.setStyle(btcSelected ?
|
||||
"-fx-background-color: -bs-blue-transparent" : "-fx-background-color: -bs-very-light-grey");
|
||||
payFeeInBsqButton.setStyle(!btcSelected ?
|
||||
"-fx-background-color: -bs-blue-transparent" : "-fx-background-color: -bs-very-light-grey");
|
||||
payFeeInBtcButton.setStyle(btcSelected ?
|
||||
"-fx-background-color: -bs-blue-transparent" : "-fx-background-color: -bs-very-light-grey");
|
||||
payFeeInBsqButton.setStyle(!btcSelected ?
|
||||
"-fx-background-color: -bs-blue-transparent" : "-fx-background-color: -bs-very-light-grey");
|
||||
} else {
|
||||
log.error("Must not happen that we get not allowBsqFeePayment and btcSelected called. allowBsqFeePayment={}, btcSelected={}",
|
||||
model.dataModel.allowBsqFeePayment.get(), btcSelected);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -465,7 +465,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
||||
dataModel.getBuyerSecurityDeposit().addListener(securityDepositAsCoinListener);
|
||||
|
||||
// dataModel.feeFromFundingTxProperty.addListener(feeFromFundingTxListener);
|
||||
dataModel.getIsWalletFunded().addListener(isWalletFundedListener);
|
||||
dataModel.getIsBtcWalletFunded().addListener(isWalletFundedListener);
|
||||
|
||||
priceFeedService.currenciesUpdateFlagProperty().addListener(currenciesUpdateListener);
|
||||
}
|
||||
@ -487,7 +487,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
||||
dataModel.getBuyerSecurityDeposit().removeListener(securityDepositAsCoinListener);
|
||||
|
||||
//dataModel.feeFromFundingTxProperty.removeListener(feeFromFundingTxListener);
|
||||
dataModel.getIsWalletFunded().removeListener(isWalletFundedListener);
|
||||
dataModel.getIsBtcWalletFunded().removeListener(isWalletFundedListener);
|
||||
|
||||
if (offer != null && errorMessageListener != null)
|
||||
offer.getErrorMessageProperty().removeListener(errorMessageListener);
|
||||
@ -589,7 +589,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
||||
|
||||
boolean fundFromSavingsWallet() {
|
||||
dataModel.fundFromSavingsWallet();
|
||||
if (dataModel.getIsWalletFunded().get()) {
|
||||
if (dataModel.getIsBtcWalletFunded().get()) {
|
||||
updateButtonDisableState();
|
||||
return true;
|
||||
} else {
|
||||
@ -937,7 +937,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
||||
errorMessage.get() != null ||
|
||||
showTransactionPublishedScreen.get()) {
|
||||
waitingForFundsText.set("");
|
||||
} else if (dataModel.getIsWalletFunded().get()) {
|
||||
} else if (dataModel.getIsBtcWalletFunded().get()) {
|
||||
waitingForFundsText.set("");
|
||||
/* if (dataModel.isFeeFromFundingTxSufficient.get()) {
|
||||
spinnerInfoText.set("");
|
||||
@ -965,7 +965,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
||||
isNextButtonDisabled.set(!inputDataValid);
|
||||
// boolean notSufficientFees = dataModel.isWalletFunded.get() && dataModel.isMainNet.get() && !dataModel.isFeeFromFundingTxSufficient.get();
|
||||
//isPlaceOfferButtonDisabled.set(createOfferRequested || !inputDataValid || notSufficientFees);
|
||||
isPlaceOfferButtonDisabled.set(createOfferRequested || !inputDataValid || !dataModel.getIsWalletFunded().get());
|
||||
isPlaceOfferButtonDisabled.set(createOfferRequested || !inputDataValid || !dataModel.getIsBtcWalletFunded().get());
|
||||
}
|
||||
|
||||
private void stopTimeoutTimer() {
|
||||
|
Loading…
Reference in New Issue
Block a user