diff --git a/assets/src/main/java/bisq/asset/CryptonoteAddressValidator.java b/assets/src/main/java/bisq/asset/CryptonoteAddressValidator.java index 22b28523da..e5ab3c8788 100644 --- a/assets/src/main/java/bisq/asset/CryptonoteAddressValidator.java +++ b/assets/src/main/java/bisq/asset/CryptonoteAddressValidator.java @@ -40,16 +40,39 @@ public class CryptonoteAddressValidator implements AddressValidator { // Invalid characters return AddressValidationResult.invalidStructure(); } - - if (address.startsWith(prefix) && address.length() == 94 + prefix.length()) { - // Standard address - return AddressValidationResult.validAddress(); - } else if (address.startsWith(subAddressPrefix) && address.length() == 94 + subAddressPrefix.length()) { - // Subaddress - return AddressValidationResult.validAddress(); - } else { - // Integrated? Invalid? Doesn't matter + if (address.startsWith(prefix)) { + if (prefix.length() == 1 && address.length() == 94 + prefix.length()) { + // XMR-type Standard address + return AddressValidationResult.validAddress(); + } + else if (prefix.length() == 2 && address.length() == 95 + prefix.length()) { + //Aeon & Blur-type addresses + return AddressValidationResult.validAddress(); + } + else { + //Non-supported prefix + return AddressValidationResult.invalidStructure(); + } + } + if (address.startsWith(subAddressPrefix)) { + if (subAddressPrefix.length() == 1 && address.length() == 94 + subAddressPrefix.length()) { + // XMR-type subaddress + return AddressValidationResult.validAddress(); + } + else if (subAddressPrefix.length() == 2 && address.length() == 95 + subAddressPrefix.length()) { + // Aeon & Blur-type subaddress + return AddressValidationResult.validAddress(); + } + else { + // Non-supported subAddress return AddressValidationResult.invalidStructure(); - } - } + } + } + else { + //Integrated? Invalid? Doesn't matter + return AddressValidationResult.invalidStructure(); + } + } } + + diff --git a/assets/src/main/java/bisq/asset/coins/Blur.java b/assets/src/main/java/bisq/asset/coins/Blur.java new file mode 100644 index 0000000000..5af9341847 --- /dev/null +++ b/assets/src/main/java/bisq/asset/coins/Blur.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq 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. + * + * Bisq 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 Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.CryptonoteAddressValidator; + +public class Blur extends Coin { + + public Blur() { + super("Blur", "BLUR", new CryptonoteAddressValidator("bL", "Ry")); + } +} diff --git a/assets/src/main/resources/META-INF/services/bisq.asset.Asset b/assets/src/main/resources/META-INF/services/bisq.asset.Asset index 719dc35223..025cbf3f10 100644 --- a/assets/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/assets/src/main/resources/META-INF/services/bisq.asset.Asset @@ -20,6 +20,7 @@ bisq.asset.coins.Bitcoin$Testnet bisq.asset.coins.Bitcore bisq.asset.coins.BitDaric bisq.asset.coins.BitZeny +bisq.asset.coins.Blur bisq.asset.coins.BSQ$Mainnet bisq.asset.coins.BSQ$Regtest bisq.asset.coins.BSQ$Testnet diff --git a/assets/src/test/java/bisq/asset/coins/BlurTest.java b/assets/src/test/java/bisq/asset/coins/BlurTest.java new file mode 100644 index 0000000000..4cf93f3569 --- /dev/null +++ b/assets/src/test/java/bisq/asset/coins/BlurTest.java @@ -0,0 +1,44 @@ +/* + * This file is part of Bisq. + * + * Bisq 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. + * + * Bisq 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 Bisq. If not, see . + */ + + package bisq.asset.coins; + + import bisq.asset.AbstractAssetTest; + import org.junit.Test; + + public class BlurTest extends AbstractAssetTest { + + public BlurTest() { + super(new Blur()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("bL3W1g1d12sbxQDTQ6q8bgU2bBp2rkfFFKfNvQuUQTHqgQHRaxKTHqK5Nqdm53BU3ibPnsqbdYAnnJMyqJ6FfN9m3CSZSNqDE"); + assertValidAddress("bL2zBGUBDkQdyYasdoAdvQCxWLa9Mk5Q1PW8Zk7S38vx9xu7T7NMPPWNfieXqUyswo544ZSB3C1n9jLMfsUvR6p91rnrSdx9h"); + assertValidAddress("Ry49oErHtqyHucxADDT2DfEJ9pRv2ciSpKV9XseCuWmx1PK1CZi4gbPKxhWBdtvLJNNc94c4yDutmZrD3WrsHPYV1nvE9X4Cc"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress(""); + assertInvalidAddress("bl4E2BCFY31DPLjeqF6Gu7TEUM5v2JwpmudFX64AubQtFDYEPBvgvQPzidaawDhjAmHeZSw92wEBnUfdfY5144Sad2ZCknZzC"); + assertInvalidAddress("Ry49oErHtqyHucxADDT2DfEJ9pRv2ciSpKV9XseCuWmx1PK1CZi4gbPKxhWBdtvLJNNc94c4yDutmZrD3WrsHPYV1nvE9X40"); + assertInvalidAddress("bLNHRh8pFh5Y14bhBVAoD4cvqHyoPsQJqB3dr49zoF6bNDFrts96tuuj#RoUKWRwpTHmYt4Kf78FES7LCXAXKXFf6bMsx1sdgz"); + assertInvalidAddress("82zBGUBDkQdyYasdoAdvQCxWLa9Mk5Q1PW#8Zk7S38vx9xu7T7NMPPWNfieXqUyswo544ZSB3C1n9jLMfsUvR6p91rnrSdxwd"); + } +}