Namecoin (NMC) update AddressValidator

This commit is contained in:
Florian Fuessl 2019-06-24 02:45:21 +02:00
parent 79a49fed3e
commit e6bc0030ee
2 changed files with 30 additions and 4 deletions

View File

@ -17,12 +17,20 @@
package bisq.asset.coins;
import bisq.asset.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.DefaultAddressValidator;
import bisq.asset.NetworkParametersAdapter;
public class Namecoin extends Coin {
public Namecoin() {
super("Namecoin", "NMC", new DefaultAddressValidator());
super("Namecoin", "NMC", new Base58BitcoinAddressValidator(new NamecoinChainParams()));
}
public static class NamecoinChainParams extends NetworkParametersAdapter {
public NamecoinChainParams() {
addressHeader = 52;
acceptableAddressCodes = new int[]{addressHeader};
}
}
}

View File

@ -17,11 +17,29 @@
package bisq.asset.coins;
import bisq.asset.AbstractAssetWithDefaultValidatorTest;
import org.junit.Test;
import bisq.asset.AbstractAssetTest;
public class NamecoinTest extends AbstractAssetWithDefaultValidatorTest {
public class NamecoinTest extends AbstractAssetTest {
public NamecoinTest() {
super(new Namecoin());
}
@Test
public void testValidAddresses() {
assertValidAddress("N7yhcPhzFduWXPc11AUK9zvtnsL6sgxmRs");
assertValidAddress("N22FRU9f3fx7Hty641D5cg95kRK6S3sbf3");
assertValidAddress("MxmFPEPzF19JFPU3VPrRXvUbPjMQXnQerY");
}
@Test
public void testInvalidAddresses() {
assertInvalidAddress("N7yhcPhzFduWXPc11AUK9zvtnsL6sgxmRsx");
assertInvalidAddress("MxmFPEPzF19JFPU3VPrRXvUbPjMQXnQer");
assertInvalidAddress("bc1qus65zpte6qa2408qu3540lfcyj9cx7dphfcspn");
assertInvalidAddress("3GyEtTwXhxbjBtmAR3CtzeayAyshtvd44P");
assertInvalidAddress("1CnXYrivw7pJy3asKftp41wRPgBggF9fBw");
}
}