Merge pull request #1948 from Qbase-Foundation/list-qbase-asset

List Qbase (QBS)
This commit is contained in:
Manfred Karrer 2018-12-19 10:25:12 +01:00 committed by GitHub
commit 5ff2534c0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,38 @@
package bisq.asset.coins;
import bisq.asset.AddressValidationResult;
import bisq.asset.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
public class Qbase extends Coin {
public Qbase() {
super("Qbase", "QBS", new Qbase.QbaseAddressValidator());
}
public static class QbaseAddressValidator extends Base58BitcoinAddressValidator {
public QbaseAddressValidator() {
super(new Qbase.QbaseParams());
}
@Override
public AddressValidationResult validate(String address) {
if (!address.matches("^[B][a-km-zA-HJ-NP-Z1-9]{25,34}$"))
return AddressValidationResult.invalidStructure();
return super.validate(address);
}
}
public static class QbaseParams extends NetworkParametersAdapter {
public QbaseParams() {
addressHeader = 25;
p2shHeader = 5;
acceptableAddressCodes = new int[]{addressHeader, p2shHeader};
}
}
}

View File

@ -34,6 +34,7 @@ bisq.asset.coins.Namecoin
bisq.asset.coins.Neos
bisq.asset.coins.PIVX
bisq.asset.coins.PZDC
bisq.asset.coins.Qbase
bisq.asset.coins.QMCoin
bisq.asset.coins.Radium
bisq.asset.coins.Ryo

View File

@ -0,0 +1,28 @@
package bisq.asset.coins;
import bisq.asset.AbstractAssetTest;
import org.junit.Test;
public class QbaseTest extends AbstractAssetTest {
public QbaseTest() {
super(new Qbase());
}
@Test
public void testValidAddresses() {
assertValidAddress("BBrv1uUkQxpWayMvaVSw9Gr4X7CcdWUtcC");
assertValidAddress("BNMFjkDk9qqcF2rtoAbqbqWiHa41GPkQ2G");
assertValidAddress("B73WdFQXx8VGNg8h1BeJj6H2BEa1xrbtsT");
assertValidAddress("BGq4DH2BnS4kFWuNNQqfmiDLZvjaWtvnWX");
assertValidAddress("B9b8iTbVVcQrohrEnJ9ho4QUftHS3svB84");
}
@Test
public void testInvalidAddresses() {
assertInvalidAddress("bBrv1uUkQxpWayMvaVSw9Gr4X7CcdWUtcC");
assertInvalidAddress("B3rv1uUkQxpWayMvaVSw9Gr4X7CcdWUtcC");
assertInvalidAddress("PXP75NnwDryYswQb9RaPFBchqLRSvBmDP");
assertInvalidAddress("PKr3vQ7S");
}
}