From ddec9c791f6f29549dde734d95e41298a082fa23 Mon Sep 17 00:00:00 2001 From: Cave Spectre Date: Fri, 21 Dec 2018 09:49:34 -0500 Subject: [PATCH] List IdaPay (IDA) --- .../main/java/bisq/asset/coins/IdaPay.java | 57 +++++++++++++++++++ .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/IdaPayTest.java | 45 +++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 assets/src/main/java/bisq/asset/coins/IdaPay.java create mode 100644 assets/src/test/java/bisq/asset/coins/IdaPayTest.java diff --git a/assets/src/main/java/bisq/asset/coins/IdaPay.java b/assets/src/main/java/bisq/asset/coins/IdaPay.java new file mode 100644 index 00000000000..84000ff023b --- /dev/null +++ b/assets/src/main/java/bisq/asset/coins/IdaPay.java @@ -0,0 +1,57 @@ +/* + * 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 IdaPay extends Coin { + + public IdaPay() { + super("IdaPay", "IDA", new IdaPayAddressValidator()); + } + + + public static class IdaPayAddressValidator extends Base58BitcoinAddressValidator { + + public IdaPayAddressValidator() { + super(new IdaPayParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[CD][a-km-zA-HJ-NP-Z1-9]{33}$")) + return AddressValidationResult.invalidStructure(); + + return super.validate(address); + } + } + + + public static class IdaPayParams extends NetworkParametersAdapter { + + public IdaPayParams() { + super(); + addressHeader = 29; + p2shHeader = 36; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} 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 ea99318ced0..3c3e71d6255 100644 --- a/assets/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/assets/src/main/resources/META-INF/services/bisq.asset.Asset @@ -25,6 +25,7 @@ bisq.asset.coins.Ether bisq.asset.coins.EtherClassic bisq.asset.coins.Gridcoin bisq.asset.coins.Horizen +bisq.asset.coins.IdaPay bisq.asset.coins.Iridium bisq.asset.coins.Kekcoin bisq.asset.coins.Litecoin diff --git a/assets/src/test/java/bisq/asset/coins/IdaPayTest.java b/assets/src/test/java/bisq/asset/coins/IdaPayTest.java new file mode 100644 index 00000000000..558786834ec --- /dev/null +++ b/assets/src/test/java/bisq/asset/coins/IdaPayTest.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 IdaPayTest extends AbstractAssetTest { + + public IdaPayTest() { + super(new IdaPay()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("Cj6A8JJvovgSTiMc4r6PaJPrfwQnwnHDpg"); + assertValidAddress("D4SEkXMAcxRBu2Gc1KpgcGunAu5rWttjRy"); + assertValidAddress("CopBThXxkziyQEG6WxEfx36Ty46DygzHTW"); + assertValidAddress("D3bEgYWDS7fxfu9y1zTSrcdP681w3MKw6W"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("Cj6A8JJv0vgSTiMc4r6PaJPrfwQnwnHDpg"); + assertInvalidAddress("D4SEkXMAcxxRBu2Gc1KpgcGunAu5rWttjRy"); + assertInvalidAddress("CopBThXxkziyQEG6WxEfx36Ty4#DygzHTW"); + assertInvalidAddress("13bEgYWDS7fxfu9y1zTSrcdP681w3MKw6W"); + } +}