void onSelectTrade(PendingTradesListItem item) {
    // clean up previous selectedItem
    selectedItem = item;

    if (item == null) {
      trade = null;
      tradeProperty.set(null);
    } else {
      trade = item.getTrade();
      tradeProperty.set(trade);

      isOfferer = tradeManager.isMyOffer(trade.getOffer());

      if (trade.getDepositTx() != null) txId.set(trade.getDepositTx().getHashAsString());
    }
  }
 void onFiatPaymentStarted(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
   checkNotNull(trade, "trade must not be null");
   checkArgument(trade instanceof BuyerTrade, "Check failed: trade instanceof BuyerTrade");
   checkArgument(
       trade.getDisputeState() == Trade.DisputeState.NONE,
       "Check failed: trade.getDisputeState() == Trade.DisputeState.NONE");
   ((BuyerTrade) trade).onFiatPaymentStarted(resultHandler, errorMessageHandler);
 }
  private void tryOpenDispute(boolean isSupportTicket) {
    if (trade != null) {
      Transaction depositTx = trade.getDepositTx();
      if (depositTx != null) {
        doOpenDispute(isSupportTicket, trade.getDepositTx());
      } else {
        log.warn("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()) {
                    // spending tx
                    for (TransactionOutput transactionOutput : transaction.getOutputs()) {
                      if (!transactionOutput.isMine(walletService.getWallet())) {
                        if (transactionOutput.getScriptPubKey().isPayToScriptHash()) {
                          // MS tx
                          candidates.add(transaction);
                        }
                      }
                    }
                  }
                });

        if (candidates.size() == 1) doOpenDispute(isSupportTicket, candidates.get(0));
        else if (candidates.size() > 1)
          new SelectDepositTxPopup()
              .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");
    }
  }
 public String getReference() {
   return trade.getOffer().getReferenceText();
 }
 public PaymentAccountContractData getSellersPaymentAccountContractData() {
   return trade.getContract().getSellerPaymentAccountContractData();
 }
 public long getOpenDisputeTimeAsBlockHeight() {
   return trade.getOpenDisputeTimeAsBlockHeight();
 }
 public long getCheckPaymentTimeAsBlockHeight() {
   return trade.getCheckPaymentTimeAsBlockHeight();
 }
 public long getLockTime() {
   return trade.getLockTimeAsBlockHeight();
 }
 Contract getContract() {
   return trade.getContract();
 }
Esempio n. 10
0
 Coin getPayoutAmount() {
   return trade.getPayoutAmount();
 }
Esempio n. 11
0
 String getCurrencyCode() {
   return trade.getOffer().getCurrencyCode();
 }
Esempio n. 12
0
 boolean isBuyOffer() {
   return trade.getOffer().getDirection() == Offer.Direction.BUY;
 }
Esempio n. 13
0
  private void doOpenDispute(boolean isSupportTicket, Transaction depositTx) {
    Log.traceCall("depositTx=" + depositTx);
    byte[] depositTxSerialized = null;
    byte[] payoutTxSerialized = null;
    String depositTxHashAsString = null;
    String payoutTxHashAsString = null;
    if (depositTx != null) {
      depositTxSerialized = depositTx.bitcoinSerialize();
      depositTxHashAsString = depositTx.getHashAsString();
    } else {
      log.warn("depositTx is null");
    }
    Transaction payoutTx = trade.getPayoutTx();
    if (payoutTx != null) {
      payoutTxSerialized = payoutTx.bitcoinSerialize();
      payoutTxHashAsString = payoutTx.getHashAsString();
    }

    Dispute dispute =
        new Dispute(
            disputeManager.getDisputeStorage(),
            trade.getId(),
            keyRing.getPubKeyRing().hashCode(), // traderId
            trade.getOffer().getDirection() == Offer.Direction.BUY ? isOfferer : !isOfferer,
            isOfferer,
            keyRing.getPubKeyRing(),
            trade.getDate(),
            trade.getContract(),
            trade.getContractHash(),
            depositTxSerialized,
            payoutTxSerialized,
            depositTxHashAsString,
            payoutTxHashAsString,
            trade.getContractAsJson(),
            trade.getOffererContractSignature(),
            trade.getTakerContractSignature(),
            user.getAcceptedArbitratorByAddress(trade.getArbitratorNodeAddress()).getPubKeyRing(),
            isSupportTicket);

    trade.setDisputeState(Trade.DisputeState.DISPUTE_REQUESTED);
    disputeManager.sendOpenNewDisputeMessage(dispute);
    navigation.navigateTo(MainView.class, DisputesView.class);
  }
Esempio n. 14
0
 void onFiatPaymentReceived() {
   checkNotNull(trade, "trade must not be null");
   if (trade instanceof SellerTrade && trade.getDisputeState() == Trade.DisputeState.NONE)
     ((SellerTrade) trade).onFiatPaymentReceived();
 }