From 2b2773e666417b179cc07edc19ede4eba4aa4ab6 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 31 Jan 2018 19:39:16 +0000 Subject: [PATCH 1/2] Adding STL Token --- .../java/io/bisq/common/locale/CurrencyUtil.java | 3 ++- .../util/validation/AltCoinAddressValidator.java | 6 +++++- .../validation/AltCoinAddressValidatorTest.java | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/io/bisq/common/locale/CurrencyUtil.java b/common/src/main/java/io/bisq/common/locale/CurrencyUtil.java index 9754f33666..00a8b1f054 100644 --- a/common/src/main/java/io/bisq/common/locale/CurrencyUtil.java +++ b/common/src/main/java/io/bisq/common/locale/CurrencyUtil.java @@ -146,7 +146,8 @@ public class CurrencyUtil { result.add(new CryptoCurrency("SIB", "Sibcoin")); result.add(new CryptoCurrency("XSPEC", "Spectrecoin")); result.add(new CryptoCurrency("STEEM", "STEEM")); - result.add(new CryptoCurrency("TRC", "Terracoin")); + result.add(new CryptoCurrency("STL", "Stellite")); + result.add(new CryptoCurrency("TRC", "Terracoin")); result.add(new CryptoCurrency("MVT", "The Movement", true)); result.add(new CryptoCurrency("UNO", "Unobtanium")); diff --git a/gui/src/main/java/io/bisq/gui/util/validation/AltCoinAddressValidator.java b/gui/src/main/java/io/bisq/gui/util/validation/AltCoinAddressValidator.java index 41d0b1266c..686897fd7d 100644 --- a/gui/src/main/java/io/bisq/gui/util/validation/AltCoinAddressValidator.java +++ b/gui/src/main/java/io/bisq/gui/util/validation/AltCoinAddressValidator.java @@ -433,7 +433,11 @@ public final class AltCoinAddressValidator extends InputValidator { return regexTestFailed; else return new ValidationResult(true); - + case "STL": + if(!input.matches("^(Se)\\d[0-9A-Za-z]{94}$")) + return regexTestFailed; + else + return new ValidationResult(true); // Add new coins at the end... default: diff --git a/gui/src/test/java/io/bisq/gui/util/validation/AltCoinAddressValidatorTest.java b/gui/src/test/java/io/bisq/gui/util/validation/AltCoinAddressValidatorTest.java index 1803217686..59b6791ac8 100644 --- a/gui/src/test/java/io/bisq/gui/util/validation/AltCoinAddressValidatorTest.java +++ b/gui/src/test/java/io/bisq/gui/util/validation/AltCoinAddressValidatorTest.java @@ -568,4 +568,18 @@ public class AltCoinAddressValidatorTest { assertFalse(validator.validate("2a65Aca4D5fC5B5C859090a6c34d16413539822g").isValid); assertFalse(validator.validate("").isValid); } + + @Test + public void testSTL() { + AltCoinAddressValidator validator = new AltCoinAddressValidator(); + validator.setCurrencyCode("STL"); + + assertTrue(validator.validate("Se3x7sVdvUnMMn2KoYLyYVHMJGRoB2R3V8K3LYuHAiEXgVac7vsmFiXUC8dSpJnjXDfwytKsQJV6HFH8MjwPagTJ2Aha46RZM").isValid); + assertTrue(validator.validate("Se3F51UzpbVVnQRx2VNbcjfBoQJfeuyFF353i1jLnCZda9yVN3vy8csbYCESBvf38TFkchH1C1tMY6XHkC8L678K2vLsVZVMU").isValid); + + assertFalse(validator.validate("Se3x7svUnMMn2KoYLyYVHMJGRoB2R3V8K3LYuHAiEXgVac7vsmFiXUC8dSpJnjXDfwytKsQJV6HFH8MjwPagTJ2Aha46RZM").isValid); //Only 95 charecter, expected is 97. + assertFalse(validator.validate("SX45GjRnvqheAgCpx4nJeKRjDtS5tYawxEP1GaTj79dTEm21Dtdxex6EHyDqBpofoDqW9k9uQWtkGgbbF8kiRSZ27AksBg7G111").isValid); //Address prefix is Se and not SX and not 99 chars. + assertFalse(validator.validate("Se3F51UzpbVVnQRx2VNbcjfBoQJfeuyFF353i1jLnCZda9yVN3vy8csbYCESBvf38TFkchH1C1tMY6XHkC8L678K2vLsVZVMUII").isValid); //99 Charecters, expected is 97 + assertFalse(validator.validate("").isValid); + } } From a380381e940c29364f515a05356bf434b3c67418 Mon Sep 17 00:00:00 2001 From: Stellite <35624857+stellitecoin@users.noreply.github.com> Date: Thu, 1 Feb 2018 01:11:32 +0530 Subject: [PATCH 2/2] fix formatting --- common/src/main/java/io/bisq/common/locale/CurrencyUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/io/bisq/common/locale/CurrencyUtil.java b/common/src/main/java/io/bisq/common/locale/CurrencyUtil.java index 00a8b1f054..f446159732 100644 --- a/common/src/main/java/io/bisq/common/locale/CurrencyUtil.java +++ b/common/src/main/java/io/bisq/common/locale/CurrencyUtil.java @@ -146,8 +146,8 @@ public class CurrencyUtil { result.add(new CryptoCurrency("SIB", "Sibcoin")); result.add(new CryptoCurrency("XSPEC", "Spectrecoin")); result.add(new CryptoCurrency("STEEM", "STEEM")); - result.add(new CryptoCurrency("STL", "Stellite")); - result.add(new CryptoCurrency("TRC", "Terracoin")); + result.add(new CryptoCurrency("STL", "Stellite")); + result.add(new CryptoCurrency("TRC", "Terracoin")); result.add(new CryptoCurrency("MVT", "The Movement", true)); result.add(new CryptoCurrency("UNO", "Unobtanium"));