Merge pull request #2919 from nikchis/list-particl-asset

List Particl (PART)
This commit is contained in:
Christoph Atteneder 2019-07-17 11:21:32 +02:00 committed by GitHub
commit a6ab3e0865
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 98 additions and 0 deletions

View File

@ -0,0 +1,53 @@
/*
* 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.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
import bisq.asset.AddressValidationResult;
public class Particl extends Coin {
public Particl() {
super("Particl", "PART", new ParticlMainNetAddressValidator());
}
public static class ParticlMainNetParams extends NetworkParametersAdapter {
public ParticlMainNetParams() {
this.addressHeader = 56;
this.p2shHeader = 60;
this.acceptableAddressCodes = new int[]{this.addressHeader, this.p2shHeader};
}
}
public static class ParticlMainNetAddressValidator extends Base58BitcoinAddressValidator {
public ParticlMainNetAddressValidator() {
super(new ParticlMainNetParams());
}
@Override
public AddressValidationResult validate(String address) {
if (!address.matches("^[RP][a-km-zA-HJ-NP-Z1-9]{25,34}$"))
return AddressValidationResult.invalidStructure();
return super.validate(address);
}
}
}

View File

@ -70,6 +70,7 @@ bisq.asset.coins.Navcoin
bisq.asset.coins.Neos
bisq.asset.coins.Noir
bisq.asset.coins.ParsiCoin
bisq.asset.coins.Particl
bisq.asset.coins.Persona
bisq.asset.coins.Pinkcoin
bisq.asset.coins.PIVX

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
package bisq.asset.coins;
import bisq.asset.AbstractAssetTest;
import org.junit.Test;
public class ParticlTest extends AbstractAssetTest {
public ParticlTest() {
super(new Particl());
}
@Test
public void testValidAddresses() {
assertValidAddress("PZdYWHgyhuG7NHVCzEkkx3dcLKurTpvmo6");
assertValidAddress("RJAPhgckEgRGVPZa9WoGSWW24spskSfLTQ");
assertValidAddress("PaqMewoBY4vufTkKeSy91su3CNwviGg4EK");
assertValidAddress("PpWHwrkUKRYvbZbTic57YZ1zjmsV9X9Wu7");
}
@Test
public void testInvalidAddresses() {
assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq");
assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYheO");
assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhek");
}
}