How to detect that address string is correct Waves account address

My API have user account address as input parameter.
I want to define that address is correct before I will send transactions.
Is there any way to do it? I cannot find corresponding API in your JS libraries.

curl -X GET --header ‘Accept: application/json’ ‘
Response Body
Response Code

curl -X GET --header ‘Accept: application/json’ ‘

Response Body

  "error": 102,
  "message": "invalid address"

Response Code


Probably there are simplier ways

1 Like

Unfortunately, any server requests is not solution for me.
I require a way to determine it offline using something like formula for sample:
address[0]===‘3’ (ugly sample)

Account validation

Account is valid then it is a valid Base58 string and the length of corresponding array is 26 bytes. Version of address (1st byte) is equal to 1. The network byte (2nd byte) is equal to network ID. The checksum of address (last 4 bytes) is correct.

In Java:

private static byte[] address(byte[] publicKey, byte chainId) {
    ByteBuffer buf = ByteBuffer.allocate(26);
    byte[] hash = secureHash(publicKey, 0, publicKey.length);
    buf.put((byte) 1).put((byte) chainId).put(hash, 0, 20);
    byte[] checksum = secureHash(buf.array(), 0, 22);
    buf.put(checksum, 0, 4);
    return buf.array();

where secureHash is KECCAK256(BLAKE2B256(buffer))