Search in sources :

Example 1 with TradeManager

use of bisq.core.trade.TradeManager in project bisq-core by bisq-network.

the class TradeProtocol method cleanupTradableOnFault.

private void cleanupTradableOnFault() {
    final Trade.State state = trade.getState();
    log.warn("cleanupTradableOnFault tradeState=" + state);
    TradeManager tradeManager = processModel.getTradeManager();
    if (trade.isInPreparation()) {
        // no funds left. we just clean up the trade list
        tradeManager.removePreparedTrade(trade);
    } else if (!trade.isFundsLockedIn()) {
        if (processModel.getPreparedDepositTx() == null) {
            if (trade.isTakerFeePublished())
                tradeManager.addTradeToFailedTrades(trade);
            else
                tradeManager.addTradeToClosedTrades(trade);
        } else {
            log.error("We have already sent the prepared deposit tx to the peer but we did not received the reply " + "about the deposit tx nor saw it in the network. tradeId={}, tradeState={}", trade.getId(), trade.getState());
        }
    }
}
Also used : TradeManager(bisq.core.trade.TradeManager) MakerTrade(bisq.core.trade.MakerTrade) Trade(bisq.core.trade.Trade)

Example 2 with TradeManager

use of bisq.core.trade.TradeManager in project bisq-desktop by bisq-network.

the class MainViewModel method onBasicServicesInitialized.

