diff --git a/assets/src/main/java/bisq/asset/coins/Phore.java b/assets/src/main/java/bisq/asset/coins/Phore.java new file mode 100644 index 00000000000..b843ece63ef --- /dev/null +++ b/assets/src/main/java/bisq/asset/coins/Phore.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 java.util.regex.Pattern; + +import bisq.asset.AddressValidationResult; +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class Phore extends Coin { + public Phore() { + super("Phore", "PHR", new PhoreAddressValidator()); + } + + public static class PhoreAddressValidator extends Base58BitcoinAddressValidator { + + public PhoreAddressValidator() { + super(new PhoreMainNetParams()); + } + + private static final Pattern VALID_ADDRESS = Pattern.compile("^[P][a-km-zA-HJ-NP-Z1-9]{25,34}$"); + + @Override + public AddressValidationResult validate(String address) { + if (!VALID_ADDRESS.matcher(address).matches()) { + return AddressValidationResult.invalidStructure(); + } + return super.validate(address); + } + } + + public static class PhoreMainNetParams extends NetworkParametersAdapter { + + public PhoreMainNetParams() { + this.addressHeader = 55; + this.p2shHeader = 13; + this.acceptableAddressCodes = new int[]{this.addressHeader, this.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 c50ae587255..eaa03c5548b 100644 --- a/assets/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/assets/src/main/resources/META-INF/services/bisq.asset.Asset @@ -84,6 +84,7 @@ bisq.asset.coins.ParsiCoin bisq.asset.coins.Particl bisq.asset.coins.PENG bisq.asset.coins.Persona +bisq.asset.coins.Phore bisq.asset.coins.Pinkcoin bisq.asset.coins.PIVX bisq.asset.coins.Plenteum diff --git a/assets/src/test/java/bisq/asset/coins/PhoreTest.java b/assets/src/test/java/bisq/asset/coins/PhoreTest.java new file mode 100644 index 00000000000..b4cd66afb3a --- /dev/null +++ b/assets/src/test/java/bisq/asset/coins/PhoreTest.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 PhoreTest extends AbstractAssetTest { + + public PhoreTest() { + super(new Phore()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("PJCKDPyvfbf1yV7mYNeJ8Zb47hKRwVPYDj"); + assertValidAddress("PJPmiib7JzMDiMQBBFCz92erB8iUvJqBqt"); + assertValidAddress("PS6yeJnJUD2pe9fpDQvtm4KkLDwCWpa8ub"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("pGXsgFjSMzh1dSqggRvHjPvE3cnwvuXC7s"); + assertInvalidAddress("PXP75NnwDryYswQb9RaPFBchqLRSvBmDP"); + assertInvalidAddress("PKr3vQ7SkqLELsYGM6qeRumyfPx3366uyU9"); + assertInvalidAddress("PKr3vQ7S"); + assertInvalidAddress("P0r3vQ7SkqLELsYGM6qeRumyfPx3366uyU9"); + } +}