Exemplo n.º 1
0
  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());
    }
  }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
  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");
    }
  }
Exemplo n.º 4
0
 public String getReference() {
   return trade.getOffer().getReferenceText();
 }
Exemplo n.º 5
0
 public PaymentAccountContractData getSellersPaymentAccountContractData() {
   return trade.getContract().getSellerPaymentAccountContractData();
 }
Exemplo n.º 6
0
 public long getOpenDisputeTimeAsBlockHeight() {
   return trade.getOpenDisputeTimeAsBlockHeight();
 }
Exemplo n.º 7
0
 public long getCheckPaymentTimeAsBlockHeight() {
   return trade.getCheckPaymentTimeAsBlockHeight();
 }
Exemplo n.º 8
0
 public long getLockTime() {
   return trade.getLockTimeAsBlockHeight();
 }
Exemplo n.º 9
0
 Contract getContract() {
   return trade.getContract();
 }
Exemplo n.º 10
0
 Coin getPayoutAmount() {
   return trade.getPayoutAmount();
 }
Exemplo n.º 11
0
 String getCurrencyCode() {
   return trade.getOffer().getCurrencyCode();
 }
Exemplo n.º 12
0
 boolean isBuyOffer() {
   return trade.getOffer().getDirection() == Offer.Direction.BUY;
 }
Exemplo 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);
  }
Exemplo n.º 14
0
 void onFiatPaymentReceived() {
   checkNotNull(trade, "trade must not be null");
   if (trade instanceof SellerTrade && trade.getDisputeState() == Trade.DisputeState.NONE)
     ((SellerTrade) trade).onFiatPaymentReceived();
 }