Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List [Polis] (POLIS) #3782

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions assets/src/main/java/bisq/asset/coins/Polis.java
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

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};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 45 additions & 0 deletions assets/src/test/java/bisq/asset/coins/PolisTest.java
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

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");
}
}