diff --git a/src/main/java/org/qortal/api/resource/CrossChainResource.java b/src/main/java/org/qortal/api/resource/CrossChainResource.java index d5a886c2..3de1b56d 100644 --- a/src/main/java/org/qortal/api/resource/CrossChainResource.java +++ b/src/main/java/org/qortal/api/resource/CrossChainResource.java @@ -754,6 +754,9 @@ public class CrossChainResource { if (p2shBalance == null) throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.ADDRESS_UNKNOWN); + if (p2shBalance.value < crossChainTradeData.expectedBitcoin) + throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.BTC_BALANCE_ISSUE); + List fundingOutputs = BTC.getInstance().getUnspentOutputs(p2shAddress.toString()); if (fundingOutputs.size() != 1) throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_ADDRESS); @@ -763,9 +766,6 @@ public class CrossChainResource { if (!canRedeem) throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.BTC_TOO_SOON); - if (p2shBalance.value < crossChainTradeData.expectedBitcoin) - throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.BTC_BALANCE_ISSUE); - Coin redeemAmount = p2shBalance.subtract(Coin.valueOf(redeemRequest.bitcoinMinerFee.unscaledValue().longValue())); org.bitcoinj.core.Transaction redeemTransaction = BTCACCT.buildRedeemTransaction(redeemAmount, redeemKey, fundingOutput, redeemScriptBytes, redeemRequest.secret);