From a949dd08f66c8dd672f085c04bb1037d0e83a46b Mon Sep 17 00:00:00 2001 From: ksynb Date: Thu, 6 Sep 2018 08:21:43 -0400 Subject: [PATCH] List Neos (NEOS) --- src/main/java/bisq/asset/coins/Neos.java | 56 +++++++++++++++++++ .../META-INF/services/bisq.asset.Asset | 1 + src/test/java/bisq/asset/coins/NeosTest.java | 45 +++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 src/main/java/bisq/asset/coins/Neos.java create mode 100644 src/test/java/bisq/asset/coins/NeosTest.java diff --git a/src/main/java/bisq/asset/coins/Neos.java b/src/main/java/bisq/asset/coins/Neos.java new file mode 100644 index 0000000..f8efecb --- /dev/null +++ b/src/main/java/bisq/asset/coins/Neos.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 Neos extends Coin { + + public Neos() { + super("Neos", "NEOS", new NeosAddressValidator()); + } + + + public static class NeosAddressValidator extends Base58BitcoinAddressValidator { + + public NeosAddressValidator() { + super(new NeosParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[N][a-km-zA-HJ-NP-Z1-9]{25,34}$")) + return AddressValidationResult.invalidStructure(); + + return super.validate(address); + } + } + + + public static class NeosParams extends NetworkParametersAdapter { + + public NeosParams() { + addressHeader = 53; + p2shHeader = 5; + 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 6474d48..14c9ec6 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -80,6 +80,7 @@ bisq.asset.coins.Namecoin bisq.asset.coins.Nano bisq.asset.coins.NavCoin bisq.asset.coins.NEETCOIN +bisq.asset.coins.Neos bisq.asset.coins.NewPowerCoin bisq.asset.coins.Nilu bisq.asset.coins.Nimiq diff --git a/src/test/java/bisq/asset/coins/NeosTest.java b/src/test/java/bisq/asset/coins/NeosTest.java new file mode 100644 index 0000000..5c11338 --- /dev/null +++ b/src/test/java/bisq/asset/coins/NeosTest.java @@ -0,0 +1,45 @@ +/* + * 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 NeosTest extends AbstractAssetTest { + + public NeosTest() { + super(new Neos()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("NS5cGWdERahJ11pn12GoV5Jb7nsLzdr3kP"); + assertValidAddress("NU7nCzyQiAtTxzXLnDsJu4NhwQqrnPyJZj"); + assertValidAddress("NeeAy35aQirpmTARHEXpP8uTmpPCcSD9Qn"); + assertValidAddress("NScgetCW5bqDTVWFH3EYNMtTo5RcvDxD6B"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq"); + assertInvalidAddress("NScgetCW5bqDTVWFH3EYNMtTo5Rc#DxD6B"); + assertInvalidAddress("NeeAy35a0irpmTARHEXpP8uTmpPCcSD9Qn"); + assertInvalidAddress("NScgetCWRcvDxD6B"); + } +}