From 352646201287bf8f9a231a561a143cf40fae6857 Mon Sep 17 00:00:00 2001 From: SUB1X Developer Date: Fri, 27 Jul 2018 01:30:59 +0100 Subject: [PATCH] List SUB1X (SUB1X) --- src/main/java/bisq/asset/coins/Sub1x.java | 56 +++++++++++++++++++ .../META-INF/services/bisq.asset.Asset | 1 + src/test/java/bisq/asset/coins/SUB1XTest.java | 47 ++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 src/main/java/bisq/asset/coins/Sub1x.java create mode 100644 src/test/java/bisq/asset/coins/SUB1XTest.java diff --git a/src/main/java/bisq/asset/coins/Sub1x.java b/src/main/java/bisq/asset/coins/Sub1x.java new file mode 100644 index 0000000..b40a145 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Sub1x.java @@ -0,0 +1,56 @@ +/* + * 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.AddressValidationResult; +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class SUB1X extends Coin { + + public SUB1X() { + super("SUB1X", "SUB1X", new SUB1XAddressValidator()); + } + + + public static class SUB1XAddressValidator extends Base58BitcoinAddressValidator { + + public SUB1XAddressValidator() { + super(new SUB1XParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[Z][a-km-zA-HJ-NP-Z1-9]{25,34}$")) + return AddressValidationResult.invalidStructure(); + + return super.validate(address); + } + } + + + public static class SUB1XParams extends NetworkParametersAdapter { + + public SUB1XParams() { + addressHeader = 30; + p2shHeader = 13; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index ea8a817..cc84f34 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -106,6 +106,7 @@ bisq.asset.coins.SpeedCash bisq.asset.coins.STEEM bisq.asset.coins.Stellite bisq.asset.coins.Strayacoin +bisq.asset.coins.SUB1X bisq.asset.coins.Tamadcoin bisq.asset.coins.Terracoin bisq.asset.coins.Triton diff --git a/src/test/java/bisq/asset/coins/SUB1XTest.java b/src/test/java/bisq/asset/coins/SUB1XTest.java new file mode 100644 index 0000000..d509844 --- /dev/null +++ b/src/test/java/bisq/asset/coins/SUB1XTest.java @@ -0,0 +1,47 @@ +/* + * 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 SUB1XTest extends AbstractAssetTest { + + public SUB1XTest() { + super(new SUB1X()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("ZDxdoVuyosZ6vY3LZAP1Z4H4eXMq2ZpLH7"); + assertValidAddress("ZKi6EksPCZoMi6EGXS9vWVed4NeSov2ZS4"); + assertValidAddress("ZT29B3yDJq1jzkCTBs4LnraM3E854MAPRm"); + assertValidAddress("ZZeaSimQwza3CkFWTrRPQDamZcbntf2uMG"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("ZDxdoVuyosZ6vY3LZAP1Z4H4eXMq2ZpAC7"); + assertInvalidAddress("ZKi6EksPCZoMi6EGXS9vWVedqwfov2ZS4"); + assertInvalidAddress("ZT29B3yDJq1jzkqwrwBs4LnraM3E854MAPRm"); + assertInvalidAddress("ZZeaSimQwza3CkFWTqwrfQDamZcbntf2uMG"); + assertInvalidAddress("Z23t23f"); + assertInvalidAddress("ZZeaSimQwza3CkFWTrRPQDamZcbntf2uMG"); + } +}