mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-05-20 23:40:48 -04:00
fix trade is in an invalid state warning
Co-authored-by: duriancrepe <duriancrepe@protonmail.com>
This commit is contained in:
parent
14c5384edc
commit
e79450f65e
21 changed files with 101 additions and 293 deletions
|
@ -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" +
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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}";
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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" +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue