Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue 1896 #3009

Merged
merged 7 commits into from Aug 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assets/src/main/java/bisq/asset/EtherAddressValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ public class EtherAddressValidator extends RegexAddressValidator {
public EtherAddressValidator() {
super("^(0x)?[0-9a-fA-F]{40}$");
}

public EtherAddressValidator(String errorMessageI18nKey) {
super("^(0x)?[0-9a-fA-F]{40}$", errorMessageI18nKey);
}
}
8 changes: 8 additions & 0 deletions assets/src/main/java/bisq/asset/I18n.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package bisq.asset;

import java.util.ResourceBundle;

public class I18n {

public static ResourceBundle DISPLAY_STRINGS = ResourceBundle.getBundle("i18n.displayStrings-assets");
}
14 changes: 11 additions & 3 deletions assets/src/main/java/bisq/asset/coins/Counterparty.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@
package bisq.asset.coins;

import bisq.asset.Coin;
import bisq.asset.DefaultAddressValidator;
import bisq.asset.I18n;
import bisq.asset.RegexAddressValidator;

public class Counterparty extends Coin {

public Counterparty() {
super("Counterparty", "XCP", new DefaultAddressValidator());
super("Counterparty", "XCP", new XcpAddressValidator());
}

public static class XcpAddressValidator extends RegexAddressValidator {

public XcpAddressValidator() {
super("^[1][a-zA-Z0-9]{33}", I18n.DISPLAY_STRINGS.getString("account.altcoin.popup.validation.XCP"));
}
}
}
14 changes: 11 additions & 3 deletions assets/src/main/java/bisq/asset/coins/Decred.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@
package bisq.asset.coins;

import bisq.asset.Coin;
import bisq.asset.DefaultAddressValidator;
import bisq.asset.I18n;
import bisq.asset.RegexAddressValidator;

