diff --git a/apitest/src/main/resources/haveno.properties b/apitest/src/main/resources/haveno.properties index 8c4b02d4fe..23f2b30623 100644 --- a/apitest/src/main/resources/haveno.properties +++ b/apitest/src/main/resources/haveno.properties @@ -3,5 +3,4 @@ # Haveno Config options not configurable in test harness-specific apitest.properties # file. This is where you might define Haveno options such as: # dumpBlockchainData=true -# dumpDelayedPayoutTxs=true # dumpStatistics=true diff --git a/common/src/main/java/bisq/common/config/Config.java b/common/src/main/java/bisq/common/config/Config.java index 93d7bbe0dc..64917c9b37 100644 --- a/common/src/main/java/bisq/common/config/Config.java +++ b/common/src/main/java/bisq/common/config/Config.java @@ -107,8 +107,6 @@ public class Config { public static final String USE_ALL_PROVIDED_NODES = "useAllProvidedNodes"; public static final String USER_AGENT = "userAgent"; public static final String NUM_CONNECTIONS_FOR_BTC = "numConnectionsForBtc"; - public static final String DUMP_DELAYED_PAYOUT_TXS = "dumpDelayedPayoutTxs"; - public static final String ALLOW_FAULTY_DELAYED_TXS = "allowFaultyDelayedTxs"; public static final String API_PASSWORD = "apiPassword"; public static final String API_PORT = "apiPort"; public static final String PREVENT_PERIODIC_SHUTDOWN_AT_SEED_NODE = "preventPeriodicShutdownAtSeedNode"; @@ -192,8 +190,6 @@ public class Config { public final boolean useAllProvidedNodes; public final String userAgent; public final int numConnectionsForBtc; - public final boolean dumpDelayedPayoutTxs; - public final boolean allowFaultyDelayedTxs; public final String apiPassword; public final int apiPort; public final boolean preventPeriodicShutdownAtSeedNode; @@ -559,19 +555,6 @@ public class Config { .ofType(int.class) .defaultsTo(DEFAULT_NUM_CONNECTIONS_FOR_BTC); - ArgumentAcceptingOptionSpec dumpDelayedPayoutTxsOpt = - parser.accepts(DUMP_DELAYED_PAYOUT_TXS, "Dump delayed payout transactions to file") - .withRequiredArg() - .ofType(boolean.class) - .defaultsTo(false); - - ArgumentAcceptingOptionSpec allowFaultyDelayedTxsOpt = - parser.accepts(ALLOW_FAULTY_DELAYED_TXS, "Allow completion of trades with faulty delayed " + - "payout transactions") - .withRequiredArg() - .ofType(boolean.class) - .defaultsTo(false); - ArgumentAcceptingOptionSpec apiPasswordOpt = parser.accepts(API_PASSWORD, "gRPC API password") .withRequiredArg() @@ -714,8 +697,6 @@ public class Config { this.userAgent = options.valueOf(userAgentOpt); this.numConnectionsForBtc = options.valueOf(numConnectionsForBtcOpt); - this.dumpDelayedPayoutTxs = options.valueOf(dumpDelayedPayoutTxsOpt); - this.allowFaultyDelayedTxs = options.valueOf(allowFaultyDelayedTxsOpt); this.apiPassword = options.valueOf(apiPasswordOpt); this.apiPort = options.valueOf(apiPortOpt); this.preventPeriodicShutdownAtSeedNode = options.valueOf(preventPeriodicShutdownAtSeedNodeOpt); diff --git a/core/src/main/java/bisq/core/api/model/TradeInfo.java b/core/src/main/java/bisq/core/api/model/TradeInfo.java index 17e25daee7..63e58be489 100644 --- a/core/src/main/java/bisq/core/api/model/TradeInfo.java +++ b/core/src/main/java/bisq/core/api/model/TradeInfo.java @@ -68,7 +68,6 @@ public class TradeInfo implements Payload { private final String role; private final long txFeeAsLong; private final long takerFeeAsLong; - private final String takerFeeTxId; private final String makerDepositTxId; private final String takerDepositTxId; private final String payoutTxId; @@ -97,7 +96,6 @@ public class TradeInfo implements Payload { this.role = builder.getRole(); this.txFeeAsLong = builder.getTxFeeAsLong(); this.takerFeeAsLong = builder.getTakerFeeAsLong(); - this.takerFeeTxId = builder.getTakerFeeTxId(); this.makerDepositTxId = builder.getMakerDepositTxId(); this.takerDepositTxId = builder.getTakerDepositTxId(); this.payoutTxId = builder.getPayoutTxId(); @@ -141,7 +139,7 @@ public class TradeInfo implements Payload { } else { contractInfo = ContractInfo.emptyContract.get(); } - + return new TradeInfoV1Builder() .withTradeId(trade.getId()) .withShortId(trade.getShortId()) @@ -149,7 +147,6 @@ public class TradeInfo implements Payload { .withRole(role == null ? "" : role) .withTxFeeAsLong(trade.getTxFeeAsLong()) .withTakerFeeAsLong(trade.getTakerFeeAsLong()) - .withTakerFeeTxId(trade.getTakerFeeTxId()) .withMakerDepositTxId(trade.getMaker().getDepositTxHash()) .withTakerDepositTxId(trade.getTaker().getDepositTxHash()) .withPayoutTxId(trade.getPayoutTxId()) @@ -187,7 +184,6 @@ public class TradeInfo implements Payload { .setRole(role) .setTxFeeAsLong(txFeeAsLong) .setTakerFeeAsLong(takerFeeAsLong) - .setTakerFeeTxId(takerFeeTxId == null ? "" : takerFeeTxId) .setMakerDepositTxId(makerDepositTxId == null ? "" : makerDepositTxId) .setTakerDepositTxId(takerDepositTxId == null ? "" : takerDepositTxId) .setPayoutTxId(payoutTxId == null ? "" : payoutTxId) @@ -219,7 +215,6 @@ public class TradeInfo implements Payload { .withRole(proto.getRole()) .withTxFeeAsLong(proto.getTxFeeAsLong()) .withTakerFeeAsLong(proto.getTakerFeeAsLong()) - .withTakerFeeTxId(proto.getTakerFeeTxId()) .withMakerDepositTxId(proto.getMakerDepositTxId()) .withTakerDepositTxId(proto.getTakerDepositTxId()) .withPayoutTxId(proto.getPayoutTxId()) @@ -251,7 +246,6 @@ public class TradeInfo implements Payload { ", role='" + role + '\'' + "\n" + ", txFeeAsLong='" + txFeeAsLong + '\'' + "\n" + ", takerFeeAsLong='" + takerFeeAsLong + '\'' + "\n" + - ", takerFeeTxId='" + takerFeeTxId + '\'' + "\n" + ", makerDepositTxId='" + makerDepositTxId + '\'' + "\n" + ", takerDepositTxId='" + takerDepositTxId + '\'' + "\n" + ", payoutTxId='" + payoutTxId + '\'' + "\n" + diff --git a/core/src/main/java/bisq/core/api/model/builder/TradeInfoV1Builder.java b/core/src/main/java/bisq/core/api/model/builder/TradeInfoV1Builder.java index 512045b320..5b591defad 100644 --- a/core/src/main/java/bisq/core/api/model/builder/TradeInfoV1Builder.java +++ b/core/src/main/java/bisq/core/api/model/builder/TradeInfoV1Builder.java @@ -40,7 +40,6 @@ public final class TradeInfoV1Builder { private boolean isCurrencyForTakerFeeBtc; private long txFeeAsLong; private long takerFeeAsLong; - private String takerFeeTxId; private String makerDepositTxId; private String takerDepositTxId; private String payoutTxId; @@ -102,11 +101,6 @@ public final class TradeInfoV1Builder { return this; } - public TradeInfoV1Builder withTakerFeeTxId(String takerFeeTxId) { - this.takerFeeTxId = takerFeeTxId; - return this; - } - public TradeInfoV1Builder withMakerDepositTxId(String makerDepositTxId) { this.makerDepositTxId = makerDepositTxId; return this; diff --git a/core/src/main/java/bisq/core/app/WalletAppSetup.java b/core/src/main/java/bisq/core/app/WalletAppSetup.java index 49aa20a707..5e12f54782 100644 --- a/core/src/main/java/bisq/core/app/WalletAppSetup.java +++ b/core/src/main/java/bisq/core/app/WalletAppSetup.java @@ -255,7 +255,7 @@ public class WalletAppSetup { if (txId.equals(trade.getTaker().getDepositTxHash())) { details = Res.get("popup.warning.trade.txRejected.deposit"); } - if (txId.equals(trade.getOffer().getOfferFeePaymentTxId()) || txId.equals(trade.getTakerFeeTxId())) { + if (txId.equals(trade.getOffer().getOfferFeePaymentTxId())) { details = Res.get("popup.warning.trade.txRejected.tradeFee"); } diff --git a/core/src/main/java/bisq/core/trade/ClosedTradableManager.java b/core/src/main/java/bisq/core/trade/ClosedTradableManager.java index 3eed4b4c7a..b2b32f9458 100644 --- a/core/src/main/java/bisq/core/trade/ClosedTradableManager.java +++ b/core/src/main/java/bisq/core/trade/ClosedTradableManager.java @@ -71,7 +71,6 @@ public class ClosedTradableManager implements PersistedDataHost { private final TradeStatisticsManager tradeStatisticsManager; private final PersistenceManager> persistenceManager; private final CleanupMailboxMessagesService cleanupMailboxMessagesService; - private final DumpDelayedPayoutTx dumpDelayedPayoutTx; private final TradableList closedTradables = new TradableList<>(); @@ -81,14 +80,12 @@ public class ClosedTradableManager implements PersistedDataHost { Preferences preferences, TradeStatisticsManager tradeStatisticsManager, PersistenceManager> persistenceManager, - CleanupMailboxMessagesService cleanupMailboxMessagesService, - DumpDelayedPayoutTx dumpDelayedPayoutTx) { + CleanupMailboxMessagesService cleanupMailboxMessagesService) { this.keyRing = keyRing; this.priceFeedService = priceFeedService; this.preferences = preferences; this.tradeStatisticsManager = tradeStatisticsManager; this.cleanupMailboxMessagesService = cleanupMailboxMessagesService; - this.dumpDelayedPayoutTx = dumpDelayedPayoutTx; this.persistenceManager = persistenceManager; this.persistenceManager.initialize(closedTradables, "ClosedTrades", PersistenceManager.Source.PRIVATE); @@ -101,7 +98,6 @@ public class ClosedTradableManager implements PersistedDataHost { closedTradables.stream() .filter(tradable -> tradable.getOffer() != null) .forEach(tradable -> tradable.getOffer().setPriceFeedService(priceFeedService)); - dumpDelayedPayoutTx.maybeDumpDelayedPayoutTxs(closedTradables, "delayed_payout_txs_closed"); completeHandler.run(); }, completeHandler); diff --git a/core/src/main/java/bisq/core/trade/DumpDelayedPayoutTx.java b/core/src/main/java/bisq/core/trade/DumpDelayedPayoutTx.java deleted file mode 100644 index 8d22f83712..0000000000 --- a/core/src/main/java/bisq/core/trade/DumpDelayedPayoutTx.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Haveno is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Haveno. If not, see . - */ - -package bisq.core.trade; - -import bisq.common.config.Config; -import bisq.common.file.JsonFileManager; -import bisq.common.util.Utilities; -import bisq.core.util.JsonUtil; -import javax.inject.Inject; -import javax.inject.Named; - -import java.io.File; - -import java.util.stream.Collectors; - -public class DumpDelayedPayoutTx { - private final boolean dumpDelayedPayoutTxs; - private final JsonFileManager jsonFileManager; - - @Inject - DumpDelayedPayoutTx(@Named(Config.STORAGE_DIR) File storageDir, - @Named(Config.DUMP_DELAYED_PAYOUT_TXS) boolean dumpDelayedPayoutTxs) { - this.dumpDelayedPayoutTxs = dumpDelayedPayoutTxs; - jsonFileManager = new JsonFileManager(storageDir); - } - - static class DelayedPayoutHash { - final String tradeId; - final String delayedPayoutTx; - - DelayedPayoutHash(String tradeId, String delayedPayoutTx) { - this.tradeId = tradeId; - this.delayedPayoutTx = delayedPayoutTx; - } - } - - public void maybeDumpDelayedPayoutTxs(TradableList tradableList, String fileName) { - if (!dumpDelayedPayoutTxs) - return; - - var delayedPayoutHashes = tradableList.stream() - .filter(tradable -> tradable instanceof Trade) - .map(trade -> new DelayedPayoutHash(trade.getId(), - Utilities.bytesAsHexString(((Trade) trade).getDelayedPayoutTxBytes()))) - .collect(Collectors.toList()); - jsonFileManager.writeToDiscThreaded(JsonUtil.objectToJson(delayedPayoutHashes), fileName); - } - -} diff --git a/core/src/main/java/bisq/core/trade/Trade.java b/core/src/main/java/bisq/core/trade/Trade.java index f5608a3a78..d51f852d14 100644 --- a/core/src/main/java/bisq/core/trade/Trade.java +++ b/core/src/main/java/bisq/core/trade/Trade.java @@ -310,10 +310,6 @@ public abstract class Trade implements Tradable, Model { @Nullable @Getter @Setter - private String takerFeeTxId; - @Nullable - @Getter - @Setter private long amountAsLong; @Setter private long price; @@ -359,15 +355,13 @@ public abstract class Trade implements Tradable, Model { transient final private ObjectProperty disputeStateProperty = new SimpleObjectProperty<>(disputeState); transient final private ObjectProperty tradePeriodStateProperty = new SimpleObjectProperty<>(periodState); transient final private StringProperty errorMessageProperty = new SimpleStringProperty(); - + // Mutable @Getter transient private boolean isInitialized; // Added in v1.2.0 @Nullable - transient private Transaction delayedPayoutTx; - @Nullable transient private Coin tradeAmount; transient private ObjectProperty tradeAmountProperty; @@ -383,10 +377,6 @@ public abstract class Trade implements Tradable, Model { @Getter @Setter private long lockTime; - @Nullable - @Getter - @Setter - private byte[] delayedPayoutTxBytes; @Getter @Nullable private RefundResultState refundResultState = RefundResultState.UNDEFINED_REFUND_RESULT; @@ -458,11 +448,11 @@ public abstract class Trade implements Tradable, Model { this.takerFeeAsLong = takerFee.value; this.takeOfferDate = new Date().getTime(); this.tradeListeners = new ArrayList(); - + getMaker().setNodeAddress(makerNodeAddress); getTaker().setNodeAddress(takerNodeAddress); getArbitrator().setNodeAddress(arbitratorNodeAddress); - + setAmount(tradeAmount); } @@ -548,7 +538,6 @@ public abstract class Trade implements Tradable, Model { .setLockTime(lockTime) .setUid(uid); - Optional.ofNullable(takerFeeTxId).ifPresent(builder::setTakerFeeTxId); Optional.ofNullable(payoutTxId).ifPresent(builder::setPayoutTxId); Optional.ofNullable(contract).ifPresent(e -> builder.setContract(contract.toProtoMessage())); Optional.ofNullable(contractAsJson).ifPresent(builder::setContractAsJson); @@ -559,7 +548,6 @@ public abstract class Trade implements Tradable, Model { Optional.ofNullable(refundResultState).ifPresent(e -> builder.setRefundResultState(RefundResultState.toProtoMessage(refundResultState))); Optional.ofNullable(payoutTxHex).ifPresent(e -> builder.setPayoutTxHex(payoutTxHex)); Optional.ofNullable(payoutTxKey).ifPresent(e -> builder.setPayoutTxHex(payoutTxKey)); - Optional.ofNullable(delayedPayoutTxBytes).ifPresent(e -> builder.setDelayedPayoutTxBytes(ByteString.copyFrom(delayedPayoutTxBytes))); Optional.ofNullable(counterCurrencyExtraData).ifPresent(e -> builder.setCounterCurrencyExtraData(counterCurrencyExtraData)); Optional.ofNullable(assetTxProofResult).ifPresent(e -> builder.setAssetTxProofResult(assetTxProofResult.name())); return builder.build(); @@ -570,7 +558,6 @@ public abstract class Trade implements Tradable, Model { trade.setState(State.fromProto(proto.getState())); trade.setDisputeState(DisputeState.fromProto(proto.getDisputeState())); trade.setPeriodState(TradePeriodState.fromProto(proto.getPeriodState())); - trade.setTakerFeeTxId(ProtoUtil.stringOrNullFromProto(proto.getTakerFeeTxId())); trade.setPayoutTxId(ProtoUtil.stringOrNullFromProto(proto.getPayoutTxId())); trade.setPayoutTxHex(ProtoUtil.stringOrNullFromProto(proto.getPayoutTxHex())); trade.setPayoutTxKey(ProtoUtil.stringOrNullFromProto(proto.getPayoutTxKey())); @@ -581,7 +568,6 @@ public abstract class Trade implements Tradable, Model { trade.setCounterCurrencyTxId(proto.getCounterCurrencyTxId().isEmpty() ? null : proto.getCounterCurrencyTxId()); trade.setMediationResultState(MediationResultState.fromProto(proto.getMediationResultState())); trade.setRefundResultState(RefundResultState.fromProto(proto.getRefundResultState())); - trade.setDelayedPayoutTxBytes(ProtoUtil.byteArrayOrNullFromProto(proto.getDelayedPayoutTxBytes())); trade.setLockTime(proto.getLockTime()); trade.setCounterCurrencyExtraData(ProtoUtil.stringOrNullFromProto(proto.getCounterCurrencyExtraData())); @@ -626,7 +612,7 @@ public abstract class Trade implements Tradable, Model { /** * Create a contract based on the current state. - * + * * @param trade is the trade to create the contract from * @return the contract */ @@ -659,7 +645,7 @@ public abstract class Trade implements Tradable, Model { /** * Create the payout tx. - * + * * @return MoneroTxWallet the payout tx when the trade is successfully completed */ public MoneroTxWallet createPayoutTx() { @@ -711,7 +697,7 @@ public abstract class Trade implements Tradable, Model { /** * Verify a payout tx. - * + * * @param payoutTxHex is the payout tx hex to verify * @param sign signs the payout tx if true * @param publish publishes the signed payout tx if true @@ -782,7 +768,7 @@ public abstract class Trade implements Tradable, Model { /** * Decrypt the peer's payment account payload using the given key. - * + * * @param paymentAccountKey is the key to decrypt the payment account payload */ public void decryptPeersPaymentAccountPayload(byte[] paymentAccountKey) { @@ -808,7 +794,7 @@ public abstract class Trade implements Tradable, Model { /** * Listen for deposit transactions to unlock and then apply the transactions. - * + * * TODO: adopt for general purpose scheduling * TODO: check and notify if deposits are dropped due to re-org */ @@ -963,15 +949,6 @@ public abstract class Trade implements Tradable, Model { } } - public void applyDelayedPayoutTx(Transaction delayedPayoutTx) { - this.delayedPayoutTx = delayedPayoutTx; - this.delayedPayoutTxBytes = delayedPayoutTx.bitcoinSerialize(); - } - - public void applyDelayedPayoutTxBytes(byte[] delayedPayoutTxBytes) { - this.delayedPayoutTxBytes = delayedPayoutTxBytes; - } - public void addAndPersistChatMessage(ChatMessage chatMessage) { if (!chatMessages.contains(chatMessage)) { chatMessages.add(chatMessage); @@ -1043,7 +1020,7 @@ public abstract class Trade implements Tradable, Model { listener.onVerifiedTradeMessage(message, sender); } } - + // notified from TradeProtocol of ack messages public void onAckMessage(AckMessage ackMessage, NodeAddress sender) { for (TradeListener listener : new ArrayList(tradeListeners)) { // copy array to allow listener invocation to unregister listener without concurrent modification exception @@ -1179,7 +1156,7 @@ public abstract class Trade implements Tradable, Model { /** * Get the taker if maker, maker if taker, null if arbitrator. - * + * * @return the trade peer */ public TradingPeer getTradingPeer() { @@ -1188,12 +1165,12 @@ public abstract class Trade implements Tradable, Model { else if (this instanceof ArbitratorTrade) return null; else throw new RuntimeException("Unknown trade type: " + getClass().getName()); } - + /** * Get the peer with the given address which can be self. - * + * * TODO (woodser): this naming convention is confusing - * + * * @param address is the address of the peer to get * @return the trade peer */ @@ -1438,10 +1415,8 @@ public abstract class Trade implements Tradable, Model { public boolean isTxChainInvalid() { return offer.getOfferFeePaymentTxId() == null || - getTakerFeeTxId() == null || processModel.getMaker().getDepositTxHash() == null || - processModel.getMaker().getDepositTxHash() == null || - getDelayedPayoutTxBytes() == null; + processModel.getTaker().getDepositTxHash() == null; } @@ -1484,7 +1459,6 @@ public abstract class Trade implements Tradable, Model { ",\n takerFeeAsLong=" + takerFeeAsLong + ",\n takeOfferDate=" + takeOfferDate + ",\n processModel=" + processModel + - ",\n takerFeeTxId='" + takerFeeTxId + '\'' + ",\n payoutTxId='" + payoutTxId + '\'' + ",\n tradeAmountAsLong=" + amountAsLong + ",\n tradePrice=" + price + @@ -1507,7 +1481,6 @@ public abstract class Trade implements Tradable, Model { ",\n disputeStateProperty=" + disputeStateProperty + ",\n tradePeriodStateProperty=" + tradePeriodStateProperty + ",\n errorMessageProperty=" + errorMessageProperty + - ",\n delayedPayoutTx=" + delayedPayoutTx + ",\n payoutTx=" + payoutTx + ",\n tradeAmount=" + tradeAmount + ",\n tradeAmountProperty=" + tradeAmountProperty + @@ -1515,7 +1488,6 @@ public abstract class Trade implements Tradable, Model { ",\n mediationResultState=" + mediationResultState + ",\n mediationResultStateProperty=" + mediationResultStateProperty + ",\n lockTime=" + lockTime + - ",\n delayedPayoutTxBytes=" + Utilities.bytesAsHexString(delayedPayoutTxBytes) + ",\n refundResultState=" + refundResultState + ",\n refundResultStateProperty=" + refundResultStateProperty + "\n}"; diff --git a/core/src/main/java/bisq/core/trade/TradeManager.java b/core/src/main/java/bisq/core/trade/TradeManager.java index 82265a4475..08eb7d48bb 100644 --- a/core/src/main/java/bisq/core/trade/TradeManager.java +++ b/core/src/main/java/bisq/core/trade/TradeManager.java @@ -155,9 +155,6 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi @Getter private final LongProperty numPendingTrades = new SimpleLongProperty(); private final ReferralIdService referralIdService; - private final DumpDelayedPayoutTx dumpDelayedPayoutTx; - @Getter - private final boolean allowFaultyDelayedTxs; /////////////////////////////////////////////////////////////////////////////////////////// @@ -183,9 +180,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi ProcessModelServiceProvider processModelServiceProvider, ClockWatcher clockWatcher, PersistenceManager> persistenceManager, - ReferralIdService referralIdService, - DumpDelayedPayoutTx dumpDelayedPayoutTx, - @Named(Config.ALLOW_FAULTY_DELAYED_TXS) boolean allowFaultyDelayedTxs) { + ReferralIdService referralIdService) { this.user = user; this.keyRing = keyRing; this.xmrWalletService = xmrWalletService; @@ -204,8 +199,6 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi this.processModelServiceProvider = processModelServiceProvider; this.clockWatcher = clockWatcher; this.referralIdService = referralIdService; - this.dumpDelayedPayoutTx = dumpDelayedPayoutTx; - this.allowFaultyDelayedTxs = allowFaultyDelayedTxs; this.persistenceManager = persistenceManager; this.persistenceManager.initialize(tradableList, "PendingTrades", PersistenceManager.Source.PRIVATE); @@ -227,7 +220,6 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi tradableList.stream() .filter(trade -> trade.getOffer() != null) .forEach(trade -> trade.getOffer().setPriceFeedService(priceFeedService)); - dumpDelayedPayoutTx.maybeDumpDelayedPayoutTxs(tradableList, "delayed_payout_txs_pending"); completeHandler.run(); }, completeHandler); @@ -338,7 +330,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi /////////////////////////////////////////////////////////////////////////////////////////// private void initPersistedTrades() { - + // open trades in parallel since each may open a multisig wallet List trades = tradableList.getList(); if (!trades.isEmpty()) { @@ -359,7 +351,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi throw new RuntimeException(e); } } - + persistedTradesInitialized.set(true); // We do not include failed trades as they should not be counted anyway in the trade statistics @@ -1037,7 +1029,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi else return offer.getDirection() == OfferDirection.SELL; } - + // TODO (woodser): make Optional versus Trade return types consistent public Trade getTrade(String tradeId) { return getOpenTrade(tradeId).orElseGet(() -> getClosedTrade(tradeId).orElseGet(() -> null)); @@ -1062,23 +1054,23 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi log.info("TradeManager.maybeRemoveTrade()"); synchronized(tradableList) { if (!tradableList.contains(trade)) return; - + // delete trade if not possibly funded if (trade.getPhase().ordinal() < Trade.Phase.DEPOSIT_REQUESTED.ordinal() || trade.getPhase().ordinal() >= Trade.Phase.PAYOUT_PUBLISHED.ordinal()) { // TODO: delete after payout unlocked - + // remove trade tradableList.remove(trade); - + // unreserve trade key images if (trade instanceof TakerTrade && trade.getSelf().getReserveTxKeyImages() != null) { for (String keyImage : trade.getSelf().getReserveTxKeyImages()) { xmrWalletService.getWallet().thawOutput(keyImage); } } - + // delete multisig wallet deleteTradeWallet(trade); - + // unregister and persist p2PService.removeDecryptedDirectMessageListener(getTradeProtocol(trade)); requestPersistence(); diff --git a/core/src/main/java/bisq/core/trade/TradeModule.java b/core/src/main/java/bisq/core/trade/TradeModule.java index 10fde10ecd..c74a3d75fe 100644 --- a/core/src/main/java/bisq/core/trade/TradeModule.java +++ b/core/src/main/java/bisq/core/trade/TradeModule.java @@ -29,8 +29,6 @@ import bisq.common.config.Config; import com.google.inject.Singleton; -import static bisq.common.config.Config.ALLOW_FAULTY_DELAYED_TXS; -import static bisq.common.config.Config.DUMP_DELAYED_PAYOUT_TXS; import static bisq.common.config.Config.DUMP_STATISTICS; import static com.google.inject.name.Names.named; @@ -52,7 +50,5 @@ public class TradeModule extends AppModule { bind(ReferralIdService.class).in(Singleton.class); bindConstant().annotatedWith(named(DUMP_STATISTICS)).to(config.dumpStatistics); - bindConstant().annotatedWith(named(DUMP_DELAYED_PAYOUT_TXS)).to(config.dumpDelayedPayoutTxs); - bindConstant().annotatedWith(named(ALLOW_FAULTY_DELAYED_TXS)).to(config.allowFaultyDelayedTxs); } } diff --git a/core/src/main/java/bisq/core/trade/failed/FailedTradesManager.java b/core/src/main/java/bisq/core/trade/failed/FailedTradesManager.java index 655ea8f29a..141016ee9f 100644 --- a/core/src/main/java/bisq/core/trade/failed/FailedTradesManager.java +++ b/core/src/main/java/bisq/core/trade/failed/FailedTradesManager.java @@ -22,7 +22,6 @@ import bisq.core.btc.wallet.XmrWalletService; import bisq.core.offer.Offer; import bisq.core.provider.price.PriceFeedService; import bisq.core.trade.CleanupMailboxMessages; -import bisq.core.trade.DumpDelayedPayoutTx; import bisq.core.trade.TradableList; import bisq.core.trade.Trade; import bisq.core.trade.TradeUtil; @@ -52,7 +51,6 @@ public class FailedTradesManager implements PersistedDataHost { private final CleanupMailboxMessages cleanupMailboxMessages; private final PersistenceManager> persistenceManager; private final TradeUtil tradeUtil; - private final DumpDelayedPayoutTx dumpDelayedPayoutTx; @Setter private Function unFailTradeCallback; @@ -62,13 +60,11 @@ public class FailedTradesManager implements PersistedDataHost { XmrWalletService xmrWalletService, PersistenceManager> persistenceManager, TradeUtil tradeUtil, - CleanupMailboxMessages cleanupMailboxMessages, - DumpDelayedPayoutTx dumpDelayedPayoutTx) { + CleanupMailboxMessages cleanupMailboxMessages) { this.keyRing = keyRing; this.priceFeedService = priceFeedService; this.xmrWalletService = xmrWalletService; this.cleanupMailboxMessages = cleanupMailboxMessages; - this.dumpDelayedPayoutTx = dumpDelayedPayoutTx; this.persistenceManager = persistenceManager; this.tradeUtil = tradeUtil; @@ -82,7 +78,6 @@ public class FailedTradesManager implements PersistedDataHost { failedTrades.stream() .filter(trade -> trade.getOffer() != null) .forEach(trade -> trade.getOffer().setPriceFeedService(priceFeedService)); - dumpDelayedPayoutTx.maybeDumpDelayedPayoutTxs(failedTrades, "delayed_payout_txs_failed"); completeHandler.run(); }, completeHandler); diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/TakerReserveTradeFunds.java b/core/src/main/java/bisq/core/trade/protocol/tasks/TakerReserveTradeFunds.java index f2bda4ce57..04982408b5 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/TakerReserveTradeFunds.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/TakerReserveTradeFunds.java @@ -52,13 +52,11 @@ public class TakerReserveTradeFunds extends TradeTask { // collect reserved key images // TODO (woodser): switch to proof of reserve? List reservedKeyImages = new ArrayList(); for (MoneroOutput input : reserveTx.getInputs()) reservedKeyImages.add(input.getKeyImage().getHex()); - + // save process state - // TODO (woodser): persist processModel.setReserveTx(reserveTx); processModel.getTaker().setReserveTxKeyImages(reservedKeyImages); - trade.setTakerFeeTxId(reserveTx.getHash()); // TODO (woodser): this should be multisig deposit tx id? how is it used? - //trade.setState(Trade.State.TAKER_PUBLISHED_TAKER_FEE_TX); // TODO (woodser): fee tx is not broadcast separate, update states + complete(); } catch (Throwable t) { trade.setErrorMessage("An error occurred.\n" + diff --git a/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionAwareTrade.java b/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionAwareTrade.java index 108bcd2ab3..0cb7fb1226 100644 --- a/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionAwareTrade.java +++ b/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionAwareTrade.java @@ -60,14 +60,13 @@ class TransactionAwareTrade implements TransactionAwareTradable { public boolean isRelatedToTransaction(MoneroTxWallet transaction) { String txId = transaction.getHash(); - boolean isTakerOfferFeeTx = txId.equals(trade.getTakerFeeTxId()); boolean isOfferFeeTx = isOfferFeeTx(txId); boolean isMakerDepositTx = isMakerDepositTx(txId); boolean isTakerDepositTx = isTakerDepositTx(txId); boolean isPayoutTx = isPayoutTx(txId); boolean isDisputedPayoutTx = isDisputedPayoutTx(txId); - return isTakerOfferFeeTx || isOfferFeeTx || isMakerDepositTx || isTakerDepositTx || + return isOfferFeeTx || isMakerDepositTx || isTakerDepositTx || isPayoutTx || isDisputedPayoutTx; } diff --git a/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionsListItem.java b/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionsListItem.java index 58c29bdcf5..3d1f53f3c6 100644 --- a/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionsListItem.java +++ b/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionsListItem.java @@ -90,7 +90,7 @@ class TransactionsListItem { this.formatter = formatter; this.memo = tx.getNote(); this.txId = tx.getHash(); - + Optional optionalTradable = Optional.ofNullable(transactionAwareTradable) .map(TransactionAwareTradable::asTradable); @@ -123,48 +123,45 @@ class TransactionsListItem { details = Res.get("funds.tx.createOfferFee", tradeId); } else if (tradable instanceof Trade) { Trade trade = (Trade) tradable; - if (trade.getTakerFeeTxId() != null && trade.getTakerFeeTxId().equals(txId)) { - details = Res.get("funds.tx.takeOfferFee", tradeId); - } else { - Offer offer = trade.getOffer(); - String offerFeePaymentTxID = offer.getOfferFeePaymentTxId(); - if (offerFeePaymentTxID != null && offerFeePaymentTxID.equals(txId)) { - details = Res.get("funds.tx.createOfferFee", tradeId); - } else if (trade.getSelf().getDepositTxHash() != null && - trade.getSelf().getDepositTxHash().equals(txId)) { - details = Res.get("funds.tx.multiSigDeposit", tradeId); - } else if (trade.getPayoutTxId() != null && - trade.getPayoutTxId().equals(txId)) { - details = Res.get("funds.tx.multiSigPayout", tradeId); - if (amountAsCoin.isZero()) { + + Offer offer = trade.getOffer(); + String offerFeePaymentTxID = offer.getOfferFeePaymentTxId(); + if (offerFeePaymentTxID != null && offerFeePaymentTxID.equals(txId)) { + details = Res.get("funds.tx.createOfferFee", tradeId); + } else if (trade.getSelf().getDepositTxHash() != null && + trade.getSelf().getDepositTxHash().equals(txId)) { + details = Res.get("funds.tx.multiSigDeposit", tradeId); + } else if (trade.getPayoutTxId() != null && + trade.getPayoutTxId().equals(txId)) { + details = Res.get("funds.tx.multiSigPayout", tradeId); + if (amountAsCoin.isZero()) { initialTxConfidenceVisibility = false; - } - } else { - Trade.DisputeState disputeState = trade.getDisputeState(); - if (disputeState == Trade.DisputeState.DISPUTE_CLOSED) { - if (valueSentToMe.isPositive()) { - details = Res.get("funds.tx.disputePayout", tradeId); - } else { - details = Res.get("funds.tx.disputeLost", tradeId); - } - } else if (disputeState == Trade.DisputeState.REFUND_REQUEST_CLOSED || - disputeState == Trade.DisputeState.REFUND_REQUESTED || - disputeState == Trade.DisputeState.REFUND_REQUEST_STARTED_BY_PEER) { - if (valueSentToMe.isPositive()) { - details = Res.get("funds.tx.refund", tradeId); - } else { - // We have spent the deposit tx outputs to the Bisq donation address to enable - // the refund process (refund agent -> reimbursement). As the funds have left our wallet - // already when funding the deposit tx we show 0 BTC as amount. - // Confirmation is not known from the BitcoinJ side (not 100% clear why) as no funds - // left our wallet nor we received funds. So we set indicator invisible. - amountAsCoin = Coin.ZERO; - details = Res.get("funds.tx.collateralForRefund", tradeId); - initialTxConfidenceVisibility = false; - } + } + } else { + Trade.DisputeState disputeState = trade.getDisputeState(); + if (disputeState == Trade.DisputeState.DISPUTE_CLOSED) { + if (valueSentToMe.isPositive()) { + details = Res.get("funds.tx.disputePayout", tradeId); } else { - details = Res.get("funds.tx.unknown", tradeId); + details = Res.get("funds.tx.disputeLost", tradeId); } + } else if (disputeState == Trade.DisputeState.REFUND_REQUEST_CLOSED || + disputeState == Trade.DisputeState.REFUND_REQUESTED || + disputeState == Trade.DisputeState.REFUND_REQUEST_STARTED_BY_PEER) { + if (valueSentToMe.isPositive()) { + details = Res.get("funds.tx.refund", tradeId); + } else { + // We have spent the deposit tx outputs to the Bisq donation address to enable + // the refund process (refund agent -> reimbursement). As the funds have left our wallet + // already when funding the deposit tx we show 0 BTC as amount. + // Confirmation is not known from the BitcoinJ side (not 100% clear why) as no funds + // left our wallet nor we received funds. So we set indicator invisible. + amountAsCoin = Coin.ZERO; + details = Res.get("funds.tx.collateralForRefund", tradeId); + initialTxConfidenceVisibility = false; + } + } else { + details = Res.get("funds.tx.unknown", tradeId); } } } @@ -183,7 +180,7 @@ class TransactionsListItem { if (isDustAttackTx) { details = Res.get("funds.tx.dustAttackTx"); } - + // confidence lazyFieldsSupplier = Suppliers.memoize(() -> new LazyFields() {{ txConfidenceIndicator = new TxConfidenceIndicator(); diff --git a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java index f22f2dd290..0c4d953e93 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java @@ -445,16 +445,11 @@ class TakeOfferViewModel extends ActivatableWithDataModel im private void applyTradeState() { if (trade.isTakerFeePublished()) { - if (trade.getTakerFeeTxId() != null) { - if (takeOfferResultHandler != null) - takeOfferResultHandler.run(); + if (takeOfferResultHandler != null) + takeOfferResultHandler.run(); - showTransactionPublishedScreen.set(true); - updateSpinnerInfo(); - } else { - final String msg = "trade.getTakerFeeTxId() must not be null."; - DevEnv.logErrorAndThrowIfDevMode(msg); - } + showTransactionPublishedScreen.set(true); + updateSpinnerInfo(); } } diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/TradeDetailsWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/TradeDetailsWindow.java index 643ad89c32..cf10a09cc7 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/TradeDetailsWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/TradeDetailsWindow.java @@ -274,7 +274,6 @@ public class TradeDetailsWindow extends Overlay { } addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.makerFeeTxId"), offer.getOfferFeePaymentTxId()); - addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.takerFeeTxId"), trade.getTakerFeeTxId()); if (trade.getMakerDepositTx() != null) addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.depositTransactionId"), // TODO (woodser): separate UI labels for deposit tx ids diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesView.java b/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesView.java index de6b195e8a..57583348c9 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesView.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesView.java @@ -107,15 +107,12 @@ public class FailedTradesView extends ActivatableViewAndModel keyEventEventHandler; private ChangeListener filterTextFieldListener; private Scene scene; - private final boolean allowFaultyDelayedTxs; @Inject public FailedTradesView(FailedTradesViewModel model, - TradeDetailsWindow tradeDetailsWindow, - @Named(Config.ALLOW_FAULTY_DELAYED_TXS) boolean allowFaultyDelayedTxs) { + TradeDetailsWindow tradeDetailsWindow) { super(model); this.tradeDetailsWindow = tradeDetailsWindow; - this.allowFaultyDelayedTxs = allowFaultyDelayedTxs; } @Override @@ -279,9 +276,6 @@ public class FailedTradesView extends ActivatableViewAndModel