A lightweight JavaScript library to validate Beldex addresses, support for Mainnet, Testnet, and Devnet.
- Validate Beldex standard addresses, subaddresses, and integrated addresses.
- Detect network type (Mainnet, Testnet, Devnet).
- Checksum verification using Keccak-256.
- Base58 decoding.
You can use this library in two ways:
- Maven Project
- Normal Java Project (without Maven)
git clone https://github.com/Beldex-Coin/java-address-validator.gitEnter the project folder:
cd java-address-validatorRun:
mvn clean installThis will compile the project and install the library into the local Maven repository:
~/.m2/repository
Specifically:
~/.m2/repository/com/beldex/java-address-validator/1.0-SNAPSHOT/
In the other Maven project, add this to pom.xml:
<dependency>
<groupId>com.beldex</groupId>
<artifactId>java-address-validator</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>Maven will now load the library from the local repository.
import com.beldex.AddressValidator;
import java.util.Map;
public class Main {
public static void main(String[] args) {
String address = "YOUR_BELDEX_ADDRESS";
Map<String, String> result =
AddressValidator.ValidateBeldexAddress(address);
System.out.println(result);
}
}Important Note
mvn install is only required once.
After installing, any Maven project on that machine can use the dependency.
You can also use the Beldex Address Validator in a standard Java project without using Maven.
Download the latest JAR file from the GitHub Releases page:
https://github.com/Beldex-Coin/java-address-validator/releases
Download
java-address-validator-1.0-SNAPSHOT.jar
or Build the validator library:
mvn clean package The compiled JAR will be generated at:
target/java-address-validator-1.0-SNAPSHOT.jar
Copy this JAR into your project (for example inside a lib folder).
Example project structure:
sample-java-project
│
├── lib
│ └── java-address-validator-1.0-SNAPSHOT.jar
│
└── src
└── Main.java
import com.beldex.AddressValidator;
import java.util.Map;
public class Main {
public static void main(String[] args) {
String address = "YOUR_BELDEX_ADDRESS";
Map<String, String> result =
AddressValidator.ValidateBeldexAddress(address);
if ("true".equals(result.get("valid"))) {
System.out.println("Address is valid");
System.out.println("Network: " + result.get("network"));
System.out.println("Type: " + result.get("type"));
} else {
System.out.println("Address is invalid");
System.out.println("Reason: " + result.get("reason"));
}
}
}Navigate to the src directory and compile:
javac -cp /lib/java-address-validator-1.0-SNAPSHOT.jar src/Main.javaRun the program with the library in the classpath:
java -cp ".:/lib/java-address-validator-1.0-SNAPSHOT.jar" src/MainValid address:
Address is valid
Network: mainnet
Type: standard
Invalid address:
Address is invalid
Reason: Invalid checksum
- Standard Address: The primary address for a wallet.
- Subaddress: Generated addresses for receiving payments without revealing the primary address.
- Integrated Address: A standard address bundled with a payment ID.
Beldex addresses use a Monero-style encoding:
- Prefix: A network-specific byte indicating the address type.
- Public Spend Key: 32 bytes.
- Public View Key: 32 bytes.
- Checksum: 4 bytes (Hash of the above data).
The entire package is encoded using Beldex's modified Base58 format.
- Java 17
- Maven 3+
- Address Validator JAR file
GPL-3.0 license