To get around dependency of project assets on project core, a new class

was created to load the properties file.

Unit Test components for touched coins fixed.
This commit is contained in:
Niyi Dada 2019-07-26 00:44:11 +01:00
parent 5fd0a9f9ac
commit 48b2e7dc90
14 changed files with 247 additions and 34 deletions

View File

@ -0,0 +1,23 @@
package bisq.asset;
import java.io.IOException;
import java.util.Properties;
public class I18n extends Properties {
/**
*
*/
private static final long serialVersionUID = -1840156948793172676L;
public static I18n DISPLAY_STRINGS = new I18n();
static {
try {
DISPLAY_STRINGS.load(I18n.class.getResourceAsStream("/resources/i18n/displayStrings.properties"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

View File

@ -18,18 +18,43 @@
package bisq.asset.coins;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.params.MainNetParams;
import org.bitcoinj.params.RegTestParams;
import org.bitcoinj.params.TestNet3Params;
import bisq.asset.AddressValidationResult;
import bisq.asset.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.core.locale.Res;
import bisq.asset.I18n;
public class Counterparty extends Coin {
public Counterparty(Network network, NetworkParameters networkParameters) {
super("Counterparty", "XCP", new XcpAddressValidator(networkParameters), network);
}
public static class Mainnet extends BSQ {
public Mainnet() {
super(Network.MAINNET, MainNetParams.get());
}
}
public static class Testnet extends BSQ {
public Testnet() {
super(Network.TESTNET, TestNet3Params.get());
}
}
public static class Regtest extends BSQ {
public Regtest() {
super(Network.REGTEST, RegTestParams.get());
}
}
public static class XcpAddressValidator extends Base58BitcoinAddressValidator {
@ -40,7 +65,7 @@ public class Counterparty extends Coin {
@Override
public AddressValidationResult validate(String address) {
if (address == null || address.length() != 34 || !address.startsWith("1")) {
return AddressValidationResult.invalidAddress(Res.get("account.altcoin.popup.validation.XCP"));
return AddressValidationResult.invalidAddress(I18n.DISPLAY_STRINGS.getProperty("account.altcoin.popup.validation.XCP"));
}
String addressAsBtc = address.substring(1, address.length());

View File

@ -18,12 +18,14 @@
package bisq.asset.coins;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.params.MainNetParams;
import org.bitcoinj.params.RegTestParams;
import org.bitcoinj.params.TestNet3Params;
import bisq.asset.AddressValidationResult;
import bisq.asset.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.core.locale.Res;
import bisq.asset.I18n;
public class Decred extends Coin {
@ -31,6 +33,29 @@ public class Decred extends Coin {
super("Decred", "DCR", new DcrAddressValidator(networkParameters), network);
}
public static class Mainnet extends BSQ {
public Mainnet() {
super(Network.MAINNET, MainNetParams.get());
}
}
public static class Testnet extends BSQ {
public Testnet() {
super(Network.TESTNET, TestNet3Params.get());
}
}
public static class Regtest extends BSQ {
public Regtest() {
super(Network.REGTEST, RegTestParams.get());
}
}
public static class DcrAddressValidator extends Base58BitcoinAddressValidator {
public DcrAddressValidator(NetworkParameters networkParameters) {
@ -43,7 +68,7 @@ public class Decred extends Coin {
|| !address.startsWith("Ds") || !address.startsWith("De") || !address.startsWith("DS")
|| !address.startsWith("Dc") || !address.startsWith("Pm")) {
return AddressValidationResult
.invalidAddress(Res.get("account.altcoin.popup.validation.DCR"));
.invalidAddress(I18n.DISPLAY_STRINGS.getProperty("account.altcoin.popup.validation.DCR"));
}
String addressAsBtc = address.substring(1, address.length());

View File

@ -19,12 +19,11 @@ package bisq.asset.coins;
import bisq.asset.Coin;
import bisq.asset.EtherAddressValidator;
import bisq.core.locale.Res;
import bisq.asset.I18n;
public class EtherClassic extends Coin {
public EtherClassic() {
super("Ether Classic", "ETC", new EtherAddressValidator(Res.get("account.altcoin.popup.validation.ETC")));
super("Ether Classic", "ETC", new EtherAddressValidator(I18n.DISPLAY_STRINGS.getProperty("account.altcoin.popup.validation.ETC")));
}
}

View File

@ -18,12 +18,14 @@
package bisq.asset.coins;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.params.MainNetParams;
import org.bitcoinj.params.RegTestParams;
import org.bitcoinj.params.TestNet3Params;
import bisq.asset.AddressValidationResult;
import bisq.asset.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.core.locale.Res;
import bisq.asset.I18n;
public class Namecoin extends Coin {
@ -31,6 +33,29 @@ public class Namecoin extends Coin {
super("Namecoin", "NMC", new NmcAddressValidator(networkParameters), network);
}
public static class Mainnet extends BSQ {
public Mainnet() {
super(Network.MAINNET, MainNetParams.get());
}
}
public static class Testnet extends BSQ {
public Testnet() {
super(Network.TESTNET, TestNet3Params.get());
}
}
public static class Regtest extends BSQ {
public Regtest() {
super(Network.REGTEST, RegTestParams.get());
}
}
public static class NmcAddressValidator extends Base58BitcoinAddressValidator {
public NmcAddressValidator(NetworkParameters networkParameters) {
@ -40,7 +65,7 @@ public class Namecoin extends Coin {
@Override
public AddressValidationResult validate(String address) {
if (address == null || address.length() != 34 || !address.startsWith("N") || !address.startsWith("M"))
return AddressValidationResult.invalidAddress(Res.get("account.altcoin.popup.validation.NMC"));
return AddressValidationResult.invalidAddress(I18n.DISPLAY_STRINGS.getProperty("account.altcoin.popup.validation.NMC"));
String addressAsBtc = address.substring(1, address.length());

View File

@ -18,10 +18,9 @@
package bisq.asset.coins;
import bisq.asset.Coin;
import bisq.asset.I18n;
import bisq.asset.RegexAddressValidator;
import bisq.core.locale.Res;
public class Siafund extends Coin {
public Siafund() {
@ -31,7 +30,7 @@ public class Siafund extends Coin {
public static class SfAddressValidator extends RegexAddressValidator {
public SfAddressValidator() {
super("^[0-9a-fA-F]{76}$", Res.get("account.altcoin.popup.validation.XCP"));
super("^[0-9a-fA-F]{76}$", I18n.DISPLAY_STRINGS.getProperty("account.altcoin.popup.validation.XCP"));
}
}

View File

@ -18,18 +18,43 @@
package bisq.asset.coins;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.params.MainNetParams;
import org.bitcoinj.params.RegTestParams;
import org.bitcoinj.params.TestNet3Params;
import bisq.asset.AddressValidationResult;
import bisq.asset.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.core.locale.Res;
import bisq.asset.I18n;
public class Unobtanium extends Coin {
public Unobtanium(Network network, NetworkParameters networkParameters) {
super("Unobtanium", "UNO", new UnoAddressValidator(networkParameters), network);
}
public static class Mainnet extends BSQ {
public Mainnet() {
super(Network.MAINNET, MainNetParams.get());
}
}
public static class Testnet extends BSQ {
public Testnet() {
super(Network.TESTNET, TestNet3Params.get());
}
}
public static class Regtest extends BSQ {
public Regtest() {
super(Network.REGTEST, RegTestParams.get());
}
}
public static class UnoAddressValidator extends Base58BitcoinAddressValidator {
@ -40,7 +65,7 @@ public class Unobtanium extends Coin {
@Override
public AddressValidationResult validate(String address) {
if (address == null || address.length() != 34 || !address.startsWith("u")) {
return AddressValidationResult.invalidAddress(Res.get("account.altcoin.popup.validation.UNO"));
return AddressValidationResult.invalidAddress(I18n.DISPLAY_STRINGS.getProperty("account.altcoin.popup.validation.UNO"));
}
String addressAsBtc = address.substring(1, address.length());

View File

@ -18,13 +18,15 @@
package bisq.asset.coins;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.params.MainNetParams;
import org.bitcoinj.params.RegTestParams;
import org.bitcoinj.params.TestNet3Params;
import bisq.asset.AddressValidationResult;
import bisq.asset.AltCoinAccountDisclaimer;
import bisq.asset.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.core.locale.Res;
import bisq.asset.I18n;
@AltCoinAccountDisclaimer("account.altcoin.popup.XZC.msg")
public class Zcoin extends Coin {
@ -32,6 +34,29 @@ public class Zcoin extends Coin {
public Zcoin(Network network, NetworkParameters networkParameters) {
super("Zcoin", "XZC", new XzcAddressValidator(networkParameters), network);
}
public static class Mainnet extends BSQ {
public Mainnet() {
super(Network.MAINNET, MainNetParams.get());
}
}
public static class Testnet extends BSQ {
public Testnet() {
super(Network.TESTNET, TestNet3Params.get());
}
}
public static class Regtest extends BSQ {
public Regtest() {
super(Network.REGTEST, RegTestParams.get());
}
}
public static class XzcAddressValidator extends Base58BitcoinAddressValidator {
@ -42,7 +67,7 @@ public class Zcoin extends Coin {
@Override
public AddressValidationResult validate(String address) {
if (address == null || address.length() != 34 || !address.startsWith("a")) {
return AddressValidationResult.invalidAddress(Res.get("account.altcoin.popup.validation.XZC"));
return AddressValidationResult.invalidAddress(I18n.DISPLAY_STRINGS.getProperty("account.altcoin.popup.validation.XZC"));
}
String addressAsBtc = address.substring(1, address.length());

View File

@ -17,11 +17,26 @@
package bisq.asset.coins;
import bisq.asset.AbstractAssetWithDefaultValidatorTest;
import bisq.asset.AbstractAssetTest;
public class CounterpartyTest extends AbstractAssetWithDefaultValidatorTest {
public class CounterpartyTest extends AbstractAssetTest {
public CounterpartyTest() {
super(new Counterparty());
super(new Counterparty.Mainnet());
}
@Override
public void testValidAddresses() {
// TODO Auto-generated method stub
assertValidAddress("1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa");
assertValidAddress("111111111112ZkE8UvCp8JCNRhfuBoo");
assertValidAddress("1234567891234567891234567891wBd7RE");
}
@Override
public void testInvalidAddresses() {
assertValidAddress("MxmFPEPzF19JFPU3VPrRXvUbPjMQXnQerY");
assertValidAddress("N22FRU9f3fx7Hty641D5cg95kRK6S3sbf3");
assertValidAddress("MxmFPEPzF19JFPU3VPrRXvUbPjMQXnQerY");
}
}

View File

@ -17,11 +17,27 @@
package bisq.asset.coins;
import bisq.asset.AbstractAssetWithDefaultValidatorTest;
import bisq.asset.AbstractAssetTest;
public class DecredTest extends AbstractAssetWithDefaultValidatorTest {
public class DecredTest extends AbstractAssetTest {
public DecredTest() {
super(new Decred());
super(new Decred.Mainnet());
}
@Override
public void testValidAddresses() {
// TODO Auto-generated method stub
assertValidAddress("Dcur2mcGjmENx4DhNqDctW5wJCVyT3Qeqkx");
assertValidAddress("Dsur2mcGjmENx4DhNqDctW5wJCVyT3Qeqkx");
assertValidAddress("Deur2mcGjmENx4DhNqDctW5wJCVyT3Qeqkx");
}
@Override
public void testInvalidAddresses() {
// TODO Auto-generated method stub
assertValidAddress("aHu897ivzmeFuLNB6956X6gyGeVNHUBRgD");
assertValidAddress("a1HwTdCmQV3NspP2QqCGpehoFpi8NY4Zg3");
assertValidAddress("aHu897ivzmeFuLNB6956X6gyGeVNHUBRgD");
}
}

View File

@ -23,7 +23,7 @@ import bisq.asset.AbstractAssetTest;
public class NamecoinTest extends AbstractAssetTest {
public NamecoinTest() {
super(new Namecoin());
super(new Namecoin.Mainnet());
}
@Test

View File

@ -17,11 +17,25 @@
package bisq.asset.coins;
import bisq.asset.AbstractAssetWithDefaultValidatorTest;
import bisq.asset.AbstractAssetTest;
public class UnobtaniumTest extends AbstractAssetWithDefaultValidatorTest {
public class UnobtaniumTest extends AbstractAssetTest {
public UnobtaniumTest() {
super(new Unobtanium());
super(new Unobtanium.Mainnet());
}
@Override
public void testValidAddresses() {
assertValidAddress("uXN2S9Soj4dSL7fPAuQi9twdaFmtwYndVP");
assertValidAddress("uZymbhuxhfvxzc5EDdqRWrrZKvabZibBu1");
assertValidAddress("uKdudT6DwojHYsBE9JWM43hRV28Rmp1Zm1");
}
@Override
public void testInvalidAddresses() {
assertValidAddress("aHu897ivzmeFuLNB6956X6gyGeVNHUBRgD");
assertValidAddress("a1HwTdCmQV3NspP2QqCGpehoFpi8NY4Zg3");
assertValidAddress("aHu897ivzmeFuLNB6956X6gyGeVNHUBRgD");
}
}

View File

@ -17,11 +17,25 @@
package bisq.asset.coins;
import bisq.asset.AbstractAssetWithDefaultValidatorTest;
import bisq.asset.AbstractAssetTest;
public class ZcoinTest extends AbstractAssetWithDefaultValidatorTest {
public class ZcoinTest extends AbstractAssetTest {
public ZcoinTest() {
super(new Zcoin());
super(new Zcoin.Mainnet());
}
@Override
public void testValidAddresses() {
assertValidAddress("aHu897ivzmeFuLNB6956X6gyGeVNHUBRgD");
assertValidAddress("a1HwTdCmQV3NspP2QqCGpehoFpi8NY4Zg3");
assertValidAddress("aHu897ivzmeFuLNB6956X6gyGeVNHUBRgD");
}
@Override
public void testInvalidAddresses() {
assertValidAddress("MxmFPEPzF19JFPU3VPrRXvUbPjMQXnQerY");
assertValidAddress("N22FRU9f3fx7Hty641D5cg95kRK6S3sbf3");
assertValidAddress("MxmFPEPzF19JFPU3VPrRXvUbPjMQXnQerY");
}
}

View File

@ -1208,6 +1208,14 @@ As burnt blackcoins are unspendable, they can not be reselled. “Selling” bur
burning ordinary blackcoins (with associated data equal to the destination address).\n\n\
In case of a dispute, the BLK seller needs to provide the transaction hash.
account.altcoin.popup.validation.XCP=XCP address must start with '1' and must have 34 characters.
account.altcoin.popup.validation.DCR=DCR address must start with 'Dk' or 'Ds' or 'De' or 'DS' or 'Dc' or 'Pm' and must have 34 characters.
account.altcoin.popup.validation.ETC=ETC address must start with '0x' and made up of letters A to F and numbers which are 40 characters long.
account.altcoin.popup.validation.NMC=NMC address must start with 'N' or 'M' and must be 33 characters long.
account.altcoin.popup.validation.SF= Siafund address must be made up of letters A to F and numbers which are 76 characters long.
account.altcoin.popup.validation.UNO=UNO address must start with 'u' and must have 34 characters.
account.altcoin.popup.validation.XZC=XZC address must start with 'a' and must have 34 characters.
account.fiat.yourFiatAccounts=Your national currency accounts
account.backup.title=Backup wallet