Search in sources :

Example 1 with SelectDepositTxWindow

use of io.bitsquare.gui.main.overlays.windows.SelectDepositTxWindow in project bitsquare by bitsquare.

the class PendingTradesDataModel method tryOpenDispute.

private void tryOpenDispute(boolean isSupportTicket) {
    if (getTrade() != null) {
        Transaction depositTx = getTrade().getDepositTx();
        if (depositTx != null) {
            doOpenDispute(isSupportTicket, getTrade().getDepositTx());
        } else {
            log.info("Trade.depositTx is null. We try to find the tx in our wallet.");
            List<Transaction> candidates = new ArrayList<>();
            List<Transaction> transactions = walletService.getWallet().getRecentTransactions(100, true);
            transactions.stream().forEach(transaction -> {
                Coin valueSentFromMe = transaction.getValueSentFromMe(walletService.getWallet());
                if (!valueSentFromMe.isZero()) {
                    candidates.addAll(transaction.getOutputs().stream().filter(transactionOutput -> !transactionOutput.isMine(walletService.getWallet())).filter(transactionOutput -> transactionOutput.getScriptPubKey().isPayToScriptHash()).map(transactionOutput -> transaction).collect(Collectors.toList()));
                }
            });
            if (candidates.size() == 1)
                doOpenDispute(isSupportTicket, candidates.get(0));
            else if (candidates.size() > 1)
                new SelectDepositTxWindow().transactions(candidates).onSelect(transaction -> doOpenDispute(isSupportTicket, transaction)).closeButtonText("Cancel").show();
            else
                log.error("Trade.depositTx is null and we did not find any MultiSig transaction.");
        }
    } else {
        log.error("Trade is null");
    }
}
Also used : Popup(io.bitsquare.gui.main.overlays.popups.Popup) MainView(io.bitsquare.gui.main.MainView) Transaction(org.bitcoinj.core.Transaction) P2PService(io.bitsquare.p2p.P2PService) ErrorMessageHandler(io.bitsquare.common.handlers.ErrorMessageHandler) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) Coin(org.bitcoinj.core.Coin) Inject(com.google.inject.Inject) FXCollections(javafx.collections.FXCollections) DisputeManager(io.bitsquare.arbitration.DisputeManager) Trade(io.bitsquare.trade.Trade) ArrayList(java.util.ArrayList) BuyerTrade(io.bitsquare.trade.BuyerTrade) TradeManager(io.bitsquare.trade.TradeManager) User(io.bitsquare.user.User) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) NotificationCenter(io.bitsquare.gui.main.overlays.notifications.NotificationCenter) ListChangeListener(javafx.collections.ListChangeListener) WalletService(io.bitsquare.btc.WalletService) Navigation(io.bitsquare.gui.Navigation) BlockChainListener(org.bitcoinj.core.BlockChainListener) KeyRing(io.bitsquare.common.crypto.KeyRing) TradeWalletService(io.bitsquare.btc.TradeWalletService) ResultHandler(io.bitsquare.common.handlers.ResultHandler) SelectDepositTxWindow(io.bitsquare.gui.main.overlays.windows.SelectDepositTxWindow) FeePolicy(io.bitsquare.btc.FeePolicy) KeyParameter(org.spongycastle.crypto.params.KeyParameter) Nullable(javax.annotation.Nullable) Log(io.bitsquare.app.Log) WalletPasswordWindow(io.bitsquare.gui.main.overlays.windows.WalletPasswordWindow) ActivatableDataModel(io.bitsquare.gui.common.model.ActivatableDataModel) ObjectProperty(javafx.beans.property.ObjectProperty) Arbitrator(io.bitsquare.arbitration.Arbitrator) DisputeAlreadyOpenException(io.bitsquare.arbitration.DisputeAlreadyOpenException) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) PaymentAccountContractData(io.bitsquare.payment.PaymentAccountContractData) Collectors(java.util.stream.Collectors) SellerTrade(io.bitsquare.trade.SellerTrade) DisputesView(io.bitsquare.gui.main.disputes.DisputesView) Preferences(io.bitsquare.user.Preferences) Offer(io.bitsquare.trade.offer.Offer) List(java.util.List) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Dispute(io.bitsquare.arbitration.Dispute) FaultHandler(io.bitsquare.common.handlers.FaultHandler) ObservableList(javafx.collections.ObservableList) StringProperty(javafx.beans.property.StringProperty) Coin(org.bitcoinj.core.Coin) Transaction(org.bitcoinj.core.Transaction) ArrayList(java.util.ArrayList) SelectDepositTxWindow(io.bitsquare.gui.main.overlays.windows.SelectDepositTxWindow)

Aggregations

Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Inject (com.google.inject.Inject)1 Log (io.bitsquare.app.Log)1 Arbitrator (io.bitsquare.arbitration.Arbitrator)1 Dispute (io.bitsquare.arbitration.Dispute)1 DisputeAlreadyOpenException (io.bitsquare.arbitration.DisputeAlreadyOpenException)1 DisputeManager (io.bitsquare.arbitration.DisputeManager)1 FeePolicy (io.bitsquare.btc.FeePolicy)1 TradeWalletService (io.bitsquare.btc.TradeWalletService)1 WalletService (io.bitsquare.btc.WalletService)1 KeyRing (io.bitsquare.common.crypto.KeyRing)1 ErrorMessageHandler (io.bitsquare.common.handlers.ErrorMessageHandler)1 FaultHandler (io.bitsquare.common.handlers.FaultHandler)1 ResultHandler (io.bitsquare.common.handlers.ResultHandler)1 Navigation (io.bitsquare.gui.Navigation)1 ActivatableDataModel (io.bitsquare.gui.common.model.ActivatableDataModel)1 MainView (io.bitsquare.gui.main.MainView)1 DisputesView (io.bitsquare.gui.main.disputes.DisputesView)1 NotificationCenter (io.bitsquare.gui.main.overlays.notifications.NotificationCenter)1