From f3f05413feded8af38b30ee662f6d9745bcbfbb5 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Thu, 22 Jun 2017 02:22:50 +0200 Subject: [PATCH] Add checks for isBaseCurrencySupportingBsq --- common/src/main/java/io/bisq/common/app/DevEnv.java | 2 +- .../io/bisq/core/trade/protocol/ProcessModel.java | 11 ++++++++--- .../protocol/tasks/taker/TakerPublishTakerFeeTx.java | 2 +- .../java/io/bisq/gui/main/disputes/DisputesView.java | 4 ---- .../main/funds/transactions/TransactionsListItem.java | 5 +++-- .../gui/main/offer/takeoffer/TakeOfferDataModel.java | 7 ++++++- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/common/src/main/java/io/bisq/common/app/DevEnv.java b/common/src/main/java/io/bisq/common/app/DevEnv.java index 227d3605c3..93e946c077 100644 --- a/common/src/main/java/io/bisq/common/app/DevEnv.java +++ b/common/src/main/java/io/bisq/common/app/DevEnv.java @@ -18,7 +18,7 @@ public class DevEnv { // If set to true we ignore several UI behavior like confirmation popups as well dummy accounts are created and // offers are filled with default values. Intended to make dev testing faster. @SuppressWarnings("PointlessBooleanExpression") - public static final boolean DEV_MODE = STRESS_TEST_MODE || true; + public static final boolean DEV_MODE = STRESS_TEST_MODE || false; public static final boolean DAO_ACTIVATED = true; public static final boolean DAO_PHASE2_ACTIVATED = false; diff --git a/core/src/main/java/io/bisq/core/trade/protocol/ProcessModel.java b/core/src/main/java/io/bisq/core/trade/protocol/ProcessModel.java index 8d24f35bda..8f444d02ea 100644 --- a/core/src/main/java/io/bisq/core/trade/protocol/ProcessModel.java +++ b/core/src/main/java/io/bisq/core/trade/protocol/ProcessModel.java @@ -23,6 +23,7 @@ import io.bisq.common.crypto.PubKeyRing; import io.bisq.common.proto.ProtoUtil; import io.bisq.common.proto.persistable.PersistablePayload; import io.bisq.common.taskrunner.Model; +import io.bisq.core.app.BisqEnvironment; import io.bisq.core.btc.data.RawTransactionInput; import io.bisq.core.btc.wallet.BsqWalletService; import io.bisq.core.btc.wallet.BtcWalletService; @@ -298,9 +299,13 @@ public class ProcessModel implements Model, PersistablePayload { return Coin.valueOf(fundsNeededForTradeAsLong); } - public Transaction getTakeOfferFeeTx() { - if (takeOfferFeeTx == null) - takeOfferFeeTx = bsqWalletService.getTransaction(Sha256Hash.wrap(takeOfferFeeTxId)); + public Transaction resolveTakeOfferFeeTx(Trade trade) { + if (takeOfferFeeTx == null) { + if (BisqEnvironment.isBaseCurrencySupportingBsq() && !trade.isCurrencyForTakerFeeBtc()) + takeOfferFeeTx = bsqWalletService.getTransaction(Sha256Hash.wrap(takeOfferFeeTxId)); + else + takeOfferFeeTx = btcWalletService.getTransaction(Sha256Hash.wrap(takeOfferFeeTxId)); + } return takeOfferFeeTx; } diff --git a/core/src/main/java/io/bisq/core/trade/protocol/tasks/taker/TakerPublishTakerFeeTx.java b/core/src/main/java/io/bisq/core/trade/protocol/tasks/taker/TakerPublishTakerFeeTx.java index 21a93fef99..aca0524b8a 100644 --- a/core/src/main/java/io/bisq/core/trade/protocol/tasks/taker/TakerPublishTakerFeeTx.java +++ b/core/src/main/java/io/bisq/core/trade/protocol/tasks/taker/TakerPublishTakerFeeTx.java @@ -36,7 +36,7 @@ public class TakerPublishTakerFeeTx extends TradeTask { protected void run() { try { runInterceptHook(); - processModel.getTradeWalletService().broadcastTx(processModel.getTakeOfferFeeTx(), + processModel.getTradeWalletService().broadcastTx(processModel.resolveTakeOfferFeeTx(trade), new FutureCallback() { @Override public void onSuccess(Transaction transaction) { diff --git a/gui/src/main/java/io/bisq/gui/main/disputes/DisputesView.java b/gui/src/main/java/io/bisq/gui/main/disputes/DisputesView.java index 4f671b00bb..79ae3c2f24 100644 --- a/gui/src/main/java/io/bisq/gui/main/disputes/DisputesView.java +++ b/gui/src/main/java/io/bisq/gui/main/disputes/DisputesView.java @@ -30,8 +30,6 @@ import io.bisq.gui.main.MainView; import io.bisq.gui.main.disputes.arbitrator.ArbitratorDisputeView; import io.bisq.gui.main.disputes.trader.TraderDisputeView; import io.bisq.gui.main.overlays.popups.Popup; -import io.bisq.gui.main.portfolio.PortfolioView; -import io.bisq.gui.main.portfolio.pendingtrades.PendingTradesView; import io.bisq.network.p2p.NodeAddress; import javafx.beans.value.ChangeListener; import javafx.collections.MapChangeListener; @@ -133,8 +131,6 @@ public class DisputesView extends ActivatableViewAndModel //noinspection unchecked new Popup<>().backgroundInfo(Res.get("support.backgroundInfo")) .width(900) - .actionButtonTextWithGoTo("navigation.portfolio.pending") - .onAction(() -> navigation.navigateTo(MainView.class, PortfolioView.class, PendingTradesView.class)) .dontShowAgainId(key) .show(); } diff --git a/gui/src/main/java/io/bisq/gui/main/funds/transactions/TransactionsListItem.java b/gui/src/main/java/io/bisq/gui/main/funds/transactions/TransactionsListItem.java index 824fd258ea..a1811cc9f1 100644 --- a/gui/src/main/java/io/bisq/gui/main/funds/transactions/TransactionsListItem.java +++ b/gui/src/main/java/io/bisq/gui/main/funds/transactions/TransactionsListItem.java @@ -18,6 +18,7 @@ package io.bisq.gui.main.funds.transactions; import io.bisq.common.locale.Res; +import io.bisq.core.app.BisqEnvironment; import io.bisq.core.btc.listeners.TxConfidenceListener; import io.bisq.core.btc.wallet.BsqWalletService; import io.bisq.core.btc.wallet.BtcWalletService; @@ -87,7 +88,7 @@ class TransactionsListItem { for (TransactionOutput output : transaction.getOutputs()) { if (!btcWalletService.isTransactionOutputMine(output)) { received = false; - if (bsqWalletService.isTransactionOutputMine(output)) { + if (BisqEnvironment.isBaseCurrencySupportingBsq() && bsqWalletService.isTransactionOutputMine(output)) { txFeeForBsqPayment = true; } else { direction = Res.get("funds.tx.direction.sentTo"); @@ -114,7 +115,7 @@ class TransactionsListItem { boolean outgoing = false; for (TransactionOutput output : transaction.getOutputs()) { if (!btcWalletService.isTransactionOutputMine(output)) { - if (bsqWalletService.isTransactionOutputMine(output)) { + if (BisqEnvironment.isBaseCurrencySupportingBsq() && bsqWalletService.isTransactionOutputMine(output)) { outgoing = false; txFeeForBsqPayment = true; } else { diff --git a/gui/src/main/java/io/bisq/gui/main/offer/takeoffer/TakeOfferDataModel.java b/gui/src/main/java/io/bisq/gui/main/offer/takeoffer/TakeOfferDataModel.java index a84f985392..fe6b5680b7 100644 --- a/gui/src/main/java/io/bisq/gui/main/offer/takeoffer/TakeOfferDataModel.java +++ b/gui/src/main/java/io/bisq/gui/main/offer/takeoffer/TakeOfferDataModel.java @@ -23,6 +23,7 @@ import io.bisq.common.locale.CurrencyUtil; import io.bisq.common.locale.Res; import io.bisq.common.monetary.Price; import io.bisq.common.monetary.Volume; +import io.bisq.core.app.BisqEnvironment; import io.bisq.core.btc.AddressEntry; import io.bisq.core.btc.Restrictions; import io.bisq.core.btc.listeners.BalanceListener; @@ -332,7 +333,11 @@ class TakeOfferDataModel extends ActivatableDataModel { } boolean isBsqForFeeAvailable() { - return getTakerFee(false) != null && bsqWalletService.getAvailableBalance() != null && !bsqWalletService.getAvailableBalance().subtract(getTakerFee(false)).isNegative(); + return BisqEnvironment.isBaseCurrencySupportingBsq() && + getTakerFee(false) != null && + bsqWalletService.getAvailableBalance() != null && + getTakerFee(false) != null && + !bsqWalletService.getAvailableBalance().subtract(getTakerFee(false)).isNegative(); } ///////////////////////////////////////////////////////////////////////////////////////////