fix trade is in an invalid state warning

Co-authored-by: duriancrepe <duriancrepe@protonmail.com>
This commit is contained in:
woodser 2022-10-17 11:22:01 -04:00
parent 14c5384edc
commit e79450f65e
21 changed files with 101 additions and 293 deletions

View file

@ -3,5 +3,4 @@
# Haveno Config options not configurable in test harness-specific apitest.properties # Haveno Config options not configurable in test harness-specific apitest.properties
# file. This is where you might define Haveno options such as: # file. This is where you might define Haveno options such as:
# dumpBlockchainData=true # dumpBlockchainData=true
# dumpDelayedPayoutTxs=true
# dumpStatistics=true # dumpStatistics=true

View file

@ -107,8 +107,6 @@ public class Config {
public static final String USE_ALL_PROVIDED_NODES = "useAllProvidedNodes"; public static final String USE_ALL_PROVIDED_NODES = "useAllProvidedNodes";
public static final String USER_AGENT = "userAgent"; public static final String USER_AGENT = "userAgent";
public static final String NUM_CONNECTIONS_FOR_BTC = "numConnectionsForBtc"; 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_PASSWORD = "apiPassword";
public static final String API_PORT = "apiPort"; public static final String API_PORT = "apiPort";
public static final String PREVENT_PERIODIC_SHUTDOWN_AT_SEED_NODE = "preventPeriodicShutdownAtSeedNode"; public static final String PREVENT_PERIODIC_SHUTDOWN_AT_SEED_NODE = "preventPeriodicShutdownAtSeedNode";
@ -192,8 +190,6 @@ public class Config {
public final boolean useAllProvidedNodes; public final boolean useAllProvidedNodes;
public final String userAgent; public final String userAgent;
public final int numConnectionsForBtc; public final int numConnectionsForBtc;
public final boolean dumpDelayedPayoutTxs;
public final boolean allowFaultyDelayedTxs;
public final String apiPassword; public final String apiPassword;
public final int apiPort; public final int apiPort;
public final boolean preventPeriodicShutdownAtSeedNode; public final boolean preventPeriodicShutdownAtSeedNode;
@ -559,19 +555,6 @@ public class Config {
.ofType(int.class) .ofType(int.class)
.defaultsTo(DEFAULT_NUM_CONNECTIONS_FOR_BTC); .defaultsTo(DEFAULT_NUM_CONNECTIONS_FOR_BTC);
ArgumentAcceptingOptionSpec<Boolean> dumpDelayedPayoutTxsOpt =
parser.accepts(DUMP_DELAYED_PAYOUT_TXS, "Dump delayed payout transactions to file")
.withRequiredArg()
.ofType(boolean.class)
.defaultsTo(false);
ArgumentAcceptingOptionSpec<Boolean> allowFaultyDelayedTxsOpt =
parser.accepts(ALLOW_FAULTY_DELAYED_TXS, "Allow completion of trades with faulty delayed " +
"payout transactions")
.withRequiredArg()
.ofType(boolean.class)
.defaultsTo(false);
ArgumentAcceptingOptionSpec<String> apiPasswordOpt = ArgumentAcceptingOptionSpec<String> apiPasswordOpt =
parser.accepts(API_PASSWORD, "gRPC API password") parser.accepts(API_PASSWORD, "gRPC API password")
.withRequiredArg() .withRequiredArg()
@ -714,8 +697,6 @@ public class Config {
this.userAgent = options.valueOf(userAgentOpt); this.userAgent = options.valueOf(userAgentOpt);
this.numConnectionsForBtc = options.valueOf(numConnectionsForBtcOpt); this.numConnectionsForBtc = options.valueOf(numConnectionsForBtcOpt);
this.dumpDelayedPayoutTxs = options.valueOf(dumpDelayedPayoutTxsOpt);
this.allowFaultyDelayedTxs = options.valueOf(allowFaultyDelayedTxsOpt);
this.apiPassword = options.valueOf(apiPasswordOpt); this.apiPassword = options.valueOf(apiPasswordOpt);
this.apiPort = options.valueOf(apiPortOpt); this.apiPort = options.valueOf(apiPortOpt);
this.preventPeriodicShutdownAtSeedNode = options.valueOf(preventPeriodicShutdownAtSeedNodeOpt); this.preventPeriodicShutdownAtSeedNode = options.valueOf(preventPeriodicShutdownAtSeedNodeOpt);

View file

@ -68,7 +68,6 @@ public class TradeInfo implements Payload {
private final String role; private final String role;
private final long txFeeAsLong; private final long txFeeAsLong;
private final long takerFeeAsLong; private final long takerFeeAsLong;
private final String takerFeeTxId;
private final String makerDepositTxId; private final String makerDepositTxId;
private final String takerDepositTxId; private final String takerDepositTxId;
private final String payoutTxId; private final String payoutTxId;
@ -97,7 +96,6 @@ public class TradeInfo implements Payload {
this.role = builder.getRole(); this.role = builder.getRole();
this.txFeeAsLong = builder.getTxFeeAsLong(); this.txFeeAsLong = builder.getTxFeeAsLong();
this.takerFeeAsLong = builder.getTakerFeeAsLong(); this.takerFeeAsLong = builder.getTakerFeeAsLong();
this.takerFeeTxId = builder.getTakerFeeTxId();
this.makerDepositTxId = builder.getMakerDepositTxId(); this.makerDepositTxId = builder.getMakerDepositTxId();
this.takerDepositTxId = builder.getTakerDepositTxId(); this.takerDepositTxId = builder.getTakerDepositTxId();
this.payoutTxId = builder.getPayoutTxId(); this.payoutTxId = builder.getPayoutTxId();
@ -141,7 +139,7 @@ public class TradeInfo implements Payload {
} else { } else {
contractInfo = ContractInfo.emptyContract.get(); contractInfo = ContractInfo.emptyContract.get();
} }
return new TradeInfoV1Builder() return new TradeInfoV1Builder()
.withTradeId(trade.getId()) .withTradeId(trade.getId())
.withShortId(trade.getShortId()) .withShortId(trade.getShortId())
@ -149,7 +147,6 @@ public class TradeInfo implements Payload {
.withRole(role == null ? "" : role) .withRole(role == null ? "" : role)
.withTxFeeAsLong(trade.getTxFeeAsLong()) .withTxFeeAsLong(trade.getTxFeeAsLong())
.withTakerFeeAsLong(trade.getTakerFeeAsLong()) .withTakerFeeAsLong(trade.getTakerFeeAsLong())
.withTakerFeeTxId(trade.getTakerFeeTxId())
.withMakerDepositTxId(trade.getMaker().getDepositTxHash()) .withMakerDepositTxId(trade.getMaker().getDepositTxHash())
.withTakerDepositTxId(trade.getTaker().getDepositTxHash()) .withTakerDepositTxId(trade.getTaker().getDepositTxHash())
.withPayoutTxId(trade.getPayoutTxId()) .withPayoutTxId(trade.getPayoutTxId())
@ -187,7 +184,6 @@ public class TradeInfo implements Payload {
.setRole(role) .setRole(role)
.setTxFeeAsLong(txFeeAsLong) .setTxFeeAsLong(txFeeAsLong)
.setTakerFeeAsLong(takerFeeAsLong) .setTakerFeeAsLong(takerFeeAsLong)
.setTakerFeeTxId(takerFeeTxId == null ? "" : takerFeeTxId)
.setMakerDepositTxId(makerDepositTxId == null ? "" : makerDepositTxId) .setMakerDepositTxId(makerDepositTxId == null ? "" : makerDepositTxId)
.setTakerDepositTxId(takerDepositTxId == null ? "" : takerDepositTxId) .setTakerDepositTxId(takerDepositTxId == null ? "" : takerDepositTxId)
.setPayoutTxId(payoutTxId == null ? "" : payoutTxId) .setPayoutTxId(payoutTxId == null ? "" : payoutTxId)
@ -219,7 +215,6 @@ public class TradeInfo implements Payload {
.withRole(proto.getRole()) .withRole(proto.getRole())
.withTxFeeAsLong(proto.getTxFeeAsLong()) .withTxFeeAsLong(proto.getTxFeeAsLong())
.withTakerFeeAsLong(proto.getTakerFeeAsLong()) .withTakerFeeAsLong(proto.getTakerFeeAsLong())
.withTakerFeeTxId(proto.getTakerFeeTxId())
.withMakerDepositTxId(proto.getMakerDepositTxId()) .withMakerDepositTxId(proto.getMakerDepositTxId())
.withTakerDepositTxId(proto.getTakerDepositTxId()) .withTakerDepositTxId(proto.getTakerDepositTxId())
.withPayoutTxId(proto.getPayoutTxId()) .withPayoutTxId(proto.getPayoutTxId())
@ -251,7 +246,6 @@ public class TradeInfo implements Payload {
", role='" + role + '\'' + "\n" + ", role='" + role + '\'' + "\n" +
", txFeeAsLong='" + txFeeAsLong + '\'' + "\n" + ", txFeeAsLong='" + txFeeAsLong + '\'' + "\n" +
", takerFeeAsLong='" + takerFeeAsLong + '\'' + "\n" + ", takerFeeAsLong='" + takerFeeAsLong + '\'' + "\n" +
", takerFeeTxId='" + takerFeeTxId + '\'' + "\n" +
", makerDepositTxId='" + makerDepositTxId + '\'' + "\n" + ", makerDepositTxId='" + makerDepositTxId + '\'' + "\n" +
", takerDepositTxId='" + takerDepositTxId + '\'' + "\n" + ", takerDepositTxId='" + takerDepositTxId + '\'' + "\n" +
", payoutTxId='" + payoutTxId + '\'' + "\n" + ", payoutTxId='" + payoutTxId + '\'' + "\n" +

View file

@ -40,7 +40,6 @@ public final class TradeInfoV1Builder {
private boolean isCurrencyForTakerFeeBtc; private boolean isCurrencyForTakerFeeBtc;
private long txFeeAsLong; private long txFeeAsLong;
private long takerFeeAsLong; private long takerFeeAsLong;
private String takerFeeTxId;
private String makerDepositTxId; private String makerDepositTxId;
private String takerDepositTxId; private String takerDepositTxId;
private String payoutTxId; private String payoutTxId;
@ -102,11 +101,6 @@ public final class TradeInfoV1Builder {
return this; return this;
} }
public TradeInfoV1Builder withTakerFeeTxId(String takerFeeTxId) {
this.takerFeeTxId = takerFeeTxId;
return this;
}
public TradeInfoV1Builder withMakerDepositTxId(String makerDepositTxId) { public TradeInfoV1Builder withMakerDepositTxId(String makerDepositTxId) {
this.makerDepositTxId = makerDepositTxId; this.makerDepositTxId = makerDepositTxId;
return this; return this;

View file

@ -255,7 +255,7 @@ public class WalletAppSetup {
if (txId.equals(trade.getTaker().getDepositTxHash())) { if (txId.equals(trade.getTaker().getDepositTxHash())) {
details = Res.get("popup.warning.trade.txRejected.deposit"); 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"); details = Res.get("popup.warning.trade.txRejected.tradeFee");
} }

View file

@ -71,7 +71,6 @@ public class ClosedTradableManager implements PersistedDataHost {
private final TradeStatisticsManager tradeStatisticsManager; private final TradeStatisticsManager tradeStatisticsManager;
private final PersistenceManager<TradableList<Tradable>> persistenceManager; private final PersistenceManager<TradableList<Tradable>> persistenceManager;
private final CleanupMailboxMessagesService cleanupMailboxMessagesService; private final CleanupMailboxMessagesService cleanupMailboxMessagesService;
private final DumpDelayedPayoutTx dumpDelayedPayoutTx;
private final TradableList<Tradable> closedTradables = new TradableList<>(); private final TradableList<Tradable> closedTradables = new TradableList<>();
@ -81,14 +80,12 @@ public class ClosedTradableManager implements PersistedDataHost {
Preferences preferences, Preferences preferences,
TradeStatisticsManager tradeStatisticsManager, TradeStatisticsManager tradeStatisticsManager,
PersistenceManager<TradableList<Tradable>> persistenceManager, PersistenceManager<TradableList<Tradable>> persistenceManager,
CleanupMailboxMessagesService cleanupMailboxMessagesService, CleanupMailboxMessagesService cleanupMailboxMessagesService) {
DumpDelayedPayoutTx dumpDelayedPayoutTx) {
this.keyRing = keyRing; this.keyRing = keyRing;
this.priceFeedService = priceFeedService; this.priceFeedService = priceFeedService;
this.preferences = preferences; this.preferences = preferences;
this.tradeStatisticsManager = tradeStatisticsManager; this.tradeStatisticsManager = tradeStatisticsManager;
this.cleanupMailboxMessagesService = cleanupMailboxMessagesService; this.cleanupMailboxMessagesService = cleanupMailboxMessagesService;
this.dumpDelayedPayoutTx = dumpDelayedPayoutTx;
this.persistenceManager = persistenceManager; this.persistenceManager = persistenceManager;
this.persistenceManager.initialize(closedTradables, "ClosedTrades", PersistenceManager.Source.PRIVATE); this.persistenceManager.initialize(closedTradables, "ClosedTrades", PersistenceManager.Source.PRIVATE);
@ -101,7 +98,6 @@ public class ClosedTradableManager implements PersistedDataHost {
closedTradables.stream() closedTradables.stream()
.filter(tradable -> tradable.getOffer() != null) .filter(tradable -> tradable.getOffer() != null)
.forEach(tradable -> tradable.getOffer().setPriceFeedService(priceFeedService)); .forEach(tradable -> tradable.getOffer().setPriceFeedService(priceFeedService));
dumpDelayedPayoutTx.maybeDumpDelayedPayoutTxs(closedTradables, "delayed_payout_txs_closed");
completeHandler.run(); completeHandler.run();
}, },
completeHandler); completeHandler);

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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 <T extends Tradable> void maybeDumpDelayedPayoutTxs(TradableList<T> 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);
}
}

View file

@ -310,10 +310,6 @@ public abstract class Trade implements Tradable, Model {
@Nullable @Nullable
@Getter @Getter
@Setter @Setter
private String takerFeeTxId;
@Nullable
@Getter
@Setter
private long amountAsLong; private long amountAsLong;
@Setter @Setter
private long price; private long price;
@ -359,15 +355,13 @@ public abstract class Trade implements Tradable, Model {
transient final private ObjectProperty<DisputeState> disputeStateProperty = new SimpleObjectProperty<>(disputeState); transient final private ObjectProperty<DisputeState> disputeStateProperty = new SimpleObjectProperty<>(disputeState);
transient final private ObjectProperty<TradePeriodState> tradePeriodStateProperty = new SimpleObjectProperty<>(periodState); transient final private ObjectProperty<TradePeriodState> tradePeriodStateProperty = new SimpleObjectProperty<>(periodState);
transient final private StringProperty errorMessageProperty = new SimpleStringProperty(); transient final private StringProperty errorMessageProperty = new SimpleStringProperty();
// Mutable // Mutable
@Getter @Getter
transient private boolean isInitialized; transient private boolean isInitialized;
// Added in v1.2.0 // Added in v1.2.0
@Nullable @Nullable
transient private Transaction delayedPayoutTx;
@Nullable
transient private Coin tradeAmount; transient private Coin tradeAmount;
transient private ObjectProperty<Coin> tradeAmountProperty; transient private ObjectProperty<Coin> tradeAmountProperty;
@ -383,10 +377,6 @@ public abstract class Trade implements Tradable, Model {
@Getter @Getter
@Setter @Setter
private long lockTime; private long lockTime;
@Nullable
@Getter
@Setter
private byte[] delayedPayoutTxBytes;
@Getter @Getter
@Nullable @Nullable
private RefundResultState refundResultState = RefundResultState.UNDEFINED_REFUND_RESULT; private RefundResultState refundResultState = RefundResultState.UNDEFINED_REFUND_RESULT;
@ -458,11 +448,11 @@ public abstract class Trade implements Tradable, Model {
this.takerFeeAsLong = takerFee.value; this.takerFeeAsLong = takerFee.value;
this.takeOfferDate = new Date().getTime(); this.takeOfferDate = new Date().getTime();
this.tradeListeners = new ArrayList<TradeListener>(); this.tradeListeners = new ArrayList<TradeListener>();
getMaker().setNodeAddress(makerNodeAddress); getMaker().setNodeAddress(makerNodeAddress);
getTaker().setNodeAddress(takerNodeAddress); getTaker().setNodeAddress(takerNodeAddress);
getArbitrator().setNodeAddress(arbitratorNodeAddress); getArbitrator().setNodeAddress(arbitratorNodeAddress);
setAmount(tradeAmount); setAmount(tradeAmount);
} }
@ -548,7 +538,6 @@ public abstract class Trade implements Tradable, Model {
.setLockTime(lockTime) .setLockTime(lockTime)
.setUid(uid); .setUid(uid);
Optional.ofNullable(takerFeeTxId).ifPresent(builder::setTakerFeeTxId);
Optional.ofNullable(payoutTxId).ifPresent(builder::setPayoutTxId); Optional.ofNullable(payoutTxId).ifPresent(builder::setPayoutTxId);
Optional.ofNullable(contract).ifPresent(e -> builder.setContract(contract.toProtoMessage())); Optional.ofNullable(contract).ifPresent(e -> builder.setContract(contract.toProtoMessage()));
Optional.ofNullable(contractAsJson).ifPresent(builder::setContractAsJson); 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(refundResultState).ifPresent(e -> builder.setRefundResultState(RefundResultState.toProtoMessage(refundResultState)));
Optional.ofNullable(payoutTxHex).ifPresent(e -> builder.setPayoutTxHex(payoutTxHex)); Optional.ofNullable(payoutTxHex).ifPresent(e -> builder.setPayoutTxHex(payoutTxHex));
Optional.ofNullable(payoutTxKey).ifPresent(e -> builder.setPayoutTxHex(payoutTxKey)); 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(counterCurrencyExtraData).ifPresent(e -> builder.setCounterCurrencyExtraData(counterCurrencyExtraData));
Optional.ofNullable(assetTxProofResult).ifPresent(e -> builder.setAssetTxProofResult(assetTxProofResult.name())); Optional.ofNullable(assetTxProofResult).ifPresent(e -> builder.setAssetTxProofResult(assetTxProofResult.name()));
return builder.build(); return builder.build();
@ -570,7 +558,6 @@ public abstract class Trade implements Tradable, Model {
trade.setState(State.fromProto(proto.getState())); trade.setState(State.fromProto(proto.getState()));
trade.setDisputeState(DisputeState.fromProto(proto.getDisputeState())); trade.setDisputeState(DisputeState.fromProto(proto.getDisputeState()));
trade.setPeriodState(TradePeriodState.fromProto(proto.getPeriodState())); trade.setPeriodState(TradePeriodState.fromProto(proto.getPeriodState()));
trade.setTakerFeeTxId(ProtoUtil.stringOrNullFromProto(proto.getTakerFeeTxId()));
trade.setPayoutTxId(ProtoUtil.stringOrNullFromProto(proto.getPayoutTxId())); trade.setPayoutTxId(ProtoUtil.stringOrNullFromProto(proto.getPayoutTxId()));
trade.setPayoutTxHex(ProtoUtil.stringOrNullFromProto(proto.getPayoutTxHex())); trade.setPayoutTxHex(ProtoUtil.stringOrNullFromProto(proto.getPayoutTxHex()));
trade.setPayoutTxKey(ProtoUtil.stringOrNullFromProto(proto.getPayoutTxKey())); 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.setCounterCurrencyTxId(proto.getCounterCurrencyTxId().isEmpty() ? null : proto.getCounterCurrencyTxId());
trade.setMediationResultState(MediationResultState.fromProto(proto.getMediationResultState())); trade.setMediationResultState(MediationResultState.fromProto(proto.getMediationResultState()));
trade.setRefundResultState(RefundResultState.fromProto(proto.getRefundResultState())); trade.setRefundResultState(RefundResultState.fromProto(proto.getRefundResultState()));
trade.setDelayedPayoutTxBytes(ProtoUtil.byteArrayOrNullFromProto(proto.getDelayedPayoutTxBytes()));
trade.setLockTime(proto.getLockTime()); trade.setLockTime(proto.getLockTime());
trade.setCounterCurrencyExtraData(ProtoUtil.stringOrNullFromProto(proto.getCounterCurrencyExtraData())); 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. * Create a contract based on the current state.
* *
* @param trade is the trade to create the contract from * @param trade is the trade to create the contract from
* @return the contract * @return the contract
*/ */
@ -659,7 +645,7 @@ public abstract class Trade implements Tradable, Model {
/** /**
* Create the payout tx. * Create the payout tx.
* *
* @return MoneroTxWallet the payout tx when the trade is successfully completed * @return MoneroTxWallet the payout tx when the trade is successfully completed
*/ */
public MoneroTxWallet createPayoutTx() { public MoneroTxWallet createPayoutTx() {
@ -711,7 +697,7 @@ public abstract class Trade implements Tradable, Model {
/** /**
* Verify a payout tx. * Verify a payout tx.
* *
* @param payoutTxHex is the payout tx hex to verify * @param payoutTxHex is the payout tx hex to verify
* @param sign signs the payout tx if true * @param sign signs the payout tx if true
* @param publish publishes the signed 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. * Decrypt the peer's payment account payload using the given key.
* *
* @param paymentAccountKey is the key to decrypt the payment account payload * @param paymentAccountKey is the key to decrypt the payment account payload
*/ */
public void decryptPeersPaymentAccountPayload(byte[] paymentAccountKey) { 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. * Listen for deposit transactions to unlock and then apply the transactions.
* *
* TODO: adopt for general purpose scheduling * TODO: adopt for general purpose scheduling
* TODO: check and notify if deposits are dropped due to re-org * 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) { public void addAndPersistChatMessage(ChatMessage chatMessage) {
if (!chatMessages.contains(chatMessage)) { if (!chatMessages.contains(chatMessage)) {
chatMessages.add(chatMessage); chatMessages.add(chatMessage);
@ -1043,7 +1020,7 @@ public abstract class Trade implements Tradable, Model {
listener.onVerifiedTradeMessage(message, sender); listener.onVerifiedTradeMessage(message, sender);
} }
} }
// notified from TradeProtocol of ack messages // notified from TradeProtocol of ack messages
public void onAckMessage(AckMessage ackMessage, NodeAddress sender) { public void onAckMessage(AckMessage ackMessage, NodeAddress sender) {
for (TradeListener listener : new ArrayList<TradeListener>(tradeListeners)) { // copy array to allow listener invocation to unregister listener without concurrent modification exception for (TradeListener listener : new ArrayList<TradeListener>(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. * Get the taker if maker, maker if taker, null if arbitrator.
* *
* @return the trade peer * @return the trade peer
*/ */
public TradingPeer getTradingPeer() { public TradingPeer getTradingPeer() {
@ -1188,12 +1165,12 @@ public abstract class Trade implements Tradable, Model {
else if (this instanceof ArbitratorTrade) return null; else if (this instanceof ArbitratorTrade) return null;
else throw new RuntimeException("Unknown trade type: " + getClass().getName()); else throw new RuntimeException("Unknown trade type: " + getClass().getName());
} }
/** /**
* Get the peer with the given address which can be self. * Get the peer with the given address which can be self.
* *
* TODO (woodser): this naming convention is confusing * TODO (woodser): this naming convention is confusing
* *
* @param address is the address of the peer to get * @param address is the address of the peer to get
* @return the trade peer * @return the trade peer
*/ */
@ -1438,10 +1415,8 @@ public abstract class Trade implements Tradable, Model {
public boolean isTxChainInvalid() { public boolean isTxChainInvalid() {
return offer.getOfferFeePaymentTxId() == null || return offer.getOfferFeePaymentTxId() == null ||
getTakerFeeTxId() == null ||
processModel.getMaker().getDepositTxHash() == null || processModel.getMaker().getDepositTxHash() == null ||
processModel.getMaker().getDepositTxHash() == null || processModel.getTaker().getDepositTxHash() == null;
getDelayedPayoutTxBytes() == null;
} }
@ -1484,7 +1459,6 @@ public abstract class Trade implements Tradable, Model {
",\n takerFeeAsLong=" + takerFeeAsLong + ",\n takerFeeAsLong=" + takerFeeAsLong +
",\n takeOfferDate=" + takeOfferDate + ",\n takeOfferDate=" + takeOfferDate +
",\n processModel=" + processModel + ",\n processModel=" + processModel +
",\n takerFeeTxId='" + takerFeeTxId + '\'' +
",\n payoutTxId='" + payoutTxId + '\'' + ",\n payoutTxId='" + payoutTxId + '\'' +
",\n tradeAmountAsLong=" + amountAsLong + ",\n tradeAmountAsLong=" + amountAsLong +
",\n tradePrice=" + price + ",\n tradePrice=" + price +
@ -1507,7 +1481,6 @@ public abstract class Trade implements Tradable, Model {
",\n disputeStateProperty=" + disputeStateProperty + ",\n disputeStateProperty=" + disputeStateProperty +
",\n tradePeriodStateProperty=" + tradePeriodStateProperty + ",\n tradePeriodStateProperty=" + tradePeriodStateProperty +
",\n errorMessageProperty=" + errorMessageProperty + ",\n errorMessageProperty=" + errorMessageProperty +
",\n delayedPayoutTx=" + delayedPayoutTx +
",\n payoutTx=" + payoutTx + ",\n payoutTx=" + payoutTx +
",\n tradeAmount=" + tradeAmount + ",\n tradeAmount=" + tradeAmount +
",\n tradeAmountProperty=" + tradeAmountProperty + ",\n tradeAmountProperty=" + tradeAmountProperty +
@ -1515,7 +1488,6 @@ public abstract class Trade implements Tradable, Model {
",\n mediationResultState=" + mediationResultState + ",\n mediationResultState=" + mediationResultState +
",\n mediationResultStateProperty=" + mediationResultStateProperty + ",\n mediationResultStateProperty=" + mediationResultStateProperty +
",\n lockTime=" + lockTime + ",\n lockTime=" + lockTime +
",\n delayedPayoutTxBytes=" + Utilities.bytesAsHexString(delayedPayoutTxBytes) +
",\n refundResultState=" + refundResultState + ",\n refundResultState=" + refundResultState +
",\n refundResultStateProperty=" + refundResultStateProperty + ",\n refundResultStateProperty=" + refundResultStateProperty +
"\n}"; "\n}";

View file

@ -155,9 +155,6 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
@Getter @Getter
private final LongProperty numPendingTrades = new SimpleLongProperty(); private final LongProperty numPendingTrades = new SimpleLongProperty();
private final ReferralIdService referralIdService; 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, ProcessModelServiceProvider processModelServiceProvider,
ClockWatcher clockWatcher, ClockWatcher clockWatcher,
PersistenceManager<TradableList<Trade>> persistenceManager, PersistenceManager<TradableList<Trade>> persistenceManager,
ReferralIdService referralIdService, ReferralIdService referralIdService) {
DumpDelayedPayoutTx dumpDelayedPayoutTx,
@Named(Config.ALLOW_FAULTY_DELAYED_TXS) boolean allowFaultyDelayedTxs) {
this.user = user; this.user = user;
this.keyRing = keyRing; this.keyRing = keyRing;
this.xmrWalletService = xmrWalletService; this.xmrWalletService = xmrWalletService;
@ -204,8 +199,6 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
this.processModelServiceProvider = processModelServiceProvider; this.processModelServiceProvider = processModelServiceProvider;
this.clockWatcher = clockWatcher; this.clockWatcher = clockWatcher;
this.referralIdService = referralIdService; this.referralIdService = referralIdService;
this.dumpDelayedPayoutTx = dumpDelayedPayoutTx;
this.allowFaultyDelayedTxs = allowFaultyDelayedTxs;
this.persistenceManager = persistenceManager; this.persistenceManager = persistenceManager;
this.persistenceManager.initialize(tradableList, "PendingTrades", PersistenceManager.Source.PRIVATE); this.persistenceManager.initialize(tradableList, "PendingTrades", PersistenceManager.Source.PRIVATE);
@ -227,7 +220,6 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
tradableList.stream() tradableList.stream()
.filter(trade -> trade.getOffer() != null) .filter(trade -> trade.getOffer() != null)
.forEach(trade -> trade.getOffer().setPriceFeedService(priceFeedService)); .forEach(trade -> trade.getOffer().setPriceFeedService(priceFeedService));
dumpDelayedPayoutTx.maybeDumpDelayedPayoutTxs(tradableList, "delayed_payout_txs_pending");
completeHandler.run(); completeHandler.run();
}, },
completeHandler); completeHandler);
@ -338,7 +330,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
private void initPersistedTrades() { private void initPersistedTrades() {
// open trades in parallel since each may open a multisig wallet // open trades in parallel since each may open a multisig wallet
List<Trade> trades = tradableList.getList(); List<Trade> trades = tradableList.getList();
if (!trades.isEmpty()) { if (!trades.isEmpty()) {
@ -359,7 +351,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
persistedTradesInitialized.set(true); persistedTradesInitialized.set(true);
// We do not include failed trades as they should not be counted anyway in the trade statistics // 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 else
return offer.getDirection() == OfferDirection.SELL; return offer.getDirection() == OfferDirection.SELL;
} }
// TODO (woodser): make Optional<Trade> versus Trade return types consistent // TODO (woodser): make Optional<Trade> versus Trade return types consistent
public Trade getTrade(String tradeId) { public Trade getTrade(String tradeId) {
return getOpenTrade(tradeId).orElseGet(() -> getClosedTrade(tradeId).orElseGet(() -> null)); return getOpenTrade(tradeId).orElseGet(() -> getClosedTrade(tradeId).orElseGet(() -> null));
@ -1062,23 +1054,23 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
log.info("TradeManager.maybeRemoveTrade()"); log.info("TradeManager.maybeRemoveTrade()");
synchronized(tradableList) { synchronized(tradableList) {
if (!tradableList.contains(trade)) return; if (!tradableList.contains(trade)) return;
// delete trade if not possibly funded // 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 if (trade.getPhase().ordinal() < Trade.Phase.DEPOSIT_REQUESTED.ordinal() || trade.getPhase().ordinal() >= Trade.Phase.PAYOUT_PUBLISHED.ordinal()) { // TODO: delete after payout unlocked
// remove trade // remove trade
tradableList.remove(trade); tradableList.remove(trade);
// unreserve trade key images // unreserve trade key images
if (trade instanceof TakerTrade && trade.getSelf().getReserveTxKeyImages() != null) { if (trade instanceof TakerTrade && trade.getSelf().getReserveTxKeyImages() != null) {
for (String keyImage : trade.getSelf().getReserveTxKeyImages()) { for (String keyImage : trade.getSelf().getReserveTxKeyImages()) {
xmrWalletService.getWallet().thawOutput(keyImage); xmrWalletService.getWallet().thawOutput(keyImage);
} }
} }
// delete multisig wallet // delete multisig wallet
deleteTradeWallet(trade); deleteTradeWallet(trade);
// unregister and persist // unregister and persist
p2PService.removeDecryptedDirectMessageListener(getTradeProtocol(trade)); p2PService.removeDecryptedDirectMessageListener(getTradeProtocol(trade));
requestPersistence(); requestPersistence();

View file

@ -29,8 +29,6 @@ import bisq.common.config.Config;
import com.google.inject.Singleton; 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 bisq.common.config.Config.DUMP_STATISTICS;
import static com.google.inject.name.Names.named; import static com.google.inject.name.Names.named;
@ -52,7 +50,5 @@ public class TradeModule extends AppModule {
bind(ReferralIdService.class).in(Singleton.class); bind(ReferralIdService.class).in(Singleton.class);
bindConstant().annotatedWith(named(DUMP_STATISTICS)).to(config.dumpStatistics); 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);
} }
} }

View file

@ -22,7 +22,6 @@ import bisq.core.btc.wallet.XmrWalletService;
import bisq.core.offer.Offer; import bisq.core.offer.Offer;
import bisq.core.provider.price.PriceFeedService; import bisq.core.provider.price.PriceFeedService;
import bisq.core.trade.CleanupMailboxMessages; import bisq.core.trade.CleanupMailboxMessages;
import bisq.core.trade.DumpDelayedPayoutTx;
import bisq.core.trade.TradableList; import bisq.core.trade.TradableList;
import bisq.core.trade.Trade; import bisq.core.trade.Trade;
import bisq.core.trade.TradeUtil; import bisq.core.trade.TradeUtil;
@ -52,7 +51,6 @@ public class FailedTradesManager implements PersistedDataHost {
private final CleanupMailboxMessages cleanupMailboxMessages; private final CleanupMailboxMessages cleanupMailboxMessages;
private final PersistenceManager<TradableList<Trade>> persistenceManager; private final PersistenceManager<TradableList<Trade>> persistenceManager;
private final TradeUtil tradeUtil; private final TradeUtil tradeUtil;
private final DumpDelayedPayoutTx dumpDelayedPayoutTx;
@Setter @Setter
private Function<Trade, Boolean> unFailTradeCallback; private Function<Trade, Boolean> unFailTradeCallback;
@ -62,13 +60,11 @@ public class FailedTradesManager implements PersistedDataHost {
XmrWalletService xmrWalletService, XmrWalletService xmrWalletService,
PersistenceManager<TradableList<Trade>> persistenceManager, PersistenceManager<TradableList<Trade>> persistenceManager,
TradeUtil tradeUtil, TradeUtil tradeUtil,
CleanupMailboxMessages cleanupMailboxMessages, CleanupMailboxMessages cleanupMailboxMessages) {
DumpDelayedPayoutTx dumpDelayedPayoutTx) {
this.keyRing = keyRing; this.keyRing = keyRing;
this.priceFeedService = priceFeedService; this.priceFeedService = priceFeedService;
this.xmrWalletService = xmrWalletService; this.xmrWalletService = xmrWalletService;
this.cleanupMailboxMessages = cleanupMailboxMessages; this.cleanupMailboxMessages = cleanupMailboxMessages;
this.dumpDelayedPayoutTx = dumpDelayedPayoutTx;
this.persistenceManager = persistenceManager; this.persistenceManager = persistenceManager;
this.tradeUtil = tradeUtil; this.tradeUtil = tradeUtil;
@ -82,7 +78,6 @@ public class FailedTradesManager implements PersistedDataHost {
failedTrades.stream() failedTrades.stream()
.filter(trade -> trade.getOffer() != null) .filter(trade -> trade.getOffer() != null)
.forEach(trade -> trade.getOffer().setPriceFeedService(priceFeedService)); .forEach(trade -> trade.getOffer().setPriceFeedService(priceFeedService));
dumpDelayedPayoutTx.maybeDumpDelayedPayoutTxs(failedTrades, "delayed_payout_txs_failed");
completeHandler.run(); completeHandler.run();
}, },
completeHandler); completeHandler);

View file

@ -52,13 +52,11 @@ public class TakerReserveTradeFunds extends TradeTask {
// collect reserved key images // TODO (woodser): switch to proof of reserve? // collect reserved key images // TODO (woodser): switch to proof of reserve?
List<String> reservedKeyImages = new ArrayList<String>(); List<String> reservedKeyImages = new ArrayList<String>();
for (MoneroOutput input : reserveTx.getInputs()) reservedKeyImages.add(input.getKeyImage().getHex()); for (MoneroOutput input : reserveTx.getInputs()) reservedKeyImages.add(input.getKeyImage().getHex());
// save process state // save process state
// TODO (woodser): persist
processModel.setReserveTx(reserveTx); processModel.setReserveTx(reserveTx);
processModel.getTaker().setReserveTxKeyImages(reservedKeyImages); 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(); complete();
} catch (Throwable t) { } catch (Throwable t) {
trade.setErrorMessage("An error occurred.\n" + trade.setErrorMessage("An error occurred.\n" +

View file

@ -60,14 +60,13 @@ class TransactionAwareTrade implements TransactionAwareTradable {
public boolean isRelatedToTransaction(MoneroTxWallet transaction) { public boolean isRelatedToTransaction(MoneroTxWallet transaction) {
String txId = transaction.getHash(); String txId = transaction.getHash();
boolean isTakerOfferFeeTx = txId.equals(trade.getTakerFeeTxId());
boolean isOfferFeeTx = isOfferFeeTx(txId); boolean isOfferFeeTx = isOfferFeeTx(txId);
boolean isMakerDepositTx = isMakerDepositTx(txId); boolean isMakerDepositTx = isMakerDepositTx(txId);
boolean isTakerDepositTx = isTakerDepositTx(txId); boolean isTakerDepositTx = isTakerDepositTx(txId);
boolean isPayoutTx = isPayoutTx(txId); boolean isPayoutTx = isPayoutTx(txId);
boolean isDisputedPayoutTx = isDisputedPayoutTx(txId); boolean isDisputedPayoutTx = isDisputedPayoutTx(txId);
return isTakerOfferFeeTx || isOfferFeeTx || isMakerDepositTx || isTakerDepositTx || return isOfferFeeTx || isMakerDepositTx || isTakerDepositTx ||
isPayoutTx || isDisputedPayoutTx; isPayoutTx || isDisputedPayoutTx;
} }

View file

@ -90,7 +90,7 @@ class TransactionsListItem {
this.formatter = formatter; this.formatter = formatter;
this.memo = tx.getNote(); this.memo = tx.getNote();
this.txId = tx.getHash(); this.txId = tx.getHash();
Optional<Tradable> optionalTradable = Optional.ofNullable(transactionAwareTradable) Optional<Tradable> optionalTradable = Optional.ofNullable(transactionAwareTradable)
.map(TransactionAwareTradable::asTradable); .map(TransactionAwareTradable::asTradable);
@ -123,48 +123,45 @@ class TransactionsListItem {
details = Res.get("funds.tx.createOfferFee", tradeId); details = Res.get("funds.tx.createOfferFee", tradeId);
} else if (tradable instanceof Trade) { } else if (tradable instanceof Trade) {
Trade trade = (Trade) tradable; Trade trade = (Trade) tradable;
if (trade.getTakerFeeTxId() != null && trade.getTakerFeeTxId().equals(txId)) {
details = Res.get("funds.tx.takeOfferFee", tradeId); Offer offer = trade.getOffer();
} else { String offerFeePaymentTxID = offer.getOfferFeePaymentTxId();
Offer offer = trade.getOffer(); if (offerFeePaymentTxID != null && offerFeePaymentTxID.equals(txId)) {
String offerFeePaymentTxID = offer.getOfferFeePaymentTxId(); details = Res.get("funds.tx.createOfferFee", tradeId);
if (offerFeePaymentTxID != null && offerFeePaymentTxID.equals(txId)) { } else if (trade.getSelf().getDepositTxHash() != null &&
details = Res.get("funds.tx.createOfferFee", tradeId); trade.getSelf().getDepositTxHash().equals(txId)) {
} else if (trade.getSelf().getDepositTxHash() != null && details = Res.get("funds.tx.multiSigDeposit", tradeId);
trade.getSelf().getDepositTxHash().equals(txId)) { } else if (trade.getPayoutTxId() != null &&
details = Res.get("funds.tx.multiSigDeposit", tradeId); trade.getPayoutTxId().equals(txId)) {
} else if (trade.getPayoutTxId() != null && details = Res.get("funds.tx.multiSigPayout", tradeId);
trade.getPayoutTxId().equals(txId)) { if (amountAsCoin.isZero()) {
details = Res.get("funds.tx.multiSigPayout", tradeId);
if (amountAsCoin.isZero()) {
initialTxConfidenceVisibility = false; initialTxConfidenceVisibility = false;
} }
} else { } else {
Trade.DisputeState disputeState = trade.getDisputeState(); Trade.DisputeState disputeState = trade.getDisputeState();
if (disputeState == Trade.DisputeState.DISPUTE_CLOSED) { if (disputeState == Trade.DisputeState.DISPUTE_CLOSED) {
if (valueSentToMe.isPositive()) { if (valueSentToMe.isPositive()) {
details = Res.get("funds.tx.disputePayout", tradeId); 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 { } 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) { if (isDustAttackTx) {
details = Res.get("funds.tx.dustAttackTx"); details = Res.get("funds.tx.dustAttackTx");
} }
// confidence // confidence
lazyFieldsSupplier = Suppliers.memoize(() -> new LazyFields() {{ lazyFieldsSupplier = Suppliers.memoize(() -> new LazyFields() {{
txConfidenceIndicator = new TxConfidenceIndicator(); txConfidenceIndicator = new TxConfidenceIndicator();

View file

@ -445,16 +445,11 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
private void applyTradeState() { private void applyTradeState() {
if (trade.isTakerFeePublished()) { if (trade.isTakerFeePublished()) {
if (trade.getTakerFeeTxId() != null) { if (takeOfferResultHandler != null)
if (takeOfferResultHandler != null) takeOfferResultHandler.run();
takeOfferResultHandler.run();
showTransactionPublishedScreen.set(true); showTransactionPublishedScreen.set(true);
updateSpinnerInfo(); updateSpinnerInfo();
} else {
final String msg = "trade.getTakerFeeTxId() must not be null.";
DevEnv.logErrorAndThrowIfDevMode(msg);
}
} }
} }

View file

@ -274,7 +274,6 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
} }
addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.makerFeeTxId"), offer.getOfferFeePaymentTxId()); addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.makerFeeTxId"), offer.getOfferFeePaymentTxId());
addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.takerFeeTxId"), trade.getTakerFeeTxId());
if (trade.getMakerDepositTx() != null) if (trade.getMakerDepositTx() != null)
addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.depositTransactionId"), // TODO (woodser): separate UI labels for deposit tx ids addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.depositTransactionId"), // TODO (woodser): separate UI labels for deposit tx ids

View file

@ -107,15 +107,12 @@ public class FailedTradesView extends ActivatableViewAndModel<VBox, FailedTrades
private EventHandler<KeyEvent> keyEventEventHandler; private EventHandler<KeyEvent> keyEventEventHandler;
private ChangeListener<String> filterTextFieldListener; private ChangeListener<String> filterTextFieldListener;
private Scene scene; private Scene scene;
private final boolean allowFaultyDelayedTxs;
@Inject @Inject
public FailedTradesView(FailedTradesViewModel model, public FailedTradesView(FailedTradesViewModel model,
TradeDetailsWindow tradeDetailsWindow, TradeDetailsWindow tradeDetailsWindow) {
@Named(Config.ALLOW_FAULTY_DELAYED_TXS) boolean allowFaultyDelayedTxs) {
super(model); super(model);
this.tradeDetailsWindow = tradeDetailsWindow; this.tradeDetailsWindow = tradeDetailsWindow;
this.allowFaultyDelayedTxs = allowFaultyDelayedTxs;
} }
@Override @Override
@ -279,9 +276,6 @@ public class FailedTradesView extends ActivatableViewAndModel<VBox, FailedTrades
Trade trade = item.getTrade(); Trade trade = item.getTrade();
if (trade.getTakerFeeTxId() != null && trade.getTakerFeeTxId().contains(filterString)) {
return true;
}
if (trade.getMaker().getDepositTxHash() != null && trade.getMaker().getDepositTxHash().contains(filterString)) { if (trade.getMaker().getDepositTxHash() != null && trade.getMaker().getDepositTxHash().contains(filterString)) {
return true; return true;
} }
@ -326,12 +320,6 @@ public class FailedTradesView extends ActivatableViewAndModel<VBox, FailedTrades
log.info("Check unfail found no deposit tx(s) for trade {}", trade.getId()); log.info("Check unfail found no deposit tx(s) for trade {}", trade.getId());
return Res.get("portfolio.failed.depositTxNull"); return Res.get("portfolio.failed.depositTxNull");
} }
if (trade.getDelayedPayoutTxBytes() == null) {
log.info("Check unfail found no delayedPayoutTxBytes for trade {}", trade.getId());
if (!allowFaultyDelayedTxs) {
return Res.get("portfolio.failed.delayedPayoutTxNull");
}
}
return ""; return "";
} }

View file

@ -412,16 +412,6 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
return Res.get("portfolio.pending.failedTrade.missingContract"); return Res.get("portfolio.pending.failedTrade.missingContract");
} }
PubKeyRing myPubKeyRing = model.dataModel.getPubKeyRingProvider().get();
boolean isMyRoleBuyer = contract.isMyRoleBuyer(myPubKeyRing);
boolean isMyRoleMaker = contract.isMyRoleMaker(myPubKeyRing);
if (trade.getTakerFeeTxId() == null) {
return isMyRoleMaker ?
Res.get("portfolio.pending.failedTrade.maker.missingTakerFeeTx") :
Res.get("portfolio.pending.failedTrade.taker.missingTakerFeeTx");
}
if (trade.getMakerDepositTx() == null) { if (trade.getMakerDepositTx() == null) {
return Res.get("portfolio.pending.failedTrade.missingDepositTx"); return Res.get("portfolio.pending.failedTrade.missingDepositTx");
} }

View file

@ -38,9 +38,6 @@ public class FilteringUtils {
if (trade == null) { if (trade == null) {
return false; return false;
} }
if (trade.getTakerFeeTxId() != null && StringUtils.containsIgnoreCase(trade.getTakerFeeTxId(), filterString)) {
return true;
}
if (trade.getMaker().getDepositTxHash() != null && StringUtils.containsIgnoreCase(trade.getMaker().getDepositTxHash(), filterString)) { if (trade.getMaker().getDepositTxHash() != null && StringUtils.containsIgnoreCase(trade.getMaker().getDepositTxHash(), filterString)) {
return true; return true;
} }
@ -50,7 +47,7 @@ public class FilteringUtils {
if (trade.getPayoutTxId() != null && StringUtils.containsIgnoreCase(trade.getPayoutTxId(), filterString)) { if (trade.getPayoutTxId() != null && StringUtils.containsIgnoreCase(trade.getPayoutTxId(), filterString)) {
return true; return true;
} }
// match contract // match contract
boolean isBuyerOnion = false; boolean isBuyerOnion = false;
boolean isSellerOnion = false; boolean isSellerOnion = false;

View file

@ -63,12 +63,6 @@ public class TransactionAwareTradeTest {
trade = new TransactionAwareTrade(delegate, arbitrationManager, refundManager, xmrWalletService, null); trade = new TransactionAwareTrade(delegate, arbitrationManager, refundManager, xmrWalletService, null);
} }
@Test
public void testIsRelatedToTransactionWhenTakerOfferFeeTx() {
when(delegate.getTakerFeeTxId()).thenReturn(XID.toString());
assertTrue(trade.isRelatedToTransaction(transaction));
}
@Test @Test
public void testIsRelatedToTransactionWhenPayoutTx() { public void testIsRelatedToTransactionWhenPayoutTx() {
when(delegate.getPayoutTx().getHash()).thenReturn(XID.toString()); when(delegate.getPayoutTx().getHash()).thenReturn(XID.toString());

View file

@ -1709,36 +1709,32 @@ message Trade {
Offer offer = 1; Offer offer = 1;
ProcessModel process_model = 2; ProcessModel process_model = 2;
string taker_fee_tx_id = 3; string payout_tx_id = 3;
reserved 4; string payout_tx_hex = 4;
string payout_tx_id = 5; string payout_tx_key = 5;
string payout_tx_hex = 6; int64 amount_as_long = 6;
string payout_tx_key = 7; int64 tx_fee_as_long = 7;
int64 amount_as_long = 8; int64 taker_fee_as_long = 8;
int64 tx_fee_as_long = 9; int64 take_offer_date = 9;
int64 taker_fee_as_long = 10; int64 price = 10;
int64 take_offer_date = 11; State state = 11;
int64 price = 12; DisputeState dispute_state = 12;
State state = 13; TradePeriodState period_state = 13;
DisputeState dispute_state = 14; Contract contract = 14;
TradePeriodState period_state = 15; string contract_as_json = 15;
Contract contract = 16; bytes contract_hash = 16;
string contract_as_json = 17; NodeAddress arbitrator_node_address = 17;
bytes contract_hash = 18; NodeAddress mediator_node_address = 18;
NodeAddress arbitrator_node_address = 19; string error_message = 19;
NodeAddress mediator_node_address = 20; string counter_currency_tx_id = 20;
string error_message = 21; repeated ChatMessage chat_message = 21;
string counter_currency_tx_id = 22; MediationResultState mediation_result_state = 22;
repeated ChatMessage chat_message = 23; int64 lock_time = 23;
MediationResultState mediation_result_state = 24; NodeAddress refund_agent_node_address = 24;
int64 lock_time = 25; RefundResultState refund_result_state = 25;
bytes delayed_payout_tx_bytes = 26; string counter_currency_extra_data = 26;
NodeAddress refund_agent_node_address = 27; string asset_tx_proof_result = 27; // name of AssetTxProofResult enum
RefundResultState refund_result_state = 28; string uid = 28;
int64 last_refresh_request_date = 29 [deprecated = true];
string counter_currency_extra_data = 30;
string asset_tx_proof_result = 31; // name of AssetTxProofResult enum
string uid = 32;
} }
message BuyerAsMakerTrade { message BuyerAsMakerTrade {
@ -2171,4 +2167,4 @@ message PaymentAccountFormField {
repeated Country supported_sepa_euro_countries = 10; repeated Country supported_sepa_euro_countries = 10;
repeated Country supported_sepa_non_euro_countries = 11; repeated Country supported_sepa_non_euro_countries = 11;
repeated string required_for_countries = 12; repeated string required_for_countries = 12;
} }