mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 15:00:30 +01:00
Add Particl
This commit is contained in:
parent
1a3bdf0f71
commit
71700a2a87
4 changed files with 120 additions and 0 deletions
|
@ -120,6 +120,7 @@ public class CurrencyUtil {
|
|||
result.add(new CryptoCurrency("NBT", "NuBits"));
|
||||
result.add(new CryptoCurrency("NXT", "Nxt"));
|
||||
result.add(new CryptoCurrency("888", "OctoCoin"));
|
||||
result.add(new CryptoCurrency("PART", "Particl"));
|
||||
result.add(new CryptoCurrency("PASC", "Pascal Coin", true));
|
||||
result.add(new CryptoCurrency("PEPECASH", "Pepe Cash"));
|
||||
result.add(new CryptoCurrency("PIVX", "PIVX"));
|
||||
|
|
|
@ -27,6 +27,7 @@ import io.bisq.gui.util.validation.altcoins.PNCAddressValidator;
|
|||
import io.bisq.gui.util.validation.altcoins.XCNAddressValidator;
|
||||
import io.bisq.gui.util.validation.params.IOPParams;
|
||||
import io.bisq.gui.util.validation.params.OctocoinParams;
|
||||
import io.bisq.gui.util.validation.params.PARTParams;
|
||||
import io.bisq.gui.util.validation.params.PNCParams;
|
||||
import io.bisq.gui.util.validation.params.PivxParams;
|
||||
import io.bisq.gui.util.validation.params.WACoinsParams;
|
||||
|
@ -210,6 +211,22 @@ public final class AltCoinAddressValidator extends InputValidator {
|
|||
else
|
||||
return new ValidationResult(true);
|
||||
// Example for BTC, though for BTC we use the BitcoinJ library address check
|
||||
case "PART":
|
||||
if (input.matches("^[RP][a-km-zA-HJ-NP-Z1-9]{25,34}$")) {
|
||||
//noinspection ConstantConditions
|
||||
if (verifyChecksum(input)) {
|
||||
try {
|
||||
Address.fromBase58(PARTParams.get(), input);
|
||||
return new ValidationResult(true);
|
||||
} catch (AddressFormatException e) {
|
||||
return new ValidationResult(false, getErrorMessage(e));
|
||||
}
|
||||
} else {
|
||||
return wrongChecksum;
|
||||
}
|
||||
} else {
|
||||
return regexTestFailed;
|
||||
}
|
||||
case "PIVX":
|
||||
if (input.matches("^[D][a-km-zA-HJ-NP-Z1-9]{25,34}$")) {
|
||||
//noinspection ConstantConditions
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* 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 io.bisq.gui.util.validation.params;
|
||||
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.store.BlockStore;
|
||||
import org.bitcoinj.store.BlockStoreException;
|
||||
import org.bitcoinj.utils.MonetaryFormat;
|
||||
|
||||
public class PARTParams extends NetworkParameters {
|
||||
|
||||
private static PARTParams instance;
|
||||
|
||||
public static synchronized PARTParams get() {
|
||||
if (instance == null) {
|
||||
instance = new PARTParams();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
// We only use the properties needed for address validation
|
||||
public PARTParams() {
|
||||
super();
|
||||
addressHeader = 56;
|
||||
p2shHeader = 60;
|
||||
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
|
||||
}
|
||||
|
||||
// default dummy implementations, not used...
|
||||
@Override
|
||||
public String getPaymentProtocolId() {
|
||||
return PAYMENT_PROTOCOL_ID_MAINNET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Coin getMaxMoney() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Coin getMinNonDustOutput() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MonetaryFormat getMonetaryFormat() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUriScheme() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMaxMoney() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BitcoinSerializer getSerializer(boolean parseRetain) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtocolVersionNum(ProtocolVersion version) {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -52,6 +52,20 @@ public class AltCoinAddressValidatorTest {
|
|||
assertFalse(validator.validate("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhek#").isValid);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPART() {
|
||||
AltCoinAddressValidator validator = new AltCoinAddressValidator();
|
||||
validator.setCurrencyCode("PART");
|
||||
assertTrue(validator.validate("PZdYWHgyhuG7NHVCzEkkx3dcLKurTpvmo6").isValid);
|
||||
assertTrue(validator.validate("RJAPhgckEgRGVPZa9WoGSWW24spskSfLTQ").isValid);
|
||||
assertTrue(validator.validate("PaqMewoBY4vufTkKeSy91su3CNwviGg4EK").isValid);
|
||||
assertTrue(validator.validate("PpWHwrkUKRYvbZbTic57YZ1zjmsV9X9Wu7").isValid);
|
||||
|
||||
assertFalse(validator.validate("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq").isValid);
|
||||
assertFalse(validator.validate("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYheO").isValid);
|
||||
assertFalse(validator.validate("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhek#").isValid);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPIVX() {
|
||||
AltCoinAddressValidator validator = new AltCoinAddressValidator();
|
||||
|
|
Loading…
Add table
Reference in a new issue