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
# file. This is where you might define Haveno options such as:
# dumpBlockchainData=true
# dumpDelayedPayoutTxs=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 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<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 =
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);

View File

@ -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" +

View File

@ -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;

View File

@ -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");
}

View File

@ -71,7 +71,6 @@ public class ClosedTradableManager implements PersistedDataHost {
private final TradeStatisticsManager tradeStatisticsManager;
private final PersistenceManager<TradableList<Tradable>> persistenceManager;
private final CleanupMailboxMessagesService cleanupMailboxMessagesService;
private final DumpDelayedPayoutTx dumpDelayedPayoutTx;
private final TradableList<Tradable> closedTradables = new TradableList<>();
@ -81,14 +80,12 @@ public class ClosedTradableManager implements PersistedDataHost {
Preferences preferences,
TradeStatisticsManager tradeStatisticsManager,
PersistenceManager<TradableList<Tradable>> 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);

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
@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<DisputeState> disputeStateProperty = new SimpleObjectProperty<>(disputeState);
transient final private ObjectProperty<TradePeriodState> 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<Coin> 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<TradeListener>();
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<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.
*
*
* @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}";

View File

@ -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<TradableList<Trade>> 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<Trade> 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<Trade> 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();

View File

@ -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);
}
}

View File

@ -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<TradableList<Trade>> persistenceManager;
private final TradeUtil tradeUtil;
private final DumpDelayedPayoutTx dumpDelayedPayoutTx;
@Setter
private Function<Trade, Boolean> unFailTradeCallback;
@ -62,13 +60,11 @@ public class FailedTradesManager implements PersistedDataHost {
XmrWalletService xmrWalletService,
PersistenceManager<TradableList<Trade>> 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);

View File

@ -52,13 +52,11 @@ public class TakerReserveTradeFunds extends TradeTask {
// collect reserved key images // TODO (woodser): switch to proof of reserve?
List<String> reservedKeyImages = new ArrayList<String>();
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" +

View File

@ -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;
}

View File

@ -90,7 +90,7 @@ class TransactionsListItem {
this.formatter = formatter;
this.memo = tx.getNote();
this.txId = tx.getHash();
Optional<Tradable> 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();

View File

@ -445,16 +445,11 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> 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();
}
}

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.takerFeeTxId"), trade.getTakerFeeTxId());
if (trade.getMakerDepositTx() != null)
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 ChangeListener<String> 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<VBox, FailedTrades
Trade trade = item.getTrade();
if (trade.getTakerFeeTxId() != null && trade.getTakerFeeTxId().contains(filterString)) {
return true;
}
if (trade.getMaker().getDepositTxHash() != null && trade.getMaker().getDepositTxHash().contains(filterString)) {
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());
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 "";
}

View File

@ -412,16 +412,6 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
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) {
return Res.get("portfolio.pending.failedTrade.missingDepositTx");
}

View File

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

View File

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

View File

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