Merge pull request #2981 from fflo/master-namecoin

Namecoin (NMC) update AddressValidator
This commit is contained in:
Christoph Atteneder 2019-07-23 09:26:11 +02:00 committed by GitHub
commit 65b4043167
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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");
}
}