AddressUtils { public static boolean isValidAddress(String address) { byte[] data; try { data = Base58.decode(address); } catch (AddressFormatException e) { return false; } if (data.length != 25) { return false; } if (data[0] != NeoConfig.addressVersion()) { return false; } byte[] checksum = hash256(data, 0, 21); for (int i = 0; i < 4; i++) { if (data[data.length - 4 + i] != checksum[i]) { return false; } } return true; }  static boolean isValidAddress(String address); static byte[] addressToScriptHash(String address); static String scriptHashToAddress(byte[] scriptHash);  }
@Test public void testIsValidAddress() { assertTrue(AddressUtils.isValidAddress("Ab2fvZdmnM4HwDgVbdBrbTLz1wK5TcEyhU")); assertTrue(AddressUtils.isValidAddress("AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y")); assertFalse(AddressUtils.isValidAddress("")); assertFalse(AddressUtils.isValidAddress("0")); assertFalse(AddressUtils.isValidAddress("b2fvZdmnM4HwDgVbdBrbTLz1wK5TcEyhU")); assertFalse(AddressUtils.isValidAddress("AAb2fvZdmnM4HwDgVbdBrbTLz1wK5TcEyhU")); try { AddressUtils.isValidAddress(null); } catch (NullPointerException e) { return; } fail(); }