public class Decred extends Coin {

public Decred() {
super("Decred", "DCR", new DefaultAddressValidator());
public Decred() {
super("Decred", "DCR", new DcrAddressValidator());
}

public static class DcrAddressValidator extends RegexAddressValidator {

public DcrAddressValidator() {
super("^[Dk|Ds|De|DS|Dc|Pm][a-zA-Z0-9]{24,34}", I18n.DISPLAY_STRINGS.getString("account.altcoin.popup.validation.DCR"));
}
}
}
5 changes: 3 additions & 2 deletions assets/src/main/java/bisq/asset/coins/EtherClassic.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
package bisq.asset.coins;

import bisq.asset.Coin;
import bisq.asset.DefaultAddressValidator;
import bisq.asset.EtherAddressValidator;
import bisq.asset.I18n;

public class EtherClassic extends Coin {

public EtherClassic() {
super("Ether Classic", "ETC", new DefaultAddressValidator());
super("Ether Classic", "ETC", new EtherAddressValidator(I18n.DISPLAY_STRINGS.getString("account.altcoin.popup.validation.ETC")));
}
}
16 changes: 8 additions & 8 deletions assets/src/main/java/bisq/asset/coins/Namecoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@

package bisq.asset.coins;

import bisq.asset.Base58BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;
import bisq.asset.I18n;
import bisq.asset.RegexAddressValidator;

public class Namecoin extends Coin {

public Namecoin() {
super("Namecoin", "NMC", new Base58BitcoinAddressValidator(new NamecoinChainParams()));
public Namecoin() {
super("Namecoin", "NMC", new NmcAddressValidator());
}

public static class NmcAddressValidator extends RegexAddressValidator {

public static class NamecoinChainParams extends NetworkParametersAdapter {
public NamecoinChainParams() {
addressHeader = 52;
acceptableAddressCodes = new int[]{addressHeader};
public NmcAddressValidator() {
super("^[NM][a-zA-Z0-9]{33}$", I18n.DISPLAY_STRINGS.getString("account.altcoin.popup.validation.NMC"));
}
}
}
13 changes: 11 additions & 2 deletions assets/src/main/java/bisq/asset/coins/Siafund.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,20 @@
package bisq.asset.coins;

import bisq.asset.Coin;
import bisq.asset.DefaultAddressValidator;
import bisq.asset.I18n;
import bisq.asset.RegexAddressValidator;

public class Siafund extends Coin {

public Siafund() {
super("Siafund", "SF", new DefaultAddressValidator());
super("Siafund", "SF", new SfAddressValidator());
}

public static class SfAddressValidator extends RegexAddressValidator {

public SfAddressValidator() {
super("^[0-9a-fA-F]{76}$", I18n.DISPLAY_STRINGS.getString("account.altcoin.popup.validation.XCP"));
}
}

}
14 changes: 11 additions & 3 deletions assets/src/main/java/bisq/asset/coins/Unobtanium.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@
package bisq.asset.coins;

import bisq.asset.Coin;
import bisq.asset.DefaultAddressValidator;
import bisq.asset.I18n;
import bisq.asset.RegexAddressValidator;

public class Unobtanium extends Coin {

public Unobtanium() {
super("Unobtanium", "UNO", new DefaultAddressValidator());
public Unobtanium() {
super("Unobtanium", "UNO", new UnoAddressValidator());
}

public static class UnoAddressValidator extends RegexAddressValidator {

public UnoAddressValidator() {
super("^[u]?[a-zA-Z0-9]{33}", I18n.DISPLAY_STRINGS.getString("account.altcoin.popup.validation.UNO"));
}
}
}
14 changes: 11 additions & 3 deletions assets/src/main/java/bisq/asset/coins/Zcoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@

import bisq.asset.AltCoinAccountDisclaimer;
import bisq.asset.Coin;
import bisq.asset.DefaultAddressValidator;
import bisq.asset.I18n;
import bisq.asset.RegexAddressValidator;

@AltCoinAccountDisclaimer("account.altcoin.popup.XZC.msg")
public class Zcoin extends Coin {

public Zcoin() {
super("Zcoin", "XZC", new DefaultAddressValidator());
public Zcoin() {
super("Zcoin", "XZC", new XzcAddressValidator());
}

public static class XzcAddressValidator extends RegexAddressValidator {

public XzcAddressValidator() {
super("^a?[a-zA-Z0-9]{33}", I18n.DISPLAY_STRINGS.getString("account.altcoin.popup.validation.XZC"));
}
}
}
28 changes: 28 additions & 0 deletions assets/src/main/resources/i18n/displayStrings-assets.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Keep display strings organized by domain
# Naming convention: We use camelCase and dot separated name spaces.
# Use as many sub spaces as required to make the structure clear, but as little as possible.
# E.g.: [main-view].[component].[description]
# In some cases we use enum values or constants to map to display strings

# A annoying issue with property files is that we need to use 2 single quotes in display string
# containing variables (e.g. {0}), otherwise the variable will not be resolved.
# In display string which do not use a variable a single quote is ok.
# E.g. Don''t .... {1}

# We use sometimes dynamic parts which are put together in the code and therefore sometimes use line breaks or spaces
# at the end of the string. Please never remove any line breaks or spaces. They are there with a purpose!
# To make longer strings with better readable you can make a line break with \ which does not result in a line break
# in the display but only in the editor.

# Please use in all language files the exact same order of the entries, that way a comparison is easier.

# Please try to keep the length of the translated string similar to English. If it is longer it might break layout or
# get truncated. We will need some adjustments in the UI code to support that but we want to keep effort at the minimum.

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 34 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.
18 changes: 16 additions & 2 deletions assets/src/test/java/bisq/asset/coins/CounterpartyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,25 @@

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

@Override
public void testValidAddresses() {
assertValidAddress("1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa");
assertValidAddress("1KBbojKRf1YnJKp1YK5eEz9TWlS4pFEbwS");
assertValidAddress("1AtLN6BMlW0Rwj800LNcBBR2o0k0sYVuIN");
}

@Override
public void testInvalidAddresses() {
assertInvalidAddress("MxmFPEPzF19JFPU3VPrRXvUbPjMQXnQerY");
assertInvalidAddress("122FRU9f3fx7Hty641DRK6S3sbf3");
assertInvalidAddress("MxmFPEPzF19JFPU3VPrRXvUbPjMQXnQerY");
}
}
20 changes: 18 additions & 2 deletions assets/src/test/java/bisq/asset/coins/DecredTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

@Override
public void testValidAddresses() {
// TODO Auto-generated method stub
assertValidAddress("Dcur2mcGjmENx4DhNqDctW5wJCVyT3Qeqkx");
assertValidAddress("Dsur2mcGjmENx4DhNqDctW5wJCVyT3Qeqkx");
assertValidAddress("Deur2mcGjmENx4DhNqDctW5wJCVyT3Qeqkx");
}

@Override
public void testInvalidAddresses() {
// TODO Auto-generated method stub
assertInvalidAddress("aHu897ivzmeFuLNB6956X6gyGeVNHUBRgD");
assertInvalidAddress("a1HwTdCmQV3NspP2QqCGpehoFpi8NY4Zg3");
assertInvalidAddress("aHu897ivzmeFuLNB6956X6gyGeVNHUBRgD");
}
}
19 changes: 17 additions & 2 deletions assets/src/test/java/bisq/asset/coins/EtherClassicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,26 @@

package bisq.asset.coins;

import bisq.asset.AbstractAssetWithDefaultValidatorTest;
import bisq.asset.AbstractAssetTest;

public class EtherClassicTest extends AbstractAssetWithDefaultValidatorTest {
public class EtherClassicTest extends AbstractAssetTest {

public EtherClassicTest() {
super(new EtherClassic());
}

@Override
public void testValidAddresses() {
assertValidAddress("0x353c13b940aa5eed75aa97d477954289e7880bb8");
assertValidAddress("0x9f5304DA62A5408416Ea58A17a92611019bD5ce3");
assertValidAddress("0x180826b05452ce96E157F0708c43381Fee64a6B8");

}

@Override
public void testInvalidAddresses() {
assertInvalidAddress("MxmFPEPzF19JFPU3VPrRXvUbPjMQXnQerY");
assertInvalidAddress("N22FRU9f3fx7Hty641D5cg95kRK6S3sbf3");
assertInvalidAddress("MxmFPEPzF19JFPU3VPrRXvUbPjMQXnQerY");
}
}
19 changes: 17 additions & 2 deletions assets/src/test/java/bisq/asset/coins/SiafundTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,26 @@

package bisq.asset.coins;

import bisq.asset.AbstractAssetWithDefaultValidatorTest;
import bisq.asset.AbstractAssetTest;

public class SiafundTest extends AbstractAssetWithDefaultValidatorTest {
public class SiafundTest extends AbstractAssetTest {

public SiafundTest() {
super(new Siafund());
}

@Override
public void testValidAddresses() {
assertValidAddress("949f35966a9b5f329f7419f91a02301b71b9f776568b2c767842af22b408eb8662203a02ec53");
assertValidAddress("4daae3005456559972f4902217ee8394a890e2afede6f0b49015e5cfaecdcb13f466f5543346");
assertValidAddress("da4f7fdc0fa047851a9860b09bc9b1e7424333c977e53a5d8aad74f5843a20b7cfa77a7794ae");

}

@Override
public void testInvalidAddresses() {
assertInvalidAddress("MxmFPEPzF19JFPU3VPrRXvUbPjMQXnQerY");
assertInvalidAddress("N22FRU9f3fx7Hty641D5cg95kRK6S3sbf3");
assertInvalidAddress("MxmFPEPzF19JFPU3VPrRXvUbPjMQXnQerY");
}
}
18 changes: 16 additions & 2 deletions assets/src/test/java/bisq/asset/coins/UnobtaniumTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

@Override
public void testValidAddresses() {
assertValidAddress("uXN2S9Soj4dSL7fPAuQi9twdaFmtwYndVP");
assertValidAddress("uZymbhuxhfvxzc5EDdqRWrrZKvabZibBu1");
assertValidAddress("uKdudT6DwojHYsBE9JWM43hRV28Rmp1Zm1");
}

@Override
public void testInvalidAddresses() {
assertInvalidAddress("aHu897ivzmeFuLNB6956X6gyGeVNHUBRgD");
assertInvalidAddress("a1HwTdCmQV3NspP2QqCGpehoFpi8NY4Zg3");
assertInvalidAddress("aHu897ivzmeFuLNB6956X6gyGeVNHUBRgD");
}
}
18 changes: 16 additions & 2 deletions assets/src/test/java/bisq/asset/coins/ZcoinTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

@Override
public void testValidAddresses() {
assertValidAddress("aHu897ivzmeFuLNB6956X6gyGeVNHUBRgD");
assertValidAddress("a1HwTdCmQV3NspP2QqCGpehoFpi8NY4Zg3");
assertValidAddress("aHu897ivzmeFuLNB6956X6gyGeVNHUBRgD");
}

@Override
public void testInvalidAddresses() {
assertInvalidAddress("MxmFPEPzF19JFPU3VPrRXvUbPjMQXnQerY");
assertInvalidAddress("N22FRU9f3fx7Hty641D5cg95kRK6S3sbf3");
assertInvalidAddress("MxmFPEPzF19JFPU3VPrRXvUbPjMQXnQerY");
}
}