diff --git a/assets/src/main/java/bisq/asset/CryptoNoteAddressValidator.java b/assets/src/main/java/bisq/asset/CryptoNoteAddressValidator.java index 295c1e0af8..cc88ed7221 100644 --- a/assets/src/main/java/bisq/asset/CryptoNoteAddressValidator.java +++ b/assets/src/main/java/bisq/asset/CryptoNoteAddressValidator.java @@ -46,7 +46,7 @@ public class CryptoNoteAddressValidator implements AddressValidator { } } return AddressValidationResult.invalidAddress(String.format("invalid address prefix %x", prefix)); - } catch (Exception e) { + } catch (CryptoNoteUtils.CryptoNoteException e) { return AddressValidationResult.invalidStructure(); } } diff --git a/assets/src/main/java/bisq/asset/CryptoNoteUtils.java b/assets/src/main/java/bisq/asset/CryptoNoteUtils.java index 425fbe19b2..c89f73aaad 100644 --- a/assets/src/main/java/bisq/asset/CryptoNoteUtils.java +++ b/assets/src/main/java/bisq/asset/CryptoNoteUtils.java @@ -34,7 +34,7 @@ public class CryptoNoteUtils { // omit the type (1st byte) and checksum (last 4 byte) byte[] slice = Arrays.copyOfRange(decoded, 1, decoded.length - 4); return Utils.HEX.encode(slice); - } catch (Exception e) { + } catch (CryptoNoteException e) { e.printStackTrace(); } return null; @@ -155,7 +155,7 @@ public class CryptoNoteUtils { int inputLength, byte[] decoded, int decodedOffset, - int decodedLength) throws Exception { + int decodedLength) throws CryptoNoteException { BigInteger result = BigInteger.ZERO; @@ -164,17 +164,17 @@ public class CryptoNoteUtils { char character = input.charAt(--index); int digit = ALPHABET.indexOf(character); if (digit == -1) { - throw new Exception("invalid character " + character); + throw new CryptoNoteException("invalid character " + character); } result = result.add(order.multiply(BigInteger.valueOf(digit))); if (result.compareTo(UINT64_MAX) > 0) { - throw new Exception("64-bit unsigned integer overflow " + result.toString()); + throw new CryptoNoteException("64-bit unsigned integer overflow " + result.toString()); } } BigInteger maxCapacity = BigInteger.ONE.shiftLeft(8 * decodedLength); if (result.compareTo(maxCapacity) >= 0) { - throw new Exception("capacity overflow " + result.toString()); + throw new CryptoNoteException("capacity overflow " + result.toString()); } for (int index = decodedOffset + decodedLength; index != decodedOffset; result = result.shiftRight(8)) { @@ -182,7 +182,7 @@ public class CryptoNoteUtils { } } - public static byte[] decode(String input) throws Exception { + public static byte[] decode(String input) throws CryptoNoteException { if (input.length() == 0) { return new byte[0]; } @@ -218,12 +218,12 @@ public class CryptoNoteUtils { return result; } - static long decodeAddress(String address, boolean validateChecksum) throws Exception { + static long decodeAddress(String address, boolean validateChecksum) throws CryptoNoteException { byte[] decoded = decode(address); int checksumSize = 4; if (decoded.length < checksumSize) { - throw new Exception("invalid length"); + throw new CryptoNoteException("invalid length"); } ByteBuffer decodedAddress = ByteBuffer.wrap(decoded, 0, decoded.length - checksumSize); @@ -237,11 +237,35 @@ public class CryptoNoteUtils { int checksum = fastHash.getInt(); int expected = ByteBuffer.wrap(decoded, decoded.length - checksumSize, checksumSize).getInt(); if (checksum != expected) { - throw new Exception(String.format("invalid checksum %08X, expected %08X", checksum, expected)); + throw new CryptoNoteException(String.format("invalid checksum %08X, expected %08X", checksum, expected)); } return prefix; } } + + static class CryptoNoteException extends Exception { + public CryptoNoteException() { + } + + public CryptoNoteException(String message) { + super(message); + } + + public CryptoNoteException(String message, Throwable cause) { + super(message, cause); + } + + public CryptoNoteException(Throwable cause) { + super(cause); + } + + public CryptoNoteException(String message, + Throwable cause, + boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + } } diff --git a/desktop/src/main/java/bisq/desktop/main/MainView.java b/desktop/src/main/java/bisq/desktop/main/MainView.java index f977c95d0b..03a5869908 100644 --- a/desktop/src/main/java/bisq/desktop/main/MainView.java +++ b/desktop/src/main/java/bisq/desktop/main/MainView.java @@ -43,12 +43,12 @@ import bisq.desktop.util.DisplayUtils; import bisq.desktop.util.Transitions; import bisq.core.dao.monitoring.DaoStateMonitoringService; -import bisq.common.BisqException; import bisq.core.locale.GlobalSettings; import bisq.core.locale.LanguageUtil; import bisq.core.locale.Res; import bisq.core.provider.price.MarketPrice; +import bisq.common.BisqException; import bisq.common.Timer; import bisq.common.UserThread; import bisq.common.app.Version; @@ -77,7 +77,6 @@ import javafx.scene.layout.AnchorPane; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; -import javafx.scene.layout.Region; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.scene.text.TextAlignment; @@ -444,13 +443,6 @@ public class MainView extends InitializableView return separator; } - @NotNull - private Region getNavigationSpacer() { - final Region spacer = new Region(); - HBox.setHgrow(spacer, Priority.ALWAYS); - return spacer; - } - private Tuple2 getBalanceBox(String text) { Label balanceDisplay = new Label(); balanceDisplay.getStyleClass().add("nav-balance-display");