From 8aca297edfcdf83f651f92e0d57d51810ca35a4a Mon Sep 17 00:00:00 2001 From: diablax Date: Wed, 7 Nov 2018 03:28:34 -0800 Subject: [PATCH] List Mask (MASK) --- .../asset/CryptonoteAddressValidator.java | 2 +- .../src/main/java/bisq/asset/coins/Mask.java | 27 +++++++++++ .../META-INF/services/bisq.asset.Asset | 1 + .../test/java/bisq/asset/coins/MaskTest.java | 46 +++++++++++++++++++ 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 assets/src/main/java/bisq/asset/coins/Mask.java create mode 100644 assets/src/test/java/bisq/asset/coins/MaskTest.java diff --git a/assets/src/main/java/bisq/asset/CryptonoteAddressValidator.java b/assets/src/main/java/bisq/asset/CryptonoteAddressValidator.java index e5ab3c8788..df992f1b05 100644 --- a/assets/src/main/java/bisq/asset/CryptonoteAddressValidator.java +++ b/assets/src/main/java/bisq/asset/CryptonoteAddressValidator.java @@ -60,7 +60,7 @@ public class CryptonoteAddressValidator implements AddressValidator { return AddressValidationResult.validAddress(); } else if (subAddressPrefix.length() == 2 && address.length() == 95 + subAddressPrefix.length()) { - // Aeon & Blur-type subaddress + // Aeon, Mask & Blur-type subaddress return AddressValidationResult.validAddress(); } else { diff --git a/assets/src/main/java/bisq/asset/coins/Mask.java b/assets/src/main/java/bisq/asset/coins/Mask.java new file mode 100644 index 0000000000..9921722215 --- /dev/null +++ b/assets/src/main/java/bisq/asset/coins/Mask.java @@ -0,0 +1,27 @@ +/* + * 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 Mask extends Coin { + public Mask() { + super("Mask", "MASK", new CryptonoteAddressValidator("M", "bT")); + } +} 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 96349c48e3..3a3f77a9f4 100644 --- a/assets/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/assets/src/main/resources/META-INF/services/bisq.asset.Asset @@ -76,6 +76,7 @@ bisq.asset.coins.Loki bisq.asset.coins.Madbyte bisq.asset.coins.Madcoin bisq.asset.coins.MaidSafeCoin +bisq.asset.coins.Mask bisq.asset.coins.MaxCoin bisq.asset.coins.Mazacoin bisq.asset.coins.MegaCoin diff --git a/assets/src/test/java/bisq/asset/coins/MaskTest.java b/assets/src/test/java/bisq/asset/coins/MaskTest.java new file mode 100644 index 0000000000..66203c5644 --- /dev/null +++ b/assets/src/test/java/bisq/asset/coins/MaskTest.java @@ -0,0 +1,46 @@ +/* + * 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 MaskTest extends AbstractAssetTest { + + public MaskTest() { + super(new Mask()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("MbxYjp38aUXBuESwsFv8YmRvbQvMhNyJygU6ViLCjM4sUNqFjsHQim9dvzp9p8BVTjdsRkVNrC1Zy3NJRb18hav3CPe5eWn"); + assertValidAddress("MeGcanFnSr4bJFuNoHogCBdDCsqDrNu5njPc1Yh1DfsTUTL5dLbbtE119f4vztxXu6fFCKWRmpqjABdDyGrzMDkhTC38WwS"); + assertValidAddress("bTWEbW8kKVrZkDwyPs5t7BZXotMNyz5UY2QDJ6MjKT7ihA8kNKhoHDqPUiUB7jPxNpXLFkJsgL6TA1fo7yAzVUdm1hTopCocf"); + assertValidAddress("bTXejHgtfTLWzhyz9fHHBDKTWrsM8MKnebZCKeue8mbDWaKRhnQ8VisGRXUgTvUhsDiwX6PxeP5A22DFf5UVEk431Vjt8m3GM"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress(""); + assertInvalidAddress("MsopefFnSr4bJFuNoHogCBdDCsqDrNu5Pc1Yh1DfsTUTL5dLbbtE119f4vztxXu6fFCKWRmpqjABdDyGrzMDkhTC38gWw"); + assertInvalidAddress("MeGcanuyt4bJFuNoHogCBdDCsqDrNu5njPc1Yh1DfsTUTL5dLbbtE119f4vztxXu6fFCKWRmpqujABdDyGrzMDkhTC38WwSx"); + assertInvalidAddress("MrtcanFnSr4bJFuNoHogCBdDCsqDrNu5Pc1Yh1DfsTUTL5dLbbtE119f4vztxXu6fFCKWRmpqjABdDyGrzMDkhTC3rt4vb8Ww"); + assertInvalidAddress("bBXejHgtfTLWzhyz9fHKBDKTWrsM8MKnebZCKeue8mbDWaKRhnQ8VisGRXUgTvUhsDiwX6PxeP5A22DFf5UVEk431Vjt8m3GM"); + } +}