From 95cb3b271008f68ff6558450fb4c6e7ceb11668d Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Fri, 25 Sep 2020 17:06:13 -0500 Subject: [PATCH] Fix deposit tx setters --- core/src/main/java/bisq/core/trade/Trade.java | 5 +- .../BuyerAsTakerSignsDepositTx.java | 2 +- .../SellerAsMakerFinalizesDepositTx.java | 2 +- .../tasks/taker/TakerPublishFeeTx.java | 52 +++++++++++-------- .../steps/buyer/BuyerStep2View.java | 5 +- 5 files changed, 38 insertions(+), 28 deletions(-) diff --git a/core/src/main/java/bisq/core/trade/Trade.java b/core/src/main/java/bisq/core/trade/Trade.java index 9e163f53ba..55be47724d 100644 --- a/core/src/main/java/bisq/core/trade/Trade.java +++ b/core/src/main/java/bisq/core/trade/Trade.java @@ -123,7 +123,7 @@ public abstract class Trade implements Tradable, Model { // maker perspective MAKER_SENT_PUBLISH_DEPOSIT_TX_REQUEST(Phase.TAKER_FEE_PUBLISHED), MAKER_SAW_ARRIVED_PUBLISH_DEPOSIT_TX_REQUEST(Phase.TAKER_FEE_PUBLISHED), - MAKER_STORED_IN_MAILBOX_PUBLISH_DEPOSIT_TX_REQUEST(Phase.TAKER_FEE_PUBLISHED), //todo remove + MAKER_STORED_IN_MAILBOX_PUBLISH_DEPOSIT_TX_REQUEST(Phase.TAKER_FEE_PUBLISHED), //not a mailbox msg, not used... MAKER_SEND_FAILED_PUBLISH_DEPOSIT_TX_REQUEST(Phase.TAKER_FEE_PUBLISHED), // taker perspective @@ -1232,8 +1232,9 @@ public abstract class Trade implements Tradable, Model { private void setConfirmedState() { // we only apply the state if we are not already further in the process - if (!isDepositConfirmed()) + if (!isDepositConfirmed()) { setState(State.DEPOSIT_CONFIRMED_IN_BLOCK_CHAIN); + } } @Override diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_taker/BuyerAsTakerSignsDepositTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_taker/BuyerAsTakerSignsDepositTx.java index 95bdbb2b91..50e302db54 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_taker/BuyerAsTakerSignsDepositTx.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/buyer_as_taker/BuyerAsTakerSignsDepositTx.java @@ -86,7 +86,7 @@ public class BuyerAsTakerSignsDepositTx extends TradeTask { sellerInputs, buyerMultiSigPubKey, sellerMultiSigPubKey); - trade.applyDepositTx(depositTx); + processModel.setDepositTx(depositTx); complete(); } catch (Throwable t) { diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerFinalizesDepositTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerFinalizesDepositTx.java index 0a130b17dc..1a580b2fc7 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerFinalizesDepositTx.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/seller_as_maker/SellerAsMakerFinalizesDepositTx.java @@ -46,7 +46,7 @@ public class SellerAsMakerFinalizesDepositTx extends TradeTask { int numTakersInputs = checkNotNull(processModel.getTradingPeer().getRawTransactionInputs()).size(); processModel.getTradeWalletService().sellerAsMakerFinalizesDepositTx(myDepositTx, takersDepositTx, numTakersInputs); - trade.applyDepositTx(myDepositTx); + processModel.setDepositTx(myDepositTx); complete(); } catch (Throwable t) { diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerPublishFeeTx.java b/core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerPublishFeeTx.java index a5da55a2d3..a1c4914a49 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerPublishFeeTx.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/taker/TakerPublishFeeTx.java @@ -57,14 +57,12 @@ public class TakerPublishFeeTx extends TradeTask { new TxBroadcaster.Callback() { @Override public void onSuccess(Transaction transaction) { - trade.setTakerFeeTxId(transaction.getTxId().toString()); - trade.setState(Trade.State.TAKER_PUBLISHED_TAKER_FEE_TX); - complete(); + TakerPublishFeeTx.this.onSuccess(transaction); } @Override public void onFailure(TxBroadcastException exception) { - failed(exception); + TakerPublishFeeTx.this.onFailure(exception); } }); } else { @@ -79,29 +77,12 @@ public class TakerPublishFeeTx extends TradeTask { new TxBroadcaster.Callback() { @Override public void onSuccess(@Nullable Transaction transaction) { - if (!completed) { - if (transaction != null) { - trade.setTakerFeeTxId(transaction.getTxId().toString()); - trade.setState(Trade.State.TAKER_PUBLISHED_TAKER_FEE_TX); - complete(); - } - } else { - log.warn("We got the onSuccess callback called after the timeout has been triggered a complete()."); - } + TakerPublishFeeTx.this.onSuccess(transaction); } @Override public void onFailure(TxBroadcastException exception) { - if (!completed) { - log.error(exception.toString()); - exception.printStackTrace(); - trade.setErrorMessage("An error occurred.\n" + - "Error message:\n" - + exception.getMessage()); - failed(exception); - } else { - log.warn("We got the onFailure callback called after the timeout has been triggered a complete()."); - } + TakerPublishFeeTx.this.onFailure(exception); } }, 1); @@ -110,4 +91,29 @@ public class TakerPublishFeeTx extends TradeTask { failed(t); } } + + protected void onFailure(TxBroadcastException exception) { + if (!completed) { + log.error(exception.toString()); + exception.printStackTrace(); + trade.setErrorMessage("An error occurred.\n" + + "Error message:\n" + + exception.getMessage()); + failed(exception); + } else { + log.warn("We got the onFailure callback called after the timeout has been triggered a complete()."); + } + } + + protected void onSuccess(@org.jetbrains.annotations.Nullable Transaction transaction) { + if (!completed) { + if (transaction != null) { + trade.setTakerFeeTxId(transaction.getTxId().toString()); + trade.setState(Trade.State.TAKER_PUBLISHED_TAKER_FEE_TX); + complete(); + } + } else { + log.warn("We got the onSuccess callback called after the timeout has been triggered a complete()."); + } + } } diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java index 150c38bca2..a60d1dcd72 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java @@ -507,8 +507,11 @@ public class BuyerStep2View extends TradeStepView { private void confirmPaymentStarted() { busyAnimation.play(); statusLabel.setText(Res.get("shared.sendingConfirmation")); - if (trade.isFiatSent()) + + //TODO seems this was a hack to enable repeated confirm??? + if (trade.isFiatSent()) { trade.setState(Trade.State.DEPOSIT_CONFIRMED_IN_BLOCK_CHAIN); + } model.dataModel.onPaymentStarted(() -> { }, errorMessage -> {