diff --git a/assets/src/main/java/bisq/asset/coins/SUNP.java b/assets/src/main/java/bisq/asset/coins/SUNP.java new file mode 100644 index 00000000000..3a02de66801 --- /dev/null +++ b/assets/src/main/java/bisq/asset/coins/SUNP.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 SUNP extends Coin { + + public SUNP() { + super("SUNP", "SUNP", new SUNPAddressValidator()); + } + + + public static class SUNPAddressValidator extends Base58BitcoinAddressValidator { + + public SUNPAddressValidator() { + super(new SUNPParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[S][a-km-zA-HJ-NP-Z1-9]{24,33}$")) + return AddressValidationResult.invalidStructure(); + + return super.validate(address); + } + } + + + public static class SUNPParams extends NetworkParametersAdapter { + + public SUNPParams() { + addressHeader = 63; + p2shHeader = 23; + 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 4e9e05ccb67..12a9fa08bb6 100644 --- a/assets/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/assets/src/main/resources/META-INF/services/bisq.asset.Asset @@ -52,6 +52,7 @@ bisq.asset.coins.SpaceCash bisq.asset.coins.Spectrecoin bisq.asset.coins.Starwels bisq.asset.coins.SUB1X +bisq.asset.coins.SUNP bisq.asset.coins.TurtleCoin bisq.asset.coins.Unobtanium bisq.asset.coins.Zcash diff --git a/assets/src/test/java/bisq/asset/coins/SUNPTest.java b/assets/src/test/java/bisq/asset/coins/SUNPTest.java new file mode 100644 index 00000000000..cb4c71f3e38 --- /dev/null +++ b/assets/src/test/java/bisq/asset/coins/SUNPTest.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 SUNPTest extends AbstractAssetTest { + + public SUNPTest() { + super(new SUNP()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("SQEasE1ErGeSSqjruzL879UNPeV7sWbnAN"); + assertValidAddress("SRK1eahAugt3k6BQjbR1EFYWTAGzg6uXPd"); + assertValidAddress("SfCe8XrgG2FTPLyuheJ2kMVTD4QehjPUPb"); + assertValidAddress("SkSJUTCgfJyGM6REhvt54JNQswnwsGHt5E"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("sQEasE1ErGeSSqjruzL879UNPeV7sWbnAN"); + assertInvalidAddress("SRK1eahBugt3k6BQjbR1EFYWTAGzg6uXpD#"); + assertInvalidAddress("SfCe8XrgG2FT@LyuheJ2kMVTD4QehjLULd"); + assertInvalidAddress("SSSJUTCgfJy$M6REhvt54JNQswnwsGHt6e"); + assertInvalidAddress("SfCe8XrgG2"); + } +}