From 9869b64352d6f9c1acf5e913218de7fe14c1120a Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Mon, 6 Jun 2016 16:11:01 +0200 Subject: [PATCH] Add null check for PayoutTx at startup --- .../bitsquare/trade/protocol/trade/BuyerAsOffererProtocol.java | 3 ++- .../bitsquare/trade/protocol/trade/BuyerAsTakerProtocol.java | 3 ++- .../trade/protocol/trade/SellerAsOffererProtocol.java | 3 ++- .../bitsquare/trade/protocol/trade/SellerAsTakerProtocol.java | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/BuyerAsOffererProtocol.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/BuyerAsOffererProtocol.java index 1f0d4f407e..da8d6b3bd3 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/BuyerAsOffererProtocol.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/BuyerAsOffererProtocol.java @@ -54,7 +54,8 @@ public class BuyerAsOffererProtocol extends TradeProtocol implements BuyerProtoc // If we are after the time lock state we need to setup the listener again Trade.State tradeState = trade.getState(); - if ((tradeState.getPhase() == Trade.Phase.FIAT_RECEIVED || tradeState.getPhase() == Trade.Phase.PAYOUT_PAID) && tradeState != Trade.State.PAYOUT_BROAD_CASTED) { + Trade.Phase phase = tradeState.getPhase(); + if (trade.getPayoutTx() != null && (phase == Trade.Phase.FIAT_RECEIVED || phase == Trade.Phase.PAYOUT_PAID) && tradeState != Trade.State.PAYOUT_BROAD_CASTED) { TradeTaskRunner taskRunner = new TradeTaskRunner(trade, () -> { diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/BuyerAsTakerProtocol.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/BuyerAsTakerProtocol.java index 4811457e9f..cb2d624fc3 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/BuyerAsTakerProtocol.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/BuyerAsTakerProtocol.java @@ -53,7 +53,8 @@ public class BuyerAsTakerProtocol extends TradeProtocol implements BuyerProtocol // If we are after the timeLock state we need to setup the listener again Trade.State tradeState = trade.getState(); - if ((tradeState.getPhase() == Trade.Phase.FIAT_RECEIVED || tradeState.getPhase() == Trade.Phase.PAYOUT_PAID) && tradeState != Trade.State.PAYOUT_BROAD_CASTED) { + Trade.Phase phase = tradeState.getPhase(); + if (trade.getPayoutTx() != null && (phase == Trade.Phase.FIAT_RECEIVED || phase == Trade.Phase.PAYOUT_PAID) && tradeState != Trade.State.PAYOUT_BROAD_CASTED) { TradeTaskRunner taskRunner = new TradeTaskRunner(trade, () -> { handleTaskRunnerSuccess("SetupPayoutTxLockTimeReachedListener"); diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/SellerAsOffererProtocol.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/SellerAsOffererProtocol.java index 1e13a555e7..f1dea4dacf 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/SellerAsOffererProtocol.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/SellerAsOffererProtocol.java @@ -53,7 +53,8 @@ public class SellerAsOffererProtocol extends TradeProtocol implements SellerProt // If we are after the time lock state we need to setup the listener again //TODO not sure if that is not called already from the checkPayoutTxTimeLock at tradeProtocol Trade.State tradeState = trade.getState(); - if ((tradeState.getPhase() == Trade.Phase.FIAT_RECEIVED || tradeState.getPhase() == Trade.Phase.PAYOUT_PAID) && tradeState != Trade.State.PAYOUT_BROAD_CASTED) { + Trade.Phase phase = tradeState.getPhase(); + if (trade.getPayoutTx() != null && (phase == Trade.Phase.FIAT_RECEIVED || phase == Trade.Phase.PAYOUT_PAID) && tradeState != Trade.State.PAYOUT_BROAD_CASTED) { TradeTaskRunner taskRunner = new TradeTaskRunner(trade, () -> { handleTaskRunnerSuccess("SetupPayoutTxLockTimeReachedListener"); diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/SellerAsTakerProtocol.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/SellerAsTakerProtocol.java index dea9e7699f..0b88a7b7b2 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/SellerAsTakerProtocol.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/SellerAsTakerProtocol.java @@ -55,7 +55,8 @@ public class SellerAsTakerProtocol extends TradeProtocol implements SellerProtoc // If we are after the timeLock state we need to setup the listener again //TODO not sure if that is not called already from the checkPayoutTxTimeLock at tradeProtocol Trade.State tradeState = trade.getState(); - if ((tradeState.getPhase() == Trade.Phase.FIAT_RECEIVED || tradeState.getPhase() == Trade.Phase.PAYOUT_PAID) && tradeState != Trade.State.PAYOUT_BROAD_CASTED) { + Trade.Phase phase = tradeState.getPhase(); + if (trade.getPayoutTx() != null && (phase == Trade.Phase.FIAT_RECEIVED || phase == Trade.Phase.PAYOUT_PAID) && tradeState != Trade.State.PAYOUT_BROAD_CASTED) { TradeTaskRunner taskRunner = new TradeTaskRunner(trade, () -> { handleTaskRunnerSuccess("SetupPayoutTxLockTimeReachedListener");