mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-09 07:02:24 -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
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 "";
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue