From 438e426a4d01bb7b84e8f9892641fcc97cac51ef Mon Sep 17 00:00:00 2001 From: Saborknight Date: Thu, 25 Jan 2018 17:10:46 +0000 Subject: [PATCH] Add BETR (Better Betting) token --- .../java/io/bisq/common/locale/CurrencyUtil.java | 1 + .../util/validation/AltCoinAddressValidator.java | 6 ++++++ .../validation/AltCoinAddressValidatorTest.java | 14 ++++++++++++++ 3 files changed, 21 insertions(+) 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 0388281b82..86ab2289d0 100644 --- a/common/src/main/java/io/bisq/common/locale/CurrencyUtil.java +++ b/common/src/main/java/io/bisq/common/locale/CurrencyUtil.java @@ -94,6 +94,7 @@ public class CurrencyUtil { result.add(new CryptoCurrency("BTC", "Bitcoin")); result.add(new CryptoCurrency("BCH", "Bitcoin Cash")); result.add(new CryptoCurrency("BCHC", "Bitcoin Clashic")); + result.add(new CryptoCurrency("BETR", "Better Betting", true)); result.add(new CryptoCurrency("BTG", "Bitcoin Gold")); result.add(new CryptoCurrency("BURST", "Burstcoin")); result.add(new CryptoCurrency("GBYTE", "Byte")); 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 93511fcee0..52dad9a71c 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 @@ -416,6 +416,12 @@ public final class AltCoinAddressValidator extends InputValidator { return regexTestFailed; else return new ValidationResult(true); + case "BETR": + // https://github.com/ethereum/web3.js/blob/master/lib/utils/utils.js#L403 + if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) + 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 bcf8247048..c695874e05 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 @@ -525,4 +525,18 @@ public class AltCoinAddressValidatorTest { assertFalse(validator.validate("XIN-FXFA-LR6Y-QZA-9V4SX").isValid); assertFalse(validator.validate("XIN-FXFA-LR6Y-QZAW-9V4S").isValid); } + + @Test + public void testBETR() { + AltCoinAddressValidator validator = new AltCoinAddressValidator(); + validator.setCurrencyCode("BETR"); + + assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); + assertTrue(validator.validate("2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); + + assertFalse(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d1641353982266").isValid); + assertFalse(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d16413539822g").isValid); + assertFalse(validator.validate("2a65Aca4D5fC5B5C859090a6c34d16413539822g").isValid); + assertFalse(validator.validate("").isValid); + } }