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 e99268b9267..63ecbc294e8 100644 --- a/assets/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/assets/src/main/resources/META-INF/services/bisq.asset.Asset @@ -37,6 +37,7 @@ bisq.asset.coins.EtherClassic bisq.asset.coins.FuturoCoin bisq.asset.coins.Graft bisq.asset.coins.Gridcoin +bisq.asset.coins.IdaPay bisq.asset.coins.Kekcoin bisq.asset.coins.Litecoin$Mainnet bisq.asset.coins.Litecoin$Regtest 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"); + } +}