List Qbase (QBS)

This commit is contained in:
Ross Goldberg 2018-11-21 13:11:57 -06:00
parent cd616ffaf3
commit 6ec318cf7c
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

@ -61,6 +61,7 @@ bisq.asset.coins.Nimiq
bisq.asset.coins.PIVX
bisq.asset.coins.PRiVCY
bisq.asset.coins.PZDC
bisq.asset.coins.Qbase
bisq.asset.coins.QMCoin
bisq.asset.coins.QRL
bisq.asset.coins.Radium

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");
}
}