From 1d1473d6356e7b967e9676cb2e85366c5896b13a Mon Sep 17 00:00:00 2001 From: Enrique Date: Thu, 12 Dec 2019 09:57:30 -0600 Subject: [PATCH 1/4] Create Polis.java --- .../src/main/java/bisq/asset/coins/Polis.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 assets/src/main/java/bisq/asset/coins/Polis.java diff --git a/assets/src/main/java/bisq/asset/coins/Polis.java b/assets/src/main/java/bisq/asset/coins/Polis.java new file mode 100644 index 00000000000..97fbba39e05 --- /dev/null +++ b/assets/src/main/java/bisq/asset/coins/Polis.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 Polis extends Coin { + public Polis() { + super("Polis", "POLIS", new PolisAddressValidator()); + } + + public static class PolisAddressValidator extends Base58BitcoinAddressValidator { + + public PolisAddressValidator() { + super(new PolisMainNetParams()); + } + + 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 PolisMainNetParams extends NetworkParametersAdapter { + + public PolisMainNetParams() { + this.addressHeader = 55; + this.p2shHeader = 56; + this.acceptableAddressCodes = new int[]{this.addressHeader, this.p2shHeader}; + } + } +} From aaf8d6b5e7a6e2eefae6eeace861dd97617a1e6a Mon Sep 17 00:00:00 2001 From: Enrique Date: Thu, 12 Dec 2019 10:03:42 -0600 Subject: [PATCH 2/4] Create PolisTest.java --- .../test/java/bisq/asset/coins/PolisTest.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 assets/src/test/java/bisq/asset/coins/PolisTest.java diff --git a/assets/src/test/java/bisq/asset/coins/PolisTest.java b/assets/src/test/java/bisq/asset/coins/PolisTest.java new file mode 100644 index 00000000000..1ed77973bf1 --- /dev/null +++ b/assets/src/test/java/bisq/asset/coins/PolisTest.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 PolisTest extends AbstractAssetTest { + + public PolisTest() { + super(new Polis()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("PVhekAVcBTdZa6ubDJ9mup83Lg2bt374Cw"); + assertValidAddress("PQXohxv155izyStLxC77zjLKqFQe4et1q"); + assertValidAddress("PDmRhhLKzekmKj65huGUNDALFS4EAbupWh"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("PVhekAVcBTdZa6ubDJ9mup83Lg2bt374C"); + assertInvalidAddress("pVhekAVcBTdZa6ubDJ9mup83Lg2bt374Cw"); + assertInvalidAddress("PDmRhhLKz"); + assertInvalidAddress("PDmRhhLKzekmKj65huGUNDALFS4EAbupWha"); + assertInvalidAddress("PDXohxv155izyStLxC77zjLKqFQe4et1q"); + } +} From c5e13707089e8f2cc8f28f4456d5d8a2c135d02f Mon Sep 17 00:00:00 2001 From: Enrique Date: Thu, 12 Dec 2019 10:04:28 -0600 Subject: [PATCH 3/4] Update bisq.asset.Asset --- assets/src/main/resources/META-INF/services/bisq.asset.Asset | 1 + 1 file changed, 1 insertion(+) 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..7a00b6a4e94 100644 --- a/assets/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/assets/src/main/resources/META-INF/services/bisq.asset.Asset @@ -87,6 +87,7 @@ bisq.asset.coins.Persona bisq.asset.coins.Pinkcoin bisq.asset.coins.PIVX bisq.asset.coins.Plenteum +bisq.asset.coins.Polis bisq.asset.coins.PZDC bisq.asset.coins.Qbase bisq.asset.coins.QMCoin From 5dc44ac9a2ea3ad3a998ce8575b8e1ccbeae1741 Mon Sep 17 00:00:00 2001 From: Enrique Date: Thu, 12 Dec 2019 12:15:45 -0600 Subject: [PATCH 4/4] Fix valid address test --- assets/src/test/java/bisq/asset/coins/PolisTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/src/test/java/bisq/asset/coins/PolisTest.java b/assets/src/test/java/bisq/asset/coins/PolisTest.java index 1ed77973bf1..674da6ce839 100644 --- a/assets/src/test/java/bisq/asset/coins/PolisTest.java +++ b/assets/src/test/java/bisq/asset/coins/PolisTest.java @@ -30,7 +30,7 @@ public PolisTest() { @Test public void testValidAddresses() { assertValidAddress("PVhekAVcBTdZa6ubDJ9mup83Lg2bt374Cw"); - assertValidAddress("PQXohxv155izyStLxC77zjLKqFQe4et1q"); + assertValidAddress("PQXohxv155izyStLxC77zjLKqFQe4et1q5"); assertValidAddress("PDmRhhLKzekmKj65huGUNDALFS4EAbupWh"); }