From 7a018ec1709569fdb822e06d35f090cd58d4e0ed Mon Sep 17 00:00:00 2001 From: DarkMonad Date: Fri, 19 Oct 2018 22:21:48 +0200 Subject: [PATCH] List Odin (ODIN) --- .../src/main/java/bisq/asset/coins/Odin.java | 55 +++++++++++++++++++ .../META-INF/services/bisq.asset.Asset | 1 + .../test/java/bisq/asset/coins/OdinTest.java | 46 ++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 assets/src/main/java/bisq/asset/coins/Odin.java create mode 100644 assets/src/test/java/bisq/asset/coins/OdinTest.java diff --git a/assets/src/main/java/bisq/asset/coins/Odin.java b/assets/src/main/java/bisq/asset/coins/Odin.java new file mode 100644 index 00000000000..15ab673c712 --- /dev/null +++ b/assets/src/main/java/bisq/asset/coins/Odin.java @@ -0,0 +1,55 @@ +/* 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 Odin extends Coin { + + public Odin() { + super("Odin", "ODIN", new OdinAddressValidator()); + } + + + public static class OdinAddressValidator extends Base58BitcoinAddressValidator { + + public OdinAddressValidator() { + super(new OdinParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[o][a-km-zA-HJ-NP-Z1-9]{25,34}$")) + return AddressValidationResult.invalidStructure(); + + return super.validate(address); + } + } + + + public static class OdinParams extends NetworkParametersAdapter { + + public OdinParams() { + addressHeader = 115; + p2shHeader = 57; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} \ No newline at end of file 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 96349c48e36..9520a6ca454 100644 --- a/assets/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/assets/src/main/resources/META-INF/services/bisq.asset.Asset @@ -97,6 +97,7 @@ bisq.asset.coins.NuBits bisq.asset.coins.Nxt bisq.asset.coins.Obsidian bisq.asset.coins.Octocoin +bisq.asset.coins.Odin bisq.asset.coins.Particl bisq.asset.coins.PepeCash bisq.asset.coins.Phore diff --git a/assets/src/test/java/bisq/asset/coins/OdinTest.java b/assets/src/test/java/bisq/asset/coins/OdinTest.java new file mode 100644 index 00000000000..b52f6ccdcd7 --- /dev/null +++ b/assets/src/test/java/bisq/asset/coins/OdinTest.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 OdinTest extends AbstractAssetTest { + + public OdinTest() { + super(new Odin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("oLSvH9Vx9NsGj27dkEJ2UTnq8HaCpx36V8"); + assertValidAddress("oNsyRf7uuVjy1n5LtSSeff6TjrkH5frqfQ"); + assertValidAddress("oNENRRLSULi6bk2njMnAF8JQ54E1nRaUsh"); + assertValidAddress("oH3ZzfWi8zwiQza1V5eaKZimQUGJMzoUsM"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("PJCKDPyvfbf1yV7mYNeJ8Zb47hKRwVPYDj"); + assertInvalidAddress("XEfyuzk8yTp5eA9eVUeCW2PFbCFtNb6Jgv"); + assertInvalidAddress("PZdYWHgyhuG7NHVCzEkkx3dcLKurTpvmo6"); + assertInvalidAddress("PS6yeJnJUD2pe9fpDQvtm4KkLDwCWpa8ub"); + assertInvalidAddress("DFJku78A14HYwPSzC5PtUmda7jMr5pbD2B"); + } +}