diff --git a/src/main/java/bisq/asset/coins/BitCloud.java b/src/main/java/bisq/asset/coins/BitCloud.java new file mode 100644 index 0000000..4a7b0df --- /dev/null +++ b/src/main/java/bisq/asset/coins/BitCloud.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 BitCloud extends Coin { + + public BitCloud() { + super("BitCloud", "BTDX", new BitCloudAddressValidator()); + } + + + public static class BitCloudAddressValidator extends Base58BitcoinAddressValidator { + + public BitCloudAddressValidator() { + super(new BitCloudParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[B][a-km-zA-HJ-NP-Z1-9]{25,34}$")) + return AddressValidationResult.invalidStructure(); + + return super.validate(address); + } + } + + public static class BitCloudParams extends NetworkParametersAdapter { + + public BitCloudParams() { + addressHeader = 25; + 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 0bc0d60..8b4c759 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -6,6 +6,7 @@ bisq.asset.coins.Achievecoin bisq.asset.coins.Angelcoin bisq.asset.coins.Aquachain bisq.asset.coins.Arto +bisq.asset.coins.BitCloud bisq.asset.coins.BitcoinCash bisq.asset.coins.BitcoinClashic bisq.asset.coins.BitcoinCore diff --git a/src/test/java/bisq/asset/coins/BitCloudTest.java b/src/test/java/bisq/asset/coins/BitCloudTest.java new file mode 100644 index 0000000..302f69b --- /dev/null +++ b/src/test/java/bisq/asset/coins/BitCloudTest.java @@ -0,0 +1,44 @@ +/* + * 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 BitCloudTest extends AbstractAssetTest { + + public BitCloudTest() { + super(new BitCloud()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("B7dtuCkeYcQQiTdr9wAK7HZtmvvrM24jEH"); + assertValidAddress("BGp8DmF5wwpaDUsK9Mi3SByTDuvgy6XJGS"); + assertValidAddress("BDL6jpyNge8VB8LL8dEDX1bxfZ3jHGYzS3"); + assertValidAddress("BKuvEvMrXmPFPC3YGGHHnZoTVYxeddxAjC"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq"); + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYheO"); + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhek#"); + } +}