From 0b93930d1953b8cb106788db06cfb8d5df77a12c Mon Sep 17 00:00:00 2001 From: XMRZombie Date: Sun, 8 Dec 2024 05:45:10 +0000 Subject: [PATCH] Create SolanaAddressValidator.java Adding solana address validation, uses a base58 regex filter --- .../haveno/asset/SolanaAddressValidator.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 assets/src/main/java/haveno/asset/SolanaAddressValidator.java diff --git a/assets/src/main/java/haveno/asset/SolanaAddressValidator.java b/assets/src/main/java/haveno/asset/SolanaAddressValidator.java new file mode 100644 index 0000000000..ff173d277e --- /dev/null +++ b/assets/src/main/java/haveno/asset/SolanaAddressValidator.java @@ -0,0 +1,35 @@ +/* +* This file is part of Haveno. +* +* Haveno is free software: you can redistribute it and/or modify it +* under the terms of the GNU Affero General Public License as published by +* the Free Software Foundation, either version 3 of the License, or (at +* your option) any later version. +* +* Haveno is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public +* License for more details. +* +* You should have received a copy of the GNU Affero General Public License +* along with Haveno. If not, see . +*/ + +package haveno.asset; + +/** +* Validates a Solana address using the regular expression for Solana's Base58 encoding format. +* Solana addresses are typically represented as a 44-character Base58 string. +* The address must be a valid Base58 string of length 44. +*/ +public class SolanaAddressValidator extends RegexAddressValidator { + + // Regular expression for a valid Solana address (Base58 encoded, 44 characters long) + public SolanaAddressValidator() { + super("^[1-9A-HJ-NP-Za-km-z]{32,44}$"); + } + + public SolanaAddressValidator(String errorMessageI18nKey) { + super("^[1-9A-HJ-NP-Za-km-z]{32,44}$", errorMessageI18nKey); + } +}