private void onBasicServicesInitialized() {
    log.info("onBasicServicesInitialized");
    clock.start();
    PaymentMethod.onAllServicesInitialized();
    // disputeManager
    disputeManager.onAllServicesInitialized();
    disputeManager.getDisputesAsObservableList().addListener((ListChangeListener<Dispute>) change -> {
        change.next();
        onDisputesChangeListener(change.getAddedSubList(), change.getRemoved());
    });
    onDisputesChangeListener(disputeManager.getDisputesAsObservableList(), null);
    // tradeManager
    tradeManager.onAllServicesInitialized();
    tradeManager.getTradableList().addListener((ListChangeListener<Trade>) c -> updateBalance());
    tradeManager.getTradableList().addListener((ListChangeListener<Trade>) change -> onTradesChanged());
    onTradesChanged();
    // We handle the trade period here as we display a global popup if we reached dispute time
    tradesAndUIReady = EasyBind.combine(isSplashScreenRemoved, tradeManager.pendingTradesInitializedProperty(), (a, b) -> a && b);
    tradesAndUIReady.subscribe((observable, oldValue, newValue) -> {
        if (newValue)
            applyTradePeriodState();
    });
    tradeManager.setTakeOfferRequestErrorMessageHandler(errorMessage -> new Popup<>().warning(Res.get("popup.error.takeOfferRequestFailed", errorMessage)).show());
    // walletService
    btcWalletService.addBalanceListener(new BalanceListener() {

        @Override
        public void onBalanceChanged(Coin balance, Transaction tx) {
            updateBalance();
        }
    });
    openOfferManager.getObservableList().addListener((ListChangeListener<OpenOffer>) c -> updateBalance());
    tradeManager.getTradableList().addListener((ListChangeListener<Trade>) c -> updateBalance());
    openOfferManager.onAllServicesInitialized();
    removeOffersWithoutAccountAgeWitness();
    arbitratorManager.onAllServicesInitialized();
    alertManager.alertMessageProperty().addListener((observable, oldValue, newValue) -> displayAlertIfPresent(newValue, false));
    privateNotificationManager.privateNotificationProperty().addListener((observable, oldValue, newValue) -> displayPrivateNotification(newValue));
    displayAlertIfPresent(alertManager.alertMessageProperty().get(), false);
    p2PService.onAllServicesInitialized();
    feeService.onAllServicesInitialized();
    GUIUtil.setFeeService(feeService);
    daoManager.onAllServicesInitialized(errorMessage -> new Popup<>().error(errorMessage).show());
    tradeStatisticsManager.onAllServicesInitialized();
    accountAgeWitnessService.onAllServicesInitialized();
    priceFeedService.setCurrencyCodeOnInit();
    filterManager.onAllServicesInitialized();
    filterManager.addListener(filter -> {
        if (filter != null) {
            if (filter.getSeedNodes() != null && !filter.getSeedNodes().isEmpty())
                new Popup<>().warning(Res.get("popup.warning.nodeBanned", Res.get("popup.warning.seed"))).show();
            if (filter.getPriceRelayNodes() != null && !filter.getPriceRelayNodes().isEmpty())
                new Popup<>().warning(Res.get("popup.warning.nodeBanned", Res.get("popup.warning.priceRelay"))).show();
        }
    });
    setupBtcNumPeersWatcher();
    setupP2PNumPeersWatcher();
    updateBalance();
    if (DevEnv.isDevMode()) {
        preferences.setShowOwnOffersInOfferBook(true);
        setupDevDummyPaymentAccounts();
    }
    fillPriceFeedComboBoxItems();
    setupMarketPriceFeed();
    swapPendingOfferFundingEntries();
    showAppScreen.set(true);
    String key = "remindPasswordAndBackup";
    user.getPaymentAccountsAsObservable().addListener((SetChangeListener<PaymentAccount>) change -> {
        if (!walletsManager.areWalletsEncrypted() && preferences.showAgain(key) && change.wasAdded()) {
            new Popup<>().headLine(Res.get("popup.securityRecommendation.headline")).information(Res.get("popup.securityRecommendation.msg")).dontShowAgainId(key).show();
        }
    });
    checkIfOpenOffersMatchTradeProtocolVersion();
    if (walletsSetup.downloadPercentageProperty().get() == 1)
        checkForLockedUpFunds();
    allBasicServicesInitialized = true;
}
Also used : OpenOffer(bisq.core.offer.OpenOffer) User(bisq.core.user.User) ChainFileLockedException(org.bitcoinj.store.ChainFileLockedException) ListChangeListener(javafx.collections.ListChangeListener) BootstrapListener(bisq.network.p2p.BootstrapListener) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) Map(java.util.Map) BlockStoreException(org.bitcoinj.store.BlockStoreException) MonadicBinding(org.fxmisc.easybind.monadic.MonadicBinding) P2PServiceListener(bisq.network.p2p.P2PServiceListener) ClosedTradableManager(bisq.core.trade.closed.ClosedTradableManager) FilterManager(bisq.core.filter.FilterManager) Set(java.util.Set) PaymentMethod(bisq.core.payment.payload.PaymentMethod) BooleanProperty(javafx.beans.property.BooleanProperty) Slf4j(lombok.extern.slf4j.Slf4j) TxIdTextField(bisq.desktop.components.TxIdTextField) Stream(java.util.stream.Stream) TorNetworkSettingsWindow(bisq.desktop.main.overlays.windows.TorNetworkSettingsWindow) AddressEntry(bisq.core.btc.AddressEntry) WalletsSetup(bisq.core.btc.wallet.WalletsSetup) TradeManager(bisq.core.trade.TradeManager) UserThread(bisq.common.UserThread) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) FeeService(bisq.core.provider.fee.FeeService) ObservableList(javafx.collections.ObservableList) StringProperty(javafx.beans.property.StringProperty) CryptoException(bisq.common.crypto.CryptoException) AlertManager(bisq.core.alert.AlertManager) SetupUtils(bisq.core.app.SetupUtils) FXCollections(javafx.collections.FXCollections) Dispute(bisq.core.arbitration.Dispute) NotificationCenter(bisq.desktop.main.overlays.notifications.NotificationCenter) IntegerProperty(javafx.beans.property.IntegerProperty) ConnectionListener(bisq.network.p2p.network.ConnectionListener) Nullable(javax.annotation.Nullable) EncryptionService(bisq.network.crypto.EncryptionService) DontShowAgainLookup(bisq.core.user.DontShowAgainLookup) GlobalSettings(bisq.core.locale.GlobalSettings) IOException(java.io.IOException) BisqEnvironment(bisq.core.app.BisqEnvironment) OpenOfferManager(bisq.core.offer.OpenOfferManager) PriceFeedService(bisq.core.provider.price.PriceFeedService) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) CloseConnectionReason(bisq.network.p2p.network.CloseConnectionReason) KeyRing(bisq.common.crypto.KeyRing) InetAddresses(com.google.common.net.InetAddresses) SealedAndSigned(bisq.common.crypto.SealedAndSigned) Transaction(org.bitcoinj.core.Transaction) DisplayAlertMessageWindow(bisq.desktop.main.overlays.windows.DisplayAlertMessageWindow) Coin(org.bitcoinj.core.Coin) Date(java.util.Date) DaoManager(bisq.core.dao.DaoManager) Clock(bisq.common.Clock) Inject(com.google.inject.Inject) PerfectMoneyAccount(bisq.core.payment.PerfectMoneyAccount) Security(java.security.Security) TimeoutException(java.util.concurrent.TimeoutException) Random(java.util.Random) DisputeManager(bisq.core.arbitration.DisputeManager) BSFormatter(bisq.desktop.util.BSFormatter) Alert(bisq.core.alert.Alert) Res(bisq.core.locale.Res) Popup(bisq.desktop.main.overlays.popups.Popup) WalletPasswordWindow(bisq.desktop.main.overlays.windows.WalletPasswordWindow) P2PService(bisq.network.p2p.P2PService) ArbitratorManager(bisq.core.arbitration.ArbitratorManager) Subscription(org.fxmisc.easybind.Subscription) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) AccountAgeWitnessService(bisq.core.payment.AccountAgeWitnessService) PaymentAccount(bisq.core.payment.PaymentAccount) List(java.util.List) TacWindow(bisq.desktop.main.overlays.windows.TacWindow) DevEnv(bisq.common.app.DevEnv) AppOptionKeys(bisq.core.app.AppOptionKeys) Preferences(bisq.core.user.Preferences) Optional(java.util.Optional) Address(org.bitcoinj.core.Address) BalanceWithConfirmationTextField(bisq.desktop.components.BalanceWithConfirmationTextField) Ping(bisq.network.p2p.peers.keepalive.messages.Ping) MarketPrice(bisq.core.provider.price.MarketPrice) DisplayUpdateDownloadWindow(bisq.desktop.main.overlays.windows.downloadupdate.DisplayUpdateDownloadWindow) GUIUtil(bisq.desktop.util.GUIUtil) BtcWalletService(bisq.core.btc.wallet.BtcWalletService) Socket(java.net.Socket) TradeCurrency(bisq.core.locale.TradeCurrency) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) SetChangeListener(javafx.collections.SetChangeListener) Timer(bisq.common.Timer) DoubleProperty(javafx.beans.property.DoubleProperty) HashMap(java.util.HashMap) TradeStatisticsManager(bisq.core.trade.statistics.TradeStatisticsManager) BalanceListener(bisq.core.btc.listeners.BalanceListener) WalletsManager(bisq.core.btc.wallet.WalletsManager) CurrencyUtil(bisq.core.locale.CurrencyUtil) Connection(bisq.network.p2p.network.Connection) PrivateNotificationManager(bisq.core.alert.PrivateNotificationManager) Version(bisq.common.app.Version) ObjectProperty(javafx.beans.property.ObjectProperty) CryptoCurrencyAccount(bisq.core.payment.CryptoCurrencyAccount) PrivateNotificationPayload(bisq.core.alert.PrivateNotificationPayload) Trade(bisq.core.trade.Trade) FailedTradesManager(bisq.core.trade.failed.FailedTradesManager) ViewModel(bisq.desktop.common.model.ViewModel) TimeUnit(java.util.concurrent.TimeUnit) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) EasyBind(org.fxmisc.easybind.EasyBind) DecryptedDataTuple(bisq.network.crypto.DecryptedDataTuple) ChangeListener(javafx.beans.value.ChangeListener) Trade(bisq.core.trade.Trade) Coin(org.bitcoinj.core.Coin) BalanceListener(bisq.core.btc.listeners.BalanceListener) Transaction(org.bitcoinj.core.Transaction) PaymentAccount(bisq.core.payment.PaymentAccount) OpenOffer(bisq.core.offer.OpenOffer) Dispute(bisq.core.arbitration.Dispute)

Aggregations

Trade (bisq.core.trade.Trade)2 Clock (bisq.common.Clock)1 Timer (bisq.common.Timer)1 UserThread (bisq.common.UserThread)1 DevEnv (bisq.common.app.DevEnv)1 Version (bisq.common.app.Version)1 CryptoException (bisq.common.crypto.CryptoException)1 KeyRing (bisq.common.crypto.KeyRing)1 SealedAndSigned (bisq.common.crypto.SealedAndSigned)1 Alert (bisq.core.alert.Alert)1 AlertManager (bisq.core.alert.AlertManager)1 PrivateNotificationManager (bisq.core.alert.PrivateNotificationManager)1 PrivateNotificationPayload (bisq.core.alert.PrivateNotificationPayload)1 AppOptionKeys (bisq.core.app.AppOptionKeys)1 BisqEnvironment (bisq.core.app.BisqEnvironment)1 SetupUtils (bisq.core.app.SetupUtils)1 ArbitratorManager (bisq.core.arbitration.ArbitratorManager)1 Dispute (bisq.core.arbitration.Dispute)1 DisputeManager (bisq.core.arbitration.DisputeManager)1 AddressEntry (bisq.core.btc.AddressEntry)1