Search in sources :

Example 1 with TradeResultHandler

use of bisq.core.trade.handlers.TradeResultHandler 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();
        });
    }
}
Also used : Arbitrator(bisq.core.arbitration.Arbitrator) BtcWalletService(bisq.core.btc.wallet.BtcWalletService) TradeResultHandler(bisq.core.trade.handlers.TradeResultHandler) Transaction(org.bitcoinj.core.Transaction) ReadOnlyObjectProperty(javafx.beans.property.ReadOnlyObjectProperty) Coin(org.bitcoinj.core.Coin) Wallet(org.bitcoinj.wallet.Wallet) Inject(com.google.inject.Inject) Volume(bisq.core.monetary.Volume) PaymentAccountUtil(bisq.core.payment.PaymentAccountUtil) User(bisq.core.user.User) BalanceListener(bisq.core.btc.listeners.BalanceListener) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) OfferPayload(bisq.core.offer.OfferPayload) Res(bisq.core.locale.Res) CurrencyUtil(bisq.core.locale.CurrencyUtil) OfferDataModel(bisq.desktop.main.offer.OfferDataModel) Nullable(javax.annotation.Nullable) Popup(bisq.desktop.main.overlays.popups.Popup) Offer(bisq.core.offer.Offer) ObjectProperty(javafx.beans.property.ObjectProperty) FilterManager(bisq.core.filter.FilterManager) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) BisqEnvironment(bisq.core.app.BisqEnvironment) PaymentMethod(bisq.core.payment.payload.PaymentMethod) InsufficientMoneyException(org.bitcoinj.core.InsufficientMoneyException) BsqWalletService(bisq.core.btc.wallet.BsqWalletService) AccountAgeWitnessService(bisq.core.payment.AccountAgeWitnessService) PaymentAccount(bisq.core.payment.PaymentAccount) List(java.util.List) PriceFeedService(bisq.core.provider.price.PriceFeedService) AddressEntry(bisq.core.btc.AddressEntry) TradeWalletService(bisq.core.btc.wallet.TradeWalletService) TradeManager(bisq.core.trade.TradeManager) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Preferences(bisq.core.user.Preferences) Price(bisq.core.monetary.Price) FeeService(bisq.core.provider.fee.FeeService) Address(org.bitcoinj.core.Address) ObservableList(javafx.collections.ObservableList) Restrictions(bisq.core.btc.Restrictions) CoinUtil(bisq.core.util.CoinUtil) Coin(org.bitcoinj.core.Coin) Popup(bisq.desktop.main.overlays.popups.Popup)

Aggregations

BisqEnvironment (bisq.core.app.BisqEnvironment)1 Arbitrator (bisq.core.arbitration.Arbitrator)1 AddressEntry (bisq.core.btc.AddressEntry)1 Restrictions (bisq.core.btc.Restrictions)1 BalanceListener (bisq.core.btc.listeners.BalanceListener)1 BsqWalletService (bisq.core.btc.wallet.BsqWalletService)1 BtcWalletService (bisq.core.btc.wallet.BtcWalletService)1 TradeWalletService (bisq.core.btc.wallet.TradeWalletService)1 FilterManager (bisq.core.filter.FilterManager)1 CurrencyUtil (bisq.core.locale.CurrencyUtil)1 Res (bisq.core.locale.Res)1 Price (bisq.core.monetary.Price)1 Volume (bisq.core.monetary.Volume)1 Offer (bisq.core.offer.Offer)1 OfferPayload (bisq.core.offer.OfferPayload)1 AccountAgeWitnessService (bisq.core.payment.AccountAgeWitnessService)1 PaymentAccount (bisq.core.payment.PaymentAccount)1 PaymentAccountUtil (bisq.core.payment.PaymentAccountUtil)1 PaymentMethod (bisq.core.payment.payload.PaymentMethod)1 FeeService (bisq.core.provider.fee.FeeService)1