From ba4ac0f678f83a451cad32f0615d2525c478cf4d Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Fri, 23 Mar 2018 12:22:18 +0100 Subject: [PATCH 001/106] Move altcoin address validators to separate classes. --- .../java/bisq/core/locale/CurrencyUtil.java | 21 +++--- ...stractSpecificAltCoinAddressValidator.java | 18 +++++ .../validation/AltCoinAddressValidator.java | 72 ++++++------------- .../SpecificAltCoinAddressValidator.java | 14 ++++ .../altcoins/bch/BchAddressValidator.java | 35 +++++++++ .../altcoins/ella/EllaAddressValidator.java | 32 +++++++++ ...validation.SpecificAltCoinAddressValidator | 2 + .../AltCoinAddressValidatorTest.java | 29 -------- .../AbstractAltcoinAddressValidatorTest.java | 19 +++++ .../altcoins/bch/BchAddressValidatorTest.java | 27 +++++++ .../ella/EllaAddressValidatorTest.java | 25 +++++++ 11 files changed, 200 insertions(+), 94 deletions(-) create mode 100644 src/main/java/bisq/core/payment/validation/AbstractSpecificAltCoinAddressValidator.java create mode 100644 src/main/java/bisq/core/payment/validation/SpecificAltCoinAddressValidator.java create mode 100644 src/main/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidator.java create mode 100644 src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidator.java create mode 100644 src/main/resources/META-INF/services/bisq.core.payment.validation.SpecificAltCoinAddressValidator create mode 100644 src/test/java/bisq/core/payment/validation/altcoins/AbstractAltcoinAddressValidatorTest.java create mode 100644 src/test/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidatorTest.java create mode 100644 src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidatorTest.java diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index f2c42741..265fca5b 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -18,20 +18,12 @@ package bisq.core.locale; import bisq.common.app.DevEnv; +import bisq.core.payment.validation.SpecificAltCoinAddressValidator; +import lombok.extern.slf4j.Slf4j; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Currency; -import java.util.List; -import java.util.Locale; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; -import lombok.extern.slf4j.Slf4j; - @Slf4j public class CurrencyUtil { private static String baseCurrencyCode = "BTC"; @@ -95,13 +87,17 @@ public static List getAllSortedCryptoCurrencies() { public static List createAllSortedCryptoCurrenciesList() { final List result = new ArrayList<>(); + final ServiceLoader loader = ServiceLoader.load(SpecificAltCoinAddressValidator.class); + for (SpecificAltCoinAddressValidator validator : loader) { + result.add(new CryptoCurrency(validator.getCurrencyCode(), validator.getCurrencyName(), validator.isAsset())); + } + result.add(new CryptoCurrency("BETR", "Better Betting", true)); if (DevEnv.DAO_TRADING_ACTIVATED) result.add(new CryptoCurrency("BSQ", "Bisq Token")); if (!baseCurrencyCode.equals("BTC")) result.add(new CryptoCurrency("BTC", "Bitcoin")); - result.add(new CryptoCurrency("BCH", "Bitcoin Cash")); result.add(new CryptoCurrency("BCHC", "Bitcoin Clashic")); result.add(new CryptoCurrency("BTG", "Bitcoin Gold")); result.add(new CryptoCurrency("BURST", "Burstcoin")); @@ -118,7 +114,6 @@ public static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("ONION", "DeepOnion")); result.add(new CryptoCurrency("DOGE", "Dogecoin")); result.add(new CryptoCurrency("DMC", "DynamicCoin")); - result.add(new CryptoCurrency("ELLA", "Ellaism")); result.add(new CryptoCurrency("ESP", "Espers")); result.add(new CryptoCurrency("ETH", "Ether")); result.add(new CryptoCurrency("ETC", "Ether Classic")); diff --git a/src/main/java/bisq/core/payment/validation/AbstractSpecificAltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AbstractSpecificAltCoinAddressValidator.java new file mode 100644 index 00000000..2b755bca --- /dev/null +++ b/src/main/java/bisq/core/payment/validation/AbstractSpecificAltCoinAddressValidator.java @@ -0,0 +1,18 @@ +package bisq.core.payment.validation; + +import bisq.core.locale.Res; +import bisq.core.util.validation.InputValidator; +import org.bitcoinj.core.AddressFormatException; +import org.jetbrains.annotations.NotNull; + +public abstract class AbstractSpecificAltCoinAddressValidator implements SpecificAltCoinAddressValidator { + + protected InputValidator.ValidationResult getRegexTestFailed() { + return new InputValidator.ValidationResult(false, Res.get("validation.altcoin.wrongStructure", getCurrencyCode())); + } + + @NotNull + protected String getErrorMessage(AddressFormatException e) { + return Res.get("validation.altcoin.invalidAddress", getCurrencyCode(), e.getMessage()); + } +} diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 51b38a05..b84728f9 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -19,60 +19,37 @@ import bisq.core.app.BisqEnvironment; import bisq.core.locale.Res; -import bisq.core.payment.validation.altcoins.ByteballAddressValidator; -import bisq.core.payment.validation.altcoins.KOTOAddressValidator; -import bisq.core.payment.validation.altcoins.NxtReedSolomonValidator; -import bisq.core.payment.validation.altcoins.OctocoinAddressValidator; -import bisq.core.payment.validation.altcoins.PNCAddressValidator; -import bisq.core.payment.validation.altcoins.WMCCAddressValidator; -import bisq.core.payment.validation.altcoins.XCNAddressValidator; -import bisq.core.payment.validation.altcoins.YTNAddressValidator; -import bisq.core.payment.validation.params.ACHParams; -import bisq.core.payment.validation.params.AlcParams; -import bisq.core.payment.validation.params.CageParams; -import bisq.core.payment.validation.params.CreaParams; -import bisq.core.payment.validation.params.ICHParams; -import bisq.core.payment.validation.params.IOPParams; -import bisq.core.payment.validation.params.ODNParams; -import bisq.core.payment.validation.params.OctocoinParams; -import bisq.core.payment.validation.params.OnionParams; -import bisq.core.payment.validation.params.PARTParams; -import bisq.core.payment.validation.params.PNCParams; -import bisq.core.payment.validation.params.PhoreParams; -import bisq.core.payment.validation.params.PivxParams; -import bisq.core.payment.validation.params.SpeedCashParams; -import bisq.core.payment.validation.params.StrayaParams; -import bisq.core.payment.validation.params.TerracoinParams; -import bisq.core.payment.validation.params.WACoinsParams; -import bisq.core.payment.validation.params.WMCCParams; -import bisq.core.payment.validation.params.XspecParams; +import bisq.core.payment.validation.altcoins.*; +import bisq.core.payment.validation.params.*; import bisq.core.payment.validation.params.btc.BTGParams; import bisq.core.payment.validation.params.btc.BtcMainNetParamsForValidation; import bisq.core.util.validation.InputValidator; - -import org.libdohj.params.DashMainNetParams; -import org.libdohj.params.DashRegTestParams; -import org.libdohj.params.DashTestNet3Params; -import org.libdohj.params.DogecoinMainNetParams; -import org.libdohj.params.LitecoinMainNetParams; -import org.libdohj.params.LitecoinRegTestParams; -import org.libdohj.params.LitecoinTestNet3Params; - +import lombok.extern.slf4j.Slf4j; import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; import org.bitcoinj.core.Base58; import org.bitcoinj.params.MainNetParams; import org.bitcoinj.params.RegTestParams; import org.bitcoinj.params.TestNet3Params; - -import lombok.extern.slf4j.Slf4j; - import org.jetbrains.annotations.NotNull; +import org.libdohj.params.*; + +import java.util.HashMap; +import java.util.Map; +import java.util.ServiceLoader; @Slf4j public final class AltCoinAddressValidator extends InputValidator { private String currencyCode; + private final Map validators = new HashMap<>(); + + public AltCoinAddressValidator() { + final ServiceLoader loader = ServiceLoader.load(SpecificAltCoinAddressValidator.class); + for (SpecificAltCoinAddressValidator validator : loader) { + validators.put(validator.getCurrencyCode(), validator); + } + } /////////////////////////////////////////////////////////////////////////////////////////// // Public methods @@ -93,6 +70,10 @@ public ValidationResult validate(String input) { ValidationResult regexTestFailed = new ValidationResult(false, Res.get("validation.altcoin.wrongStructure", currencyCode)); + final SpecificAltCoinAddressValidator validator = validators.get(currencyCode); + if (null != validator) { + return validator.validate(input); + } switch (currencyCode) { case "BTC": try { @@ -314,12 +295,6 @@ public ValidationResult validate(String input) { // Unhandled Exception (probably a checksum error) return new ValidationResult(false); } - case "ELLA": - // 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); case "XCN": // https://bitcointalk.org/index.php?topic=1801595 return XCNAddressValidator.ValidateAddress(input); @@ -352,13 +327,6 @@ public ValidationResult validate(String input) { return new ValidationResult(true); else return regexTestFailed; - case "BCH": - try { - Address.fromBase58(BtcMainNetParamsForValidation.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } case "BCHC": try { Address.fromBase58(BtcMainNetParamsForValidation.get(), input); diff --git a/src/main/java/bisq/core/payment/validation/SpecificAltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/SpecificAltCoinAddressValidator.java new file mode 100644 index 00000000..fea040f7 --- /dev/null +++ b/src/main/java/bisq/core/payment/validation/SpecificAltCoinAddressValidator.java @@ -0,0 +1,14 @@ +package bisq.core.payment.validation; + +import bisq.core.util.validation.InputValidator; + +public interface SpecificAltCoinAddressValidator { + + String getCurrencyCode(); + + String getCurrencyName(); + + boolean isAsset(); + + InputValidator.ValidationResult validate(String input); +} diff --git a/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidator.java b/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidator.java new file mode 100644 index 00000000..35babdb6 --- /dev/null +++ b/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidator.java @@ -0,0 +1,35 @@ +package bisq.core.payment.validation.altcoins.bch; + +import bisq.core.payment.validation.AbstractSpecificAltCoinAddressValidator; +import bisq.core.payment.validation.params.btc.BtcMainNetParamsForValidation; +import bisq.core.util.validation.InputValidator; +import org.bitcoinj.core.Address; +import org.bitcoinj.core.AddressFormatException; + +public class BchAddressValidator extends AbstractSpecificAltCoinAddressValidator { + + @Override + public String getCurrencyCode() { + return "BCH"; + } + + @Override + public String getCurrencyName() { + return "Bitcoin Cash"; + } + + @Override + public boolean isAsset() { + return false; + } + + @Override + public InputValidator.ValidationResult validate(String input) { + try { + Address.fromBase58(BtcMainNetParamsForValidation.get(), input); + return new InputValidator.ValidationResult(true); + } catch (AddressFormatException e) { + return new InputValidator.ValidationResult(false, getErrorMessage(e)); + } + } +} diff --git a/src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidator.java b/src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidator.java new file mode 100644 index 00000000..01841064 --- /dev/null +++ b/src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidator.java @@ -0,0 +1,32 @@ +package bisq.core.payment.validation.altcoins.ella; + +import bisq.core.payment.validation.AbstractSpecificAltCoinAddressValidator; +import bisq.core.util.validation.InputValidator; + +public class EllaAddressValidator extends AbstractSpecificAltCoinAddressValidator { + + @Override + public String getCurrencyCode() { + return "ELLA"; + } + + @Override + public String getCurrencyName() { + return "Ellaism"; + } + + @Override + public boolean isAsset() { + return false; + } + + @Override + public InputValidator.ValidationResult validate(String input) { + // https://github.com/ethereum/web3.js/blob/master/lib/utils/utils.js#L403 + if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) { + return getRegexTestFailed(); + } else { + return new InputValidator.ValidationResult(true); + } + } +} diff --git a/src/main/resources/META-INF/services/bisq.core.payment.validation.SpecificAltCoinAddressValidator b/src/main/resources/META-INF/services/bisq.core.payment.validation.SpecificAltCoinAddressValidator new file mode 100644 index 00000000..1f9acb20 --- /dev/null +++ b/src/main/resources/META-INF/services/bisq.core.payment.validation.SpecificAltCoinAddressValidator @@ -0,0 +1,2 @@ +bisq.core.payment.validation.altcoins.bch.BchAddressValidator +bisq.core.payment.validation.altcoins.ella.EllaAddressValidator diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 697af326..1db0fbec 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -271,20 +271,6 @@ public void testZEN() { assertFalse(validator.validate("").isValid); } - @Test - public void testELLA() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); - validator.setCurrencyCode("ELLA"); - - assertTrue(validator.validate("0x65767ec6d4d3d18a200842352485cdc37cbf3a21").isValid); - assertTrue(validator.validate("65767ec6d4d3d18a200842352485cdc37cbf3a21").isValid); - - assertFalse(validator.validate("0x65767ec6d4d3d18a200842352485cdc37cbf3a216").isValid); - assertFalse(validator.validate("0x65767ec6d4d3d18a200842352485cdc37cbf3a2g").isValid); - assertFalse(validator.validate("65767ec6d4d3d18a200842352485cdc37cbf3a2g").isValid); - assertFalse(validator.validate("").isValid); - } - @Test public void testXCN() { AltCoinAddressValidator validator = new AltCoinAddressValidator(); @@ -369,21 +355,6 @@ public void testMDC() { assertFalse(validator.validate("").isValid); } - @Test - public void testBCH() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); - validator.setCurrencyCode("BCH"); - - assertTrue(validator.validate("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSH").isValid); - assertTrue(validator.validate("1MEbUJ5v5MdDEqFJGz4SZp58KkaLdmXZ85").isValid); - assertTrue(validator.validate("34dvotXMg5Gxc37TBVV2e5GUAfCFu7Ms4g").isValid); - - assertFalse(validator.validate("21HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSHa").isValid); - assertFalse(validator.validate("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSHs").isValid); - assertFalse(validator.validate("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSH#").isValid); - assertFalse(validator.validate("").isValid); - } - @Test public void testBCHC() { AltCoinAddressValidator validator = new AltCoinAddressValidator(); diff --git a/src/test/java/bisq/core/payment/validation/altcoins/AbstractAltcoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/altcoins/AbstractAltcoinAddressValidatorTest.java new file mode 100644 index 00000000..56a8dfff --- /dev/null +++ b/src/test/java/bisq/core/payment/validation/altcoins/AbstractAltcoinAddressValidatorTest.java @@ -0,0 +1,19 @@ +package bisq.core.payment.validation.altcoins; + +import bisq.core.app.BisqEnvironment; +import bisq.core.btc.BaseCurrencyNetwork; +import bisq.core.locale.CurrencyUtil; +import bisq.core.locale.Res; +import org.junit.Before; + +public abstract class AbstractAltcoinAddressValidatorTest { + + @Before + public void setup() { + final BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork(); + final String currencyCode = baseCurrencyNetwork.getCurrencyCode(); + Res.setBaseCurrencyCode(currencyCode); + Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName()); + CurrencyUtil.setBaseCurrencyCode(currencyCode); + } +} diff --git a/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidatorTest.java new file mode 100644 index 00000000..15304423 --- /dev/null +++ b/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidatorTest.java @@ -0,0 +1,27 @@ +package bisq.core.payment.validation.altcoins.bch; + +import bisq.core.payment.validation.altcoins.AbstractAltcoinAddressValidatorTest; +import bisq.core.payment.validation.AltCoinAddressValidator; +import org.junit.Test; + +import static junit.framework.TestCase.assertFalse; +import static org.junit.Assert.assertTrue; + +public class BchAddressValidatorTest extends AbstractAltcoinAddressValidatorTest { + + @Test + public void testBCH() { + AltCoinAddressValidator validator = new AltCoinAddressValidator(); + validator.setCurrencyCode("BCH"); + + assertTrue(validator.validate("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSH").isValid); + assertTrue(validator.validate("1MEbUJ5v5MdDEqFJGz4SZp58KkaLdmXZ85").isValid); + assertTrue(validator.validate("34dvotXMg5Gxc37TBVV2e5GUAfCFu7Ms4g").isValid); + + assertFalse(validator.validate("21HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSHa").isValid); + assertFalse(validator.validate("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSHs").isValid); + assertFalse(validator.validate("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSH#").isValid); + assertFalse(validator.validate("").isValid); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidatorTest.java new file mode 100644 index 00000000..de8a578b --- /dev/null +++ b/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidatorTest.java @@ -0,0 +1,25 @@ +package bisq.core.payment.validation.altcoins.ella; + +import bisq.core.payment.validation.altcoins.AbstractAltcoinAddressValidatorTest; +import bisq.core.payment.validation.AltCoinAddressValidator; +import org.junit.Test; + +import static junit.framework.TestCase.assertFalse; +import static org.junit.Assert.assertTrue; + +public class EllaAddressValidatorTest extends AbstractAltcoinAddressValidatorTest { + + @Test + public void testELLA() { + AltCoinAddressValidator validator = new AltCoinAddressValidator(); + validator.setCurrencyCode("ELLA"); + + assertTrue(validator.validate("0x65767ec6d4d3d18a200842352485cdc37cbf3a21").isValid); + assertTrue(validator.validate("65767ec6d4d3d18a200842352485cdc37cbf3a21").isValid); + + assertFalse(validator.validate("0x65767ec6d4d3d18a200842352485cdc37cbf3a216").isValid); + assertFalse(validator.validate("0x65767ec6d4d3d18a200842352485cdc37cbf3a2g").isValid); + assertFalse(validator.validate("65767ec6d4d3d18a200842352485cdc37cbf3a2g").isValid); + assertFalse(validator.validate("").isValid); + } +} From 856669aadba4e2a65136491df9e1b0bfd96dddb0 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Fri, 23 Mar 2018 13:49:41 +0100 Subject: [PATCH 002/106] AssetProvider --- src/main/java/bisq/core/locale/CurrencyUtil.java | 6 +++--- ...ddressValidator.java => AbstractAssetProvider.java} | 2 +- .../payment/validation/AltCoinAddressValidator.java | 10 +++++----- ...AltCoinAddressValidator.java => AssetProvider.java} | 4 ++-- .../validation/altcoins/bch/BchAddressValidator.java | 6 +++--- .../validation/altcoins/ella/EllaAddressValidator.java | 6 +++--- ...ator => bisq.core.payment.validation.AssetProvider} | 0 7 files changed, 17 insertions(+), 17 deletions(-) rename src/main/java/bisq/core/payment/validation/{AbstractSpecificAltCoinAddressValidator.java => AbstractAssetProvider.java} (84%) rename src/main/java/bisq/core/payment/validation/{SpecificAltCoinAddressValidator.java => AssetProvider.java} (61%) rename src/main/resources/META-INF/services/{bisq.core.payment.validation.SpecificAltCoinAddressValidator => bisq.core.payment.validation.AssetProvider} (100%) diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 265fca5b..8b003a3f 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -18,7 +18,7 @@ package bisq.core.locale; import bisq.common.app.DevEnv; -import bisq.core.payment.validation.SpecificAltCoinAddressValidator; +import bisq.core.payment.validation.AssetProvider; import lombok.extern.slf4j.Slf4j; import java.util.*; @@ -87,8 +87,8 @@ public static List getAllSortedCryptoCurrencies() { public static List createAllSortedCryptoCurrenciesList() { final List result = new ArrayList<>(); - final ServiceLoader loader = ServiceLoader.load(SpecificAltCoinAddressValidator.class); - for (SpecificAltCoinAddressValidator validator : loader) { + final ServiceLoader loader = ServiceLoader.load(AssetProvider.class); + for (AssetProvider validator : loader) { result.add(new CryptoCurrency(validator.getCurrencyCode(), validator.getCurrencyName(), validator.isAsset())); } diff --git a/src/main/java/bisq/core/payment/validation/AbstractSpecificAltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AbstractAssetProvider.java similarity index 84% rename from src/main/java/bisq/core/payment/validation/AbstractSpecificAltCoinAddressValidator.java rename to src/main/java/bisq/core/payment/validation/AbstractAssetProvider.java index 2b755bca..43272d77 100644 --- a/src/main/java/bisq/core/payment/validation/AbstractSpecificAltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AbstractAssetProvider.java @@ -5,7 +5,7 @@ import org.bitcoinj.core.AddressFormatException; import org.jetbrains.annotations.NotNull; -public abstract class AbstractSpecificAltCoinAddressValidator implements SpecificAltCoinAddressValidator { +public abstract class AbstractAssetProvider implements AssetProvider { protected InputValidator.ValidationResult getRegexTestFailed() { return new InputValidator.ValidationResult(false, Res.get("validation.altcoin.wrongStructure", getCurrencyCode())); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index b84728f9..2fd98a51 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -42,11 +42,11 @@ public final class AltCoinAddressValidator extends InputValidator { private String currencyCode; - private final Map validators = new HashMap<>(); + private final Map validators = new HashMap<>(); public AltCoinAddressValidator() { - final ServiceLoader loader = ServiceLoader.load(SpecificAltCoinAddressValidator.class); - for (SpecificAltCoinAddressValidator validator : loader) { + final ServiceLoader loader = ServiceLoader.load(AssetProvider.class); + for (AssetProvider validator : loader) { validators.put(validator.getCurrencyCode(), validator); } } @@ -70,9 +70,9 @@ public ValidationResult validate(String input) { ValidationResult regexTestFailed = new ValidationResult(false, Res.get("validation.altcoin.wrongStructure", currencyCode)); - final SpecificAltCoinAddressValidator validator = validators.get(currencyCode); + final AssetProvider validator = validators.get(currencyCode); if (null != validator) { - return validator.validate(input); + return validator.validateAddress(input); } switch (currencyCode) { case "BTC": diff --git a/src/main/java/bisq/core/payment/validation/SpecificAltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AssetProvider.java similarity index 61% rename from src/main/java/bisq/core/payment/validation/SpecificAltCoinAddressValidator.java rename to src/main/java/bisq/core/payment/validation/AssetProvider.java index fea040f7..ba26d2a8 100644 --- a/src/main/java/bisq/core/payment/validation/SpecificAltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AssetProvider.java @@ -2,7 +2,7 @@ import bisq.core.util.validation.InputValidator; -public interface SpecificAltCoinAddressValidator { +public interface AssetProvider { String getCurrencyCode(); @@ -10,5 +10,5 @@ public interface SpecificAltCoinAddressValidator { boolean isAsset(); - InputValidator.ValidationResult validate(String input); + InputValidator.ValidationResult validateAddress(String input); } diff --git a/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidator.java b/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidator.java index 35babdb6..eb9064c6 100644 --- a/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidator.java @@ -1,12 +1,12 @@ package bisq.core.payment.validation.altcoins.bch; -import bisq.core.payment.validation.AbstractSpecificAltCoinAddressValidator; +import bisq.core.payment.validation.AbstractAssetProvider; import bisq.core.payment.validation.params.btc.BtcMainNetParamsForValidation; import bisq.core.util.validation.InputValidator; import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; -public class BchAddressValidator extends AbstractSpecificAltCoinAddressValidator { +public class BchAddressValidator extends AbstractAssetProvider { @Override public String getCurrencyCode() { @@ -24,7 +24,7 @@ public boolean isAsset() { } @Override - public InputValidator.ValidationResult validate(String input) { + public InputValidator.ValidationResult validateAddress(String input) { try { Address.fromBase58(BtcMainNetParamsForValidation.get(), input); return new InputValidator.ValidationResult(true); diff --git a/src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidator.java b/src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidator.java index 01841064..3ab0edbd 100644 --- a/src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidator.java @@ -1,9 +1,9 @@ package bisq.core.payment.validation.altcoins.ella; -import bisq.core.payment.validation.AbstractSpecificAltCoinAddressValidator; +import bisq.core.payment.validation.AbstractAssetProvider; import bisq.core.util.validation.InputValidator; -public class EllaAddressValidator extends AbstractSpecificAltCoinAddressValidator { +public class EllaAddressValidator extends AbstractAssetProvider { @Override public String getCurrencyCode() { @@ -21,7 +21,7 @@ public boolean isAsset() { } @Override - public InputValidator.ValidationResult validate(String input) { + public InputValidator.ValidationResult validateAddress(String input) { // https://github.com/ethereum/web3.js/blob/master/lib/utils/utils.js#L403 if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) { return getRegexTestFailed(); diff --git a/src/main/resources/META-INF/services/bisq.core.payment.validation.SpecificAltCoinAddressValidator b/src/main/resources/META-INF/services/bisq.core.payment.validation.AssetProvider similarity index 100% rename from src/main/resources/META-INF/services/bisq.core.payment.validation.SpecificAltCoinAddressValidator rename to src/main/resources/META-INF/services/bisq.core.payment.validation.AssetProvider From cb6c5797f95a85d615bb8f6e68c3cac207747db8 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Fri, 23 Mar 2018 15:03:06 +0100 Subject: [PATCH 003/106] AssetProviderRegistry --- .../java/bisq/core/locale/CurrencyUtil.java | 13 +- .../java/bisq/core/payment/PaymentModule.java | 34 +++++ .../validation/AltCoinAddressValidator.java | 21 ++- .../validation/AssetProviderRegistry.java | 55 ++++++++ .../AbstractAltcoinAddressValidatorTest.java | 8 +- .../AltCoinAddressValidatorTest.java | 129 ++++++++---------- .../altcoins/bch/BchAddressValidatorTest.java | 4 +- .../ella/EllaAddressValidatorTest.java | 5 +- 8 files changed, 172 insertions(+), 97 deletions(-) create mode 100644 src/main/java/bisq/core/payment/PaymentModule.java create mode 100644 src/main/java/bisq/core/payment/validation/AssetProviderRegistry.java rename src/test/java/bisq/core/payment/validation/{altcoins => }/AbstractAltcoinAddressValidatorTest.java (71%) diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 8b003a3f..cbfed745 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -18,7 +18,7 @@ package bisq.core.locale; import bisq.common.app.DevEnv; -import bisq.core.payment.validation.AssetProvider; +import bisq.core.payment.validation.AssetProviderRegistry; import lombok.extern.slf4j.Slf4j; import java.util.*; @@ -85,12 +85,11 @@ public static List getAllSortedCryptoCurrencies() { // Don't make a PR for adding a coin but follow the steps described here: // https://forum.bisq.network/t/how-to-add-your-favorite-altcoin/ public static List createAllSortedCryptoCurrenciesList() { - final List result = new ArrayList<>(); - - final ServiceLoader loader = ServiceLoader.load(AssetProvider.class); - for (AssetProvider validator : loader) { - result.add(new CryptoCurrency(validator.getCurrencyCode(), validator.getCurrencyName(), validator.isAsset())); - } + final List result = AssetProviderRegistry.getInstance() + .getProviders() + .stream() + .map(assetProvider -> new CryptoCurrency(assetProvider.getCurrencyCode(), assetProvider.getCurrencyName(), assetProvider.isAsset())) + .collect(Collectors.toList()); result.add(new CryptoCurrency("BETR", "Better Betting", true)); if (DevEnv.DAO_TRADING_ACTIVATED) diff --git a/src/main/java/bisq/core/payment/PaymentModule.java b/src/main/java/bisq/core/payment/PaymentModule.java new file mode 100644 index 00000000..0efdd6e6 --- /dev/null +++ b/src/main/java/bisq/core/payment/PaymentModule.java @@ -0,0 +1,34 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.core.payment; + +import bisq.common.app.AppModule; +import bisq.core.payment.validation.AssetProviderRegistry; +import org.springframework.core.env.Environment; + +public class PaymentModule extends AppModule { + + public PaymentModule(Environment environment) { + super(environment); + } + + @Override + protected final void configure() { + bind(AssetProviderRegistry.class).toInstance(AssetProviderRegistry.getInstance()); + } +} diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 2fd98a51..1f3d2ed9 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -24,6 +24,7 @@ import bisq.core.payment.validation.params.btc.BTGParams; import bisq.core.payment.validation.params.btc.BtcMainNetParamsForValidation; import bisq.core.util.validation.InputValidator; +import com.google.inject.Inject; import lombok.extern.slf4j.Slf4j; import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; @@ -34,21 +35,15 @@ import org.jetbrains.annotations.NotNull; import org.libdohj.params.*; -import java.util.HashMap; -import java.util.Map; -import java.util.ServiceLoader; - @Slf4j public final class AltCoinAddressValidator extends InputValidator { + private final AssetProviderRegistry assetProviderRegistry; private String currencyCode; - private final Map validators = new HashMap<>(); - public AltCoinAddressValidator() { - final ServiceLoader loader = ServiceLoader.load(AssetProvider.class); - for (AssetProvider validator : loader) { - validators.put(validator.getCurrencyCode(), validator); - } + @Inject + public AltCoinAddressValidator(AssetProviderRegistry assetProviderRegistry) { + this.assetProviderRegistry = assetProviderRegistry; } /////////////////////////////////////////////////////////////////////////////////////////// @@ -70,9 +65,9 @@ public ValidationResult validate(String input) { ValidationResult regexTestFailed = new ValidationResult(false, Res.get("validation.altcoin.wrongStructure", currencyCode)); - final AssetProvider validator = validators.get(currencyCode); - if (null != validator) { - return validator.validateAddress(input); + final AssetProvider assetProvider = assetProviderRegistry.getProviderByCurrencyCode(currencyCode); + if (null != assetProvider) { + return assetProvider.validateAddress(input); } switch (currencyCode) { case "BTC": diff --git a/src/main/java/bisq/core/payment/validation/AssetProviderRegistry.java b/src/main/java/bisq/core/payment/validation/AssetProviderRegistry.java new file mode 100644 index 00000000..51cf7a06 --- /dev/null +++ b/src/main/java/bisq/core/payment/validation/AssetProviderRegistry.java @@ -0,0 +1,55 @@ +package bisq.core.payment.validation; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.*; + +public final class AssetProviderRegistry { + + private Map providers; + + private static AssetProviderRegistry instance; + + public static AssetProviderRegistry getInstance() { + if (null == instance) { + instance = new AssetProviderRegistry(); + } + return instance; + } + + private AssetProviderRegistry() { + } + + @Nullable + public AssetProvider getProviderByCurrencyCode(String code) { + return getProvidersMap().get(code); + } + + @Nonnull + public Collection getProviders() { + return Collections.unmodifiableCollection(getProvidersMap().values()); + } + + @Nonnull + private Map getProvidersMap() { + if (null == providers) { + initProviders(); + } + return providers; + } + + private void initProviders() { + providers = new HashMap<>(); + for (AssetProvider provider : ServiceLoader.load(AssetProvider.class)) { + String currencyCode = provider.getCurrencyCode(); + AssetProvider existingProvider = providers.get(currencyCode); + if (null != existingProvider) { + final String providerClassName = provider.getClass().getCanonicalName(); + final String existingProviderClassName = existingProvider.getClass().getCanonicalName(); + String message = String.format("AssetProvider %s wants to register itself for asset %s which is already registered with %s", providerClassName, currencyCode, existingProviderClassName); + throw new RuntimeException(message); + } + providers.put(currencyCode, provider); + } + } +} diff --git a/src/test/java/bisq/core/payment/validation/altcoins/AbstractAltcoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AbstractAltcoinAddressValidatorTest.java similarity index 71% rename from src/test/java/bisq/core/payment/validation/altcoins/AbstractAltcoinAddressValidatorTest.java rename to src/test/java/bisq/core/payment/validation/AbstractAltcoinAddressValidatorTest.java index 56a8dfff..cb1a495b 100644 --- a/src/test/java/bisq/core/payment/validation/altcoins/AbstractAltcoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AbstractAltcoinAddressValidatorTest.java @@ -1,9 +1,10 @@ -package bisq.core.payment.validation.altcoins; +package bisq.core.payment.validation; import bisq.core.app.BisqEnvironment; import bisq.core.btc.BaseCurrencyNetwork; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; +import org.jetbrains.annotations.NotNull; import org.junit.Before; public abstract class AbstractAltcoinAddressValidatorTest { @@ -16,4 +17,9 @@ public void setup() { Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName()); CurrencyUtil.setBaseCurrencyCode(currencyCode); } + + @NotNull + protected AltCoinAddressValidator getAltCoinAddressValidator() { + return new AltCoinAddressValidator(AssetProviderRegistry.getInstance()); + } } diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 1db0fbec..07d4be2a 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -17,31 +17,16 @@ package bisq.core.payment.validation; -import bisq.core.app.BisqEnvironment; -import bisq.core.btc.BaseCurrencyNetwork; -import bisq.core.locale.CurrencyUtil; -import bisq.core.locale.Res; - -import org.junit.Before; import org.junit.Test; import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertTrue; -public class AltCoinAddressValidatorTest { - - @Before - public void setup() { - final BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork(); - final String currencyCode = baseCurrencyNetwork.getCurrencyCode(); - Res.setBaseCurrencyCode(currencyCode); - Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName()); - CurrencyUtil.setBaseCurrencyCode(currencyCode); - } +public class AltCoinAddressValidatorTest extends AbstractAltcoinAddressValidatorTest { @Test public void testBTC() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("BTC"); assertTrue(validator.validate("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem").isValid); @@ -57,7 +42,7 @@ public void testBTC() { @Test public void testBSQ() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("BSQ"); assertTrue(validator.validate("B17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem").isValid); @@ -73,7 +58,7 @@ public void testBSQ() { @Test public void testLTC() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("LTC"); assertTrue(validator.validate("Lg3PX8wRWmApFCoCMAsPF5P9dPHYQHEWKW").isValid); @@ -88,7 +73,7 @@ public void testLTC() { @Test public void testDOGE() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("DOGE"); assertTrue(validator.validate("DEa7damK8MsbdCJztidBasZKVsDLJifWfE").isValid); @@ -103,7 +88,7 @@ public void testDOGE() { @Test public void testDASH() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("DASH"); assertTrue(validator.validate("XjNms118hx6dGyBqsrVMTbzMUmxDVijk7Y").isValid); @@ -118,7 +103,7 @@ public void testDASH() { @Test public void testETH() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ETH"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -132,7 +117,7 @@ public void testETH() { @Test public void testPIVX() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("PIVX"); assertTrue(validator.validate("DFJku78A14HYwPSzC5PtUmda7jMr5pbD2B").isValid); @@ -148,7 +133,7 @@ public void testPIVX() { @Test public void testIOP() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("IOP"); assertTrue(validator.validate("pKbz7iRUSiUaTgh4UuwQCnc6pWZnyCGWxM").isValid); @@ -160,7 +145,7 @@ public void testIOP() { @Test public void test888() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("888"); assertTrue(validator.validate("8TP9rh3SH6n9cSLmV22vnSNNw56LKGpLra").isValid); @@ -175,7 +160,7 @@ public void test888() { @Test public void testGBYTE() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("GBYTE"); assertTrue(validator.validate("BN7JXKXWEG4BVJ7NW6Q3Z7SMJNZJYM3G").isValid); @@ -189,7 +174,7 @@ public void testGBYTE() { @Test public void testNXT() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("NXT"); assertTrue(validator.validate("NXT-JM2U-U4AE-G7WF-3NP9F").isValid); @@ -207,7 +192,7 @@ public void testNXT() { // Added at 0.6.0 @Test public void testDCT() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("DCT"); assertTrue(validator.validate("ud6910c2790bda53bcc53cb131f8fa3bf").isValid); @@ -225,7 +210,7 @@ public void testDCT() { @Test public void testPNC() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("PNC"); assertTrue(validator.validate("3AB1qXhaU3hK5oAPQfwzN3QkM8LxAgL8vB").isValid); @@ -240,7 +225,7 @@ public void testPNC() { @Test public void testWAC() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("WAC"); assertTrue(validator.validate("WfEnB3VGrBqW7uamJMymymEwxMBYQKELKY").isValid); @@ -256,7 +241,7 @@ public void testWAC() { @Test public void testZEN() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ZEN"); assertTrue(validator.validate("znk62Ey7ptTyHgYLaLDTEwhLF6uN1DXTBfa").isValid); @@ -273,7 +258,7 @@ public void testZEN() { @Test public void testXCN() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("XCN"); assertTrue(validator.validate("CT49DTNo5itqYoAD6XTGyTKbe8z5nGY2D5").isValid); @@ -294,7 +279,7 @@ public void testXCN() { @Test public void testTRC() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("TRC"); assertTrue(validator.validate("1Bys8pZaKo4GTWcpArMg92cBgYqij8mKXt").isValid); @@ -313,7 +298,7 @@ public void testTRC() { @Test public void testINXT() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("INXT"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -327,7 +312,7 @@ public void testINXT() { @Test public void testPART() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("PART"); assertTrue(validator.validate("PZdYWHgyhuG7NHVCzEkkx3dcLKurTpvmo6").isValid); assertTrue(validator.validate("RJAPhgckEgRGVPZa9WoGSWW24spskSfLTQ").isValid); @@ -343,7 +328,7 @@ public void testPART() { // Added 0.6.1 @Test public void testMDC() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("MDC"); assertTrue(validator.validate("mHUisRLQ4vMXrWrVfGfiEHuD3KZqiUNvzH").isValid); @@ -357,7 +342,7 @@ public void testMDC() { @Test public void testBCHC() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("BCHC"); assertTrue(validator.validate("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSH").isValid); @@ -372,7 +357,7 @@ public void testBCHC() { @Test public void testBTG() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("BTG"); assertTrue(validator.validate("AehvQ57Fp168uY592LCUYBbyNEpiRAPufb").isValid); @@ -388,7 +373,7 @@ public void testBTG() { // Added 0.6.2 @Test public void testCAGE() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("CAGE"); assertTrue(validator.validate("Db97PgfdBDhXk8DmrDhrUPyydTCELn8YSb").isValid); @@ -404,7 +389,7 @@ public void testCAGE() { @Test public void testCRED() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("CRED"); assertTrue(validator.validate("0x65767ec6d4d3d18a200842352485cdc37cbf3a21").isValid); @@ -418,7 +403,7 @@ public void testCRED() { @Test public void testXSPEC() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("XSPEC"); assertTrue(validator.validate("SUZRHjTLSCr581qLsGqMqBD5f3oW2JHckn").isValid); @@ -434,7 +419,7 @@ public void testXSPEC() { // Added 0.6.3 @Test public void testWILD() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("WILD"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -448,7 +433,7 @@ public void testWILD() { @Test public void testONION() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ONION"); assertTrue(validator.validate("DbkkqXwdiWJNcpfw49f2xzTVEbvL1SYWDm").isValid); @@ -464,7 +449,7 @@ public void testONION() { // Added 0.6.4 @Test public void testCREA() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("CREA"); assertTrue(validator.validate("CGjh99QdHxCE6g9pGUucCJNeUyQPRJr4fE").isValid); @@ -479,7 +464,7 @@ public void testCREA() { @Test public void testXIN() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("XIN"); assertTrue(validator.validate("XIN-FXFA-LR6Y-QZAW-9V4SX").isValid); @@ -502,7 +487,7 @@ public void testXIN() { // Added 0.6.5 @Test public void testBETR() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("BETR"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -516,7 +501,7 @@ public void testBETR() { @Test public void testMVT() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("MVT"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -530,7 +515,7 @@ public void testMVT() { @Test public void testREF() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("REF"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -545,7 +530,7 @@ public void testREF() { // Added 0.6.6 @Test public void testSTL() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("STL"); assertTrue(validator.validate("Se3x7sVdvUnMMn2KoYLyYVHMJGRoB2R3V8K3LYuHAiEXgVac7vsmFiXUC8dSpJnjXDfwytKsQJV6HFH8MjwPagTJ2Aha46RZM").isValid); @@ -559,7 +544,7 @@ public void testSTL() { @Test public void testDAI() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("DAI"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -573,7 +558,7 @@ public void testDAI() { @Test public void testYTN() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("YTN"); assertTrue(validator.validate("YTgSv7bk5x5p6te3uf3HbUwgnf7zEJM4Jn").isValid); assertTrue(validator.validate("YVz19KtQUfyTP4AJS8sbRBqi7dkGTL2ovd").isValid); @@ -589,7 +574,7 @@ public void testYTN() { @Test public void testDARX() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("DARX"); assertTrue(validator.validate("RN8spHmkV6ZtRsquaTJMRZJujRQkkDNh2G").isValid); @@ -603,7 +588,7 @@ public void testDARX() { @Test public void testODN() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ODN"); assertTrue(validator.validate("XEfyuzk8yTp5eA9eVUeCW2PFbCFtNb6Jgv").isValid); @@ -619,7 +604,7 @@ public void testODN() { @Test public void testCDT() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("CDT"); assertTrue(validator.validate("DM7BjopQ3bGYxSPZ4yhfttxqnDrEkyc3sw").isValid); @@ -637,7 +622,7 @@ public void testCDT() { @Test public void testDGM() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("DGM"); assertTrue(validator.validate("DvaAgcLKrno2AC7kYhHVDCrkhx2xHFpXUf").isValid); @@ -651,7 +636,7 @@ public void testDGM() { @Test public void testSCS() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("SCS"); assertTrue(validator.validate("SNrVzPaFVCQGH4Rdch2EuhoyeWMfgWqk1J").isValid); @@ -667,7 +652,7 @@ public void testSCS() { @Test public void testSOS() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("SOS"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -681,7 +666,7 @@ public void testSOS() { @Test public void testACH() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ACH"); assertTrue(validator.validate("AciV7ZyJDpCg7kGGmbo97VjgjpVZkXRTMD").isValid); @@ -696,7 +681,7 @@ public void testACH() { @Test public void testVDN() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("VDN"); assertTrue(validator.validate("DG1KpSsSXd3uitgwHaA1i6T1Bj1hWEwAxB").isValid); @@ -715,7 +700,7 @@ public void testVDN() { // Added 0.7.0 @Test public void testALC() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ALC"); assertTrue(validator.validate("AQJTNtWcP7opxuR52Lf5vmoQTC8EHQ6GxV").isValid); @@ -731,7 +716,7 @@ public void testALC() { @Test public void testDIN() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("DIN"); assertTrue(validator.validate("DBmvak2TM8GpeiR3ZEVWAHWFZeiw9FG7jK").isValid); @@ -747,7 +732,7 @@ public void testDIN() { @Test public void testStraya() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("NAH"); assertTrue(validator.validate("SZHa3vS9ctDJwx3BziaqgN3zQMkYpgyP7f").isValid); @@ -763,7 +748,7 @@ public void testStraya() { @Test public void testROI() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ROI"); assertTrue(validator.validate("RSdzB2mFpQ6cR3HmEopbaRBjrEMWAwXBYn").isValid); @@ -778,7 +763,7 @@ public void testROI() { @Test public void testWMCC() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("WMCC"); assertTrue(validator.validate("wc1qke2es507uz0dcfx7eyvlfuemwys8xem48vp5rw").isValid); @@ -797,7 +782,7 @@ public void testWMCC() { @Test public void testRTO() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("RTO"); assertTrue(validator.validate("AHT1tiauD1GKvLnSL2RVuug1arn3cvFYw7PX5cUmCkM9MHuBn8yrGoHGHXP8ZV9FUR5Y5ntvhanwCMp8FK5bmLrqKxq7BRj").isValid); @@ -811,7 +796,7 @@ public void testRTO() { @Test public void testKOTO() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("KOTO"); assertTrue(validator.validate("k13dNgJJjf1SCU2Xv2jLnuUb5Q7zZx7P9vW").isValid); @@ -828,7 +813,7 @@ public void testKOTO() { @Test public void testUBQ() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("UBQ"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -842,7 +827,7 @@ public void testUBQ() { @Test public void testQWARK() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("QWARK"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -856,7 +841,7 @@ public void testQWARK() { @Test public void testGEO() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("GEO"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -870,7 +855,7 @@ public void testGEO() { @Test public void testGRANS() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("GRANS"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -884,7 +869,7 @@ public void testGRANS() { @Test public void testICH() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ICH"); assertTrue(validator.validate("AYx4EqKhomeMu2CTMx1AHdNMkjv6ygnvji").isValid); @@ -903,7 +888,7 @@ public void testICH() { @Test public void testPHR() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("PHR"); assertTrue(validator.validate("PJCKDPyvfbf1yV7mYNeJ8Zb47hKRwVPYDj").isValid); diff --git a/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidatorTest.java index 15304423..f8bab797 100644 --- a/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidatorTest.java @@ -1,7 +1,7 @@ package bisq.core.payment.validation.altcoins.bch; -import bisq.core.payment.validation.altcoins.AbstractAltcoinAddressValidatorTest; import bisq.core.payment.validation.AltCoinAddressValidator; +import bisq.core.payment.validation.AbstractAltcoinAddressValidatorTest; import org.junit.Test; import static junit.framework.TestCase.assertFalse; @@ -11,7 +11,7 @@ public class BchAddressValidatorTest extends AbstractAltcoinAddressValidatorTest @Test public void testBCH() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("BCH"); assertTrue(validator.validate("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSH").isValid); diff --git a/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidatorTest.java index de8a578b..88719ab3 100644 --- a/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidatorTest.java @@ -1,6 +1,6 @@ package bisq.core.payment.validation.altcoins.ella; -import bisq.core.payment.validation.altcoins.AbstractAltcoinAddressValidatorTest; +import bisq.core.payment.validation.AbstractAltcoinAddressValidatorTest; import bisq.core.payment.validation.AltCoinAddressValidator; import org.junit.Test; @@ -11,7 +11,7 @@ public class EllaAddressValidatorTest extends AbstractAltcoinAddressValidatorTes @Test public void testELLA() { - AltCoinAddressValidator validator = new AltCoinAddressValidator(); + AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ELLA"); assertTrue(validator.validate("0x65767ec6d4d3d18a200842352485cdc37cbf3a21").isValid); @@ -22,4 +22,5 @@ public void testELLA() { assertFalse(validator.validate("65767ec6d4d3d18a200842352485cdc37cbf3a2g").isValid); assertFalse(validator.validate("").isValid); } + } From c949a2470059a8ab32dcd102e1a86f9dddbd2beb Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Fri, 23 Mar 2018 15:22:22 +0100 Subject: [PATCH 004/106] Adjust Bch and Ella asset providers names. --- .../bch/{BchAddressValidator.java => BchAssetProvider.java} | 2 +- .../{EllaAddressValidator.java => EllaAssetProvider.java} | 2 +- .../services/bisq.core.payment.validation.AssetProvider | 4 ++-- ...BchAddressValidatorTest.java => BchAssetProviderTest.java} | 2 +- ...laAddressValidatorTest.java => EllaAssetProviderTest.java} | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename src/main/java/bisq/core/payment/validation/altcoins/bch/{BchAddressValidator.java => BchAssetProvider.java} (93%) rename src/main/java/bisq/core/payment/validation/altcoins/ella/{EllaAddressValidator.java => EllaAssetProvider.java} (92%) rename src/test/java/bisq/core/payment/validation/altcoins/bch/{BchAddressValidatorTest.java => BchAssetProviderTest.java} (92%) rename src/test/java/bisq/core/payment/validation/altcoins/ella/{EllaAddressValidatorTest.java => EllaAssetProviderTest.java} (92%) diff --git a/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidator.java b/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAssetProvider.java similarity index 93% rename from src/main/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidator.java rename to src/main/java/bisq/core/payment/validation/altcoins/bch/BchAssetProvider.java index eb9064c6..d541aac7 100644 --- a/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAssetProvider.java @@ -6,7 +6,7 @@ import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; -public class BchAddressValidator extends AbstractAssetProvider { +public class BchAssetProvider extends AbstractAssetProvider { @Override public String getCurrencyCode() { diff --git a/src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidator.java b/src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProvider.java similarity index 92% rename from src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidator.java rename to src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProvider.java index 3ab0edbd..ae84c21e 100644 --- a/src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProvider.java @@ -3,7 +3,7 @@ import bisq.core.payment.validation.AbstractAssetProvider; import bisq.core.util.validation.InputValidator; -public class EllaAddressValidator extends AbstractAssetProvider { +public class EllaAssetProvider extends AbstractAssetProvider { @Override public String getCurrencyCode() { diff --git a/src/main/resources/META-INF/services/bisq.core.payment.validation.AssetProvider b/src/main/resources/META-INF/services/bisq.core.payment.validation.AssetProvider index 1f9acb20..c31497bf 100644 --- a/src/main/resources/META-INF/services/bisq.core.payment.validation.AssetProvider +++ b/src/main/resources/META-INF/services/bisq.core.payment.validation.AssetProvider @@ -1,2 +1,2 @@ -bisq.core.payment.validation.altcoins.bch.BchAddressValidator -bisq.core.payment.validation.altcoins.ella.EllaAddressValidator +bisq.core.payment.validation.altcoins.bch.BchAssetProvider +bisq.core.payment.validation.altcoins.ella.EllaAssetProvider diff --git a/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAssetProviderTest.java similarity index 92% rename from src/test/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidatorTest.java rename to src/test/java/bisq/core/payment/validation/altcoins/bch/BchAssetProviderTest.java index f8bab797..9568a228 100644 --- a/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAssetProviderTest.java @@ -7,7 +7,7 @@ import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertTrue; -public class BchAddressValidatorTest extends AbstractAltcoinAddressValidatorTest { +public class BchAssetProviderTest extends AbstractAltcoinAddressValidatorTest { @Test public void testBCH() { diff --git a/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProviderTest.java similarity index 92% rename from src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidatorTest.java rename to src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProviderTest.java index 88719ab3..f118f453 100644 --- a/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProviderTest.java @@ -7,7 +7,7 @@ import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertTrue; -public class EllaAddressValidatorTest extends AbstractAltcoinAddressValidatorTest { +public class EllaAssetProviderTest extends AbstractAltcoinAddressValidatorTest { @Test public void testELLA() { From 695053d66781d8d79505f791057e842d890cb173 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Mon, 26 Mar 2018 10:32:58 +0200 Subject: [PATCH 005/106] Organize imports --- .../java/bisq/core/locale/CurrencyUtil.java | 16 +++++-- .../java/bisq/core/payment/PaymentModule.java | 4 +- .../validation/AbstractAssetProvider.java | 2 + .../validation/AltCoinAddressValidator.java | 46 +++++++++++++++++-- .../validation/AssetProviderRegistry.java | 7 ++- .../altcoins/bch/BchAssetProvider.java | 1 + .../AbstractAltcoinAddressValidatorTest.java | 2 + .../altcoins/bch/BchAssetProviderTest.java | 3 +- .../altcoins/ella/EllaAssetProviderTest.java | 1 + 9 files changed, 71 insertions(+), 11 deletions(-) diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index cbfed745..4faff4c2 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -17,13 +17,23 @@ package bisq.core.locale; -import bisq.common.app.DevEnv; import bisq.core.payment.validation.AssetProviderRegistry; -import lombok.extern.slf4j.Slf4j; -import java.util.*; +import bisq.common.app.DevEnv; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Currency; +import java.util.List; +import java.util.Locale; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; + @Slf4j public class CurrencyUtil { private static String baseCurrencyCode = "BTC"; diff --git a/src/main/java/bisq/core/payment/PaymentModule.java b/src/main/java/bisq/core/payment/PaymentModule.java index 0efdd6e6..5ced826b 100644 --- a/src/main/java/bisq/core/payment/PaymentModule.java +++ b/src/main/java/bisq/core/payment/PaymentModule.java @@ -17,8 +17,10 @@ package bisq.core.payment; -import bisq.common.app.AppModule; import bisq.core.payment.validation.AssetProviderRegistry; + +import bisq.common.app.AppModule; + import org.springframework.core.env.Environment; public class PaymentModule extends AppModule { diff --git a/src/main/java/bisq/core/payment/validation/AbstractAssetProvider.java b/src/main/java/bisq/core/payment/validation/AbstractAssetProvider.java index 43272d77..06d1e9f0 100644 --- a/src/main/java/bisq/core/payment/validation/AbstractAssetProvider.java +++ b/src/main/java/bisq/core/payment/validation/AbstractAssetProvider.java @@ -2,7 +2,9 @@ import bisq.core.locale.Res; import bisq.core.util.validation.InputValidator; + import org.bitcoinj.core.AddressFormatException; + import org.jetbrains.annotations.NotNull; public abstract class AbstractAssetProvider implements AssetProvider { diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 1f3d2ed9..274b0d8d 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -19,21 +19,57 @@ import bisq.core.app.BisqEnvironment; import bisq.core.locale.Res; -import bisq.core.payment.validation.altcoins.*; -import bisq.core.payment.validation.params.*; +import bisq.core.payment.validation.altcoins.ByteballAddressValidator; +import bisq.core.payment.validation.altcoins.KOTOAddressValidator; +import bisq.core.payment.validation.altcoins.NxtReedSolomonValidator; +import bisq.core.payment.validation.altcoins.OctocoinAddressValidator; +import bisq.core.payment.validation.altcoins.PNCAddressValidator; +import bisq.core.payment.validation.altcoins.WMCCAddressValidator; +import bisq.core.payment.validation.altcoins.XCNAddressValidator; +import bisq.core.payment.validation.altcoins.YTNAddressValidator; +import bisq.core.payment.validation.params.ACHParams; +import bisq.core.payment.validation.params.AlcParams; +import bisq.core.payment.validation.params.CageParams; +import bisq.core.payment.validation.params.CreaParams; +import bisq.core.payment.validation.params.ICHParams; +import bisq.core.payment.validation.params.IOPParams; +import bisq.core.payment.validation.params.ODNParams; +import bisq.core.payment.validation.params.OctocoinParams; +import bisq.core.payment.validation.params.OnionParams; +import bisq.core.payment.validation.params.PARTParams; +import bisq.core.payment.validation.params.PNCParams; +import bisq.core.payment.validation.params.PhoreParams; +import bisq.core.payment.validation.params.PivxParams; +import bisq.core.payment.validation.params.SpeedCashParams; +import bisq.core.payment.validation.params.StrayaParams; +import bisq.core.payment.validation.params.TerracoinParams; +import bisq.core.payment.validation.params.WACoinsParams; +import bisq.core.payment.validation.params.WMCCParams; +import bisq.core.payment.validation.params.XspecParams; import bisq.core.payment.validation.params.btc.BTGParams; import bisq.core.payment.validation.params.btc.BtcMainNetParamsForValidation; import bisq.core.util.validation.InputValidator; -import com.google.inject.Inject; -import lombok.extern.slf4j.Slf4j; + +import org.libdohj.params.DashMainNetParams; +import org.libdohj.params.DashRegTestParams; +import org.libdohj.params.DashTestNet3Params; +import org.libdohj.params.DogecoinMainNetParams; +import org.libdohj.params.LitecoinMainNetParams; +import org.libdohj.params.LitecoinRegTestParams; +import org.libdohj.params.LitecoinTestNet3Params; + import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; import org.bitcoinj.core.Base58; import org.bitcoinj.params.MainNetParams; import org.bitcoinj.params.RegTestParams; import org.bitcoinj.params.TestNet3Params; + +import com.google.inject.Inject; + +import lombok.extern.slf4j.Slf4j; + import org.jetbrains.annotations.NotNull; -import org.libdohj.params.*; @Slf4j public final class AltCoinAddressValidator extends InputValidator { diff --git a/src/main/java/bisq/core/payment/validation/AssetProviderRegistry.java b/src/main/java/bisq/core/payment/validation/AssetProviderRegistry.java index 51cf7a06..2304426d 100644 --- a/src/main/java/bisq/core/payment/validation/AssetProviderRegistry.java +++ b/src/main/java/bisq/core/payment/validation/AssetProviderRegistry.java @@ -1,8 +1,13 @@ package bisq.core.payment.validation; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.ServiceLoader; + import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.util.*; public final class AssetProviderRegistry { diff --git a/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAssetProvider.java b/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAssetProvider.java index d541aac7..461404c9 100644 --- a/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAssetProvider.java +++ b/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAssetProvider.java @@ -3,6 +3,7 @@ import bisq.core.payment.validation.AbstractAssetProvider; import bisq.core.payment.validation.params.btc.BtcMainNetParamsForValidation; import bisq.core.util.validation.InputValidator; + import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; diff --git a/src/test/java/bisq/core/payment/validation/AbstractAltcoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AbstractAltcoinAddressValidatorTest.java index cb1a495b..b61a8b5c 100644 --- a/src/test/java/bisq/core/payment/validation/AbstractAltcoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AbstractAltcoinAddressValidatorTest.java @@ -4,7 +4,9 @@ import bisq.core.btc.BaseCurrencyNetwork; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; + import org.jetbrains.annotations.NotNull; + import org.junit.Before; public abstract class AbstractAltcoinAddressValidatorTest { diff --git a/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAssetProviderTest.java b/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAssetProviderTest.java index 9568a228..ab84c4bc 100644 --- a/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAssetProviderTest.java +++ b/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAssetProviderTest.java @@ -1,7 +1,8 @@ package bisq.core.payment.validation.altcoins.bch; -import bisq.core.payment.validation.AltCoinAddressValidator; import bisq.core.payment.validation.AbstractAltcoinAddressValidatorTest; +import bisq.core.payment.validation.AltCoinAddressValidator; + import org.junit.Test; import static junit.framework.TestCase.assertFalse; diff --git a/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProviderTest.java b/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProviderTest.java index f118f453..b136fe70 100644 --- a/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProviderTest.java +++ b/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProviderTest.java @@ -2,6 +2,7 @@ import bisq.core.payment.validation.AbstractAltcoinAddressValidatorTest; import bisq.core.payment.validation.AltCoinAddressValidator; + import org.junit.Test; import static junit.framework.TestCase.assertFalse; From cab46e238df7dc263c7d20505a5959fd9f9c91ed Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Mon, 26 Mar 2018 13:59:41 +0200 Subject: [PATCH 006/106] Redesign asset listing and validation infrastructure This change builds on initial work in prior commits to fundamentally redesign the way we manage assets in Bisq. Previously, assets were "listed" by adding them in several places, mainly AltCoinAddressValidator and CurrencyUtil. This led to large and growing classes that do everything and that are prone to merge conflicts any time there is more than one open pull request to list an asset. Now we have a new, top-level 'bisq.asset' package (we may want to extract this to its own repository for several reasons). Within, we have a first class concept of an 'Asset' (think "crypto asset", as in the most general term possible for all different kinds of crypto currencies, tokens, colored coins, etc.). Assets implementations are listed in the META-INF/services/bisq.asset.Asset service-provider file. Two subtypes of Asset exist: Coin and Token. 'Coin' is what we have always meant when saying "altcoin" so far: i.e. a coin that has its own blockchain. A 'Token' is an asset that does not have its own blockchain, but rides on top of another through a smart contract, e.g. ERC-20 tokens. And indeed, there is an abstract Erc20Token subtype that captures this common suitation and provides various conveniences. In this commit, several assets have been extracted, including Bitcoin, Bitcoin Cash, Ether, Instacash and Ellaism. Each represents an at least somewhat different kind of asset, and therefore provided a good basis for ensuring that the changes in this commit were sufficiently generalized to accommodate the other asset extractions that will follow in subsequent commits: - Bitcoin is a base currency for Bisq - Bitcoin Cash is a typcial Bitcoin-based altcoin - Instacash is another Bitcoin-based altcoin - Ether is a non Bitcoin-based altcoin - Ellaism is an ERC-20 token A number of changes remain to be made in the new types introduced here, including Javadoc, and this will be added prior to merging the series of commits that will make up the overall pull request. Also note that the tests in AltCoinAddressValidatorTest have been left intact for now, as a means of double-checking that everything works as expected from the application level. It should also be noted that AltCoinAddressValidator is essentially becoming a translation layer (an "anti-corruption layer" in DDD terms) where the new 'bisq.asset' world meets the old AltCoinAddressValidator / CurrencyUtil world that bisq-desktop already knows. It is intentional that this refactoring has been isolated in this way, leaving the old "contract" for AltCoinAddressValidator and CurrencyUtil intact. We can see about refactoring bisq-desktop to deal more directly with the new AssetRegistry interface in the future, but it is not necessary, and indeed not desirable to do all of that now in this PR. The idea is to redesign the underlying infrastructure now, enough to make it more manageable to deal with going forward. --- .idea/codeStyles/Project.xml | 2 + src/main/java/bisq/asset/AbstractAsset.java | 32 +++++++ .../bisq/asset/AddressValidationResult.java | 65 ++++++++++++++ .../java/bisq/asset/AddressValidator.java | 23 +++++ src/main/java/bisq/asset/Asset.java | 10 +++ src/main/java/bisq/asset/AssetRegistry.java | 38 ++++++++ .../asset/Base58BitcoinAddressValidator.java | 47 ++++++++++ src/main/java/bisq/asset/Coin.java | 38 ++++++++ src/main/java/bisq/asset/Erc20Token.java | 25 ++++++ .../bisq/asset/EtherAddressValidator.java | 26 ++++++ .../NetworkParametersAdapter.java} | 22 +---- .../RegexAddressValidator.java} | 21 +++-- src/main/java/bisq/asset/Token.java | 25 ++++++ src/main/java/bisq/asset/coins/Bitcoin.java | 57 ++++++++++++ .../java/bisq/asset/coins/BitcoinCash.java | 11 +++ src/main/java/bisq/asset/coins/Ether.java | 28 ++++++ src/main/java/bisq/asset/coins/Instacash.java | 61 +++++++++++++ src/main/java/bisq/asset/tokens/Ellaism.java | 10 +++ .../java/bisq/core/locale/CurrencyUtil.java | 30 ++++--- .../validation/AbstractAssetProvider.java | 20 ----- .../validation/AltCoinAddressValidator.java | 88 ++++++++----------- .../payment/validation/AssetProvider.java | 14 --- .../validation/AssetProviderRegistry.java | 60 ------------- .../altcoins/bch/BchAssetProvider.java | 36 -------- .../altcoins/ella/EllaAssetProvider.java | 32 ------- .../META-INF/services/bisq.asset.Asset | 7 ++ ...bisq.core.payment.validation.AssetProvider | 2 - .../java/bisq/asset/AbstractAssetTest.java | 63 +++++++++++++ .../bisq/asset/coins/BitcoinCashTest.java | 26 ++++++ .../java/bisq/asset/coins/BitcoinTest.java | 27 ++++++ .../java/bisq/asset/coins/InstacashTest.java | 29 ++++++ .../java/bisq/asset/tokens/EllaismTest.java | 25 ++++++ .../AbstractAltcoinAddressValidatorTest.java | 14 ++- .../AltCoinAddressValidatorTest.java | 56 ------------ .../altcoins/bch/BchAssetProviderTest.java | 28 ------ .../altcoins/ella/EllaAssetProviderTest.java | 27 ------ 36 files changed, 746 insertions(+), 379 deletions(-) create mode 100644 src/main/java/bisq/asset/AbstractAsset.java create mode 100644 src/main/java/bisq/asset/AddressValidationResult.java create mode 100644 src/main/java/bisq/asset/AddressValidator.java create mode 100644 src/main/java/bisq/asset/Asset.java create mode 100644 src/main/java/bisq/asset/AssetRegistry.java create mode 100644 src/main/java/bisq/asset/Base58BitcoinAddressValidator.java create mode 100644 src/main/java/bisq/asset/Coin.java create mode 100644 src/main/java/bisq/asset/Erc20Token.java create mode 100644 src/main/java/bisq/asset/EtherAddressValidator.java rename src/main/java/bisq/{core/payment/validation/params/ICHParams.java => asset/NetworkParametersAdapter.java} (76%) rename src/main/java/bisq/{core/payment/PaymentModule.java => asset/RegexAddressValidator.java} (62%) create mode 100644 src/main/java/bisq/asset/Token.java create mode 100644 src/main/java/bisq/asset/coins/Bitcoin.java create mode 100644 src/main/java/bisq/asset/coins/BitcoinCash.java create mode 100644 src/main/java/bisq/asset/coins/Ether.java create mode 100644 src/main/java/bisq/asset/coins/Instacash.java create mode 100644 src/main/java/bisq/asset/tokens/Ellaism.java delete mode 100644 src/main/java/bisq/core/payment/validation/AbstractAssetProvider.java delete mode 100644 src/main/java/bisq/core/payment/validation/AssetProvider.java delete mode 100644 src/main/java/bisq/core/payment/validation/AssetProviderRegistry.java delete mode 100644 src/main/java/bisq/core/payment/validation/altcoins/bch/BchAssetProvider.java delete mode 100644 src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProvider.java create mode 100644 src/main/resources/META-INF/services/bisq.asset.Asset delete mode 100644 src/main/resources/META-INF/services/bisq.core.payment.validation.AssetProvider create mode 100644 src/test/java/bisq/asset/AbstractAssetTest.java create mode 100644 src/test/java/bisq/asset/coins/BitcoinCashTest.java create mode 100644 src/test/java/bisq/asset/coins/BitcoinTest.java create mode 100644 src/test/java/bisq/asset/coins/InstacashTest.java create mode 100644 src/test/java/bisq/asset/tokens/EllaismTest.java delete mode 100644 src/test/java/bisq/core/payment/validation/altcoins/bch/BchAssetProviderTest.java delete mode 100644 src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProviderTest.java diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index af939e65..76e08734 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -25,6 +25,8 @@ + + diff --git a/src/main/java/bisq/asset/AbstractAsset.java b/src/main/java/bisq/asset/AbstractAsset.java new file mode 100644 index 00000000..8050f14b --- /dev/null +++ b/src/main/java/bisq/asset/AbstractAsset.java @@ -0,0 +1,32 @@ +package bisq.asset; + +import static org.apache.commons.lang3.Validate.notBlank; +import static org.apache.commons.lang3.Validate.notNull; + +public abstract class AbstractAsset implements Asset { + + private final String name; + private final String tickerSymbol; + private final AddressValidator addressValidator; + + public AbstractAsset(String name, String tickerSymbol, AddressValidator addressValidator) { + this.name = notBlank(name); + this.tickerSymbol = notBlank(tickerSymbol); + this.addressValidator = notNull(addressValidator); + } + + @Override + public final String getName() { + return name; + } + + @Override + public final String getTickerSymbol() { + return tickerSymbol; + } + + @Override + public final AddressValidationResult validateAddress(String address) { + return addressValidator.validate(address); + } +} diff --git a/src/main/java/bisq/asset/AddressValidationResult.java b/src/main/java/bisq/asset/AddressValidationResult.java new file mode 100644 index 00000000..b426415c --- /dev/null +++ b/src/main/java/bisq/asset/AddressValidationResult.java @@ -0,0 +1,65 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset; + +public class AddressValidationResult { + + public static AddressValidationResult VALID = new AddressValidationResult(true); + + private final boolean isValid; + private String message; + private String i18nKey; + + private AddressValidationResult(boolean isValid) { + this.isValid = isValid; + } + + private AddressValidationResult(boolean isValid, String message, String i18nKey) { + this(isValid); + this.message = message; + this.i18nKey = i18nKey; + } + + public boolean isValid() { + return isValid; + } + + public String getI18nKey() { + return i18nKey; + } + + public String getMessage() { + return message; + } + + public static AddressValidationResult validAddress() { + return VALID; + } + + public static AddressValidationResult invalidStructure() { + return new AddressValidationResult(false, "", "validation.altcoin.wrongStructure"); + } + + public static AddressValidationResult invalidAddress(String cause) { + return new AddressValidationResult(false, cause, "validation.altcoin.invalidAddress"); + } + + public static AddressValidationResult invalidAddress(Throwable cause) { + return invalidAddress(cause.getMessage()); + } +} diff --git a/src/main/java/bisq/asset/AddressValidator.java b/src/main/java/bisq/asset/AddressValidator.java new file mode 100644 index 00000000..0fe72cd2 --- /dev/null +++ b/src/main/java/bisq/asset/AddressValidator.java @@ -0,0 +1,23 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset; + +public interface AddressValidator { + + AddressValidationResult validate(String address); +} diff --git a/src/main/java/bisq/asset/Asset.java b/src/main/java/bisq/asset/Asset.java new file mode 100644 index 00000000..d74adb00 --- /dev/null +++ b/src/main/java/bisq/asset/Asset.java @@ -0,0 +1,10 @@ +package bisq.asset; + +public interface Asset { + + String getName(); + + String getTickerSymbol(); + + AddressValidationResult validateAddress(String address); +} diff --git a/src/main/java/bisq/asset/AssetRegistry.java b/src/main/java/bisq/asset/AssetRegistry.java new file mode 100644 index 00000000..eddb0827 --- /dev/null +++ b/src/main/java/bisq/asset/AssetRegistry.java @@ -0,0 +1,38 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset; + +import java.util.ArrayList; +import java.util.List; +import java.util.ServiceLoader; +import java.util.stream.Stream; + +public class AssetRegistry { + + private static final List registeredAssets = new ArrayList<>(); + + static { + for (Asset asset : ServiceLoader.load(Asset.class)) { + registeredAssets.add(asset); + } + } + + public Stream stream() { + return registeredAssets.stream(); + } +} diff --git a/src/main/java/bisq/asset/Base58BitcoinAddressValidator.java b/src/main/java/bisq/asset/Base58BitcoinAddressValidator.java new file mode 100644 index 00000000..616bbbab --- /dev/null +++ b/src/main/java/bisq/asset/Base58BitcoinAddressValidator.java @@ -0,0 +1,47 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset; + +import org.bitcoinj.core.Address; +import org.bitcoinj.core.AddressFormatException; +import org.bitcoinj.core.NetworkParameters; +import org.bitcoinj.params.MainNetParams; + +public class Base58BitcoinAddressValidator implements AddressValidator { + + private final NetworkParameters networkParameters; + + public Base58BitcoinAddressValidator() { + this(MainNetParams.get()); + } + + public Base58BitcoinAddressValidator(NetworkParameters networkParameters) { + this.networkParameters = networkParameters; + } + + @Override + public AddressValidationResult validate(String address) { + try { + Address.fromBase58(networkParameters, address); + } catch (AddressFormatException ex) { + return AddressValidationResult.invalidAddress(ex); + } + + return AddressValidationResult.validAddress(); + } +} diff --git a/src/main/java/bisq/asset/Coin.java b/src/main/java/bisq/asset/Coin.java new file mode 100644 index 00000000..19cf8838 --- /dev/null +++ b/src/main/java/bisq/asset/Coin.java @@ -0,0 +1,38 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset; + +public abstract class Coin extends AbstractAsset { + + public enum Network { MAINNET, TESTNET, REGTEST } + + private final Network network; + + public Coin(String name, String tickerSymbol, AddressValidator addressValidator) { + this(name, tickerSymbol, addressValidator, Network.MAINNET); + } + + public Coin(String name, String tickerSymbol, AddressValidator addressValidator, Network network) { + super(name, tickerSymbol, addressValidator); + this.network = network; + } + + public Network getNetwork() { + return network; + } +} diff --git a/src/main/java/bisq/asset/Erc20Token.java b/src/main/java/bisq/asset/Erc20Token.java new file mode 100644 index 00000000..86a33e3c --- /dev/null +++ b/src/main/java/bisq/asset/Erc20Token.java @@ -0,0 +1,25 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset; + +public abstract class Erc20Token extends Token { + + public Erc20Token(String name, String tickerSymbol) { + super(name, tickerSymbol, new EtherAddressValidator()); + } +} diff --git a/src/main/java/bisq/asset/EtherAddressValidator.java b/src/main/java/bisq/asset/EtherAddressValidator.java new file mode 100644 index 00000000..10d5003c --- /dev/null +++ b/src/main/java/bisq/asset/EtherAddressValidator.java @@ -0,0 +1,26 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset; + +public class EtherAddressValidator extends RegexAddressValidator { + + public EtherAddressValidator() { + // https://github.com/ethereum/web3.js/blob/master/lib/utils/utils.js#L403 + super("^(0x)?[0-9a-fA-F]{40}$"); + } +} diff --git a/src/main/java/bisq/core/payment/validation/params/ICHParams.java b/src/main/java/bisq/asset/NetworkParametersAdapter.java similarity index 76% rename from src/main/java/bisq/core/payment/validation/params/ICHParams.java rename to src/main/java/bisq/asset/NetworkParametersAdapter.java index 7b42ade5..62ed257b 100644 --- a/src/main/java/bisq/core/payment/validation/params/ICHParams.java +++ b/src/main/java/bisq/asset/NetworkParametersAdapter.java @@ -15,7 +15,7 @@ * along with Bisq. If not, see . */ -package bisq.core.payment.validation.params; +package bisq.asset; import org.bitcoinj.core.BitcoinSerializer; import org.bitcoinj.core.Block; @@ -27,26 +27,8 @@ import org.bitcoinj.store.BlockStoreException; import org.bitcoinj.utils.MonetaryFormat; -public class ICHParams extends NetworkParameters { +public abstract class NetworkParametersAdapter extends NetworkParameters { - private static ICHParams instance; - - public static synchronized ICHParams get() { - if (instance == null) { - instance = new ICHParams(); - } - return instance; - } - - // We only use the properties needed for address validation - public ICHParams() { - super(); - addressHeader = 23; - p2shHeader = 13; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - // default dummy implementations, not used... @Override public String getPaymentProtocolId() { return PAYMENT_PROTOCOL_ID_MAINNET; diff --git a/src/main/java/bisq/core/payment/PaymentModule.java b/src/main/java/bisq/asset/RegexAddressValidator.java similarity index 62% rename from src/main/java/bisq/core/payment/PaymentModule.java rename to src/main/java/bisq/asset/RegexAddressValidator.java index 5ced826b..1855b068 100644 --- a/src/main/java/bisq/core/payment/PaymentModule.java +++ b/src/main/java/bisq/asset/RegexAddressValidator.java @@ -15,22 +15,21 @@ * along with Bisq. If not, see . */ -package bisq.core.payment; +package bisq.asset; -import bisq.core.payment.validation.AssetProviderRegistry; +public class RegexAddressValidator implements AddressValidator { -import bisq.common.app.AppModule; + private final String regex; -import org.springframework.core.env.Environment; - -public class PaymentModule extends AppModule { - - public PaymentModule(Environment environment) { - super(environment); + public RegexAddressValidator(String regex) { + this.regex = regex; } @Override - protected final void configure() { - bind(AssetProviderRegistry.class).toInstance(AssetProviderRegistry.getInstance()); + public AddressValidationResult validate(String address) { + if (!address.matches(regex)) + return AddressValidationResult.invalidStructure(); + + return AddressValidationResult.validAddress(); } } diff --git a/src/main/java/bisq/asset/Token.java b/src/main/java/bisq/asset/Token.java new file mode 100644 index 00000000..215c87a3 --- /dev/null +++ b/src/main/java/bisq/asset/Token.java @@ -0,0 +1,25 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset; + +public abstract class Token extends AbstractAsset { + + public Token(String name, String tickerSymbol, AddressValidator addressValidator) { + super(name, tickerSymbol, addressValidator); + } +} diff --git a/src/main/java/bisq/asset/coins/Bitcoin.java b/src/main/java/bisq/asset/coins/Bitcoin.java new file mode 100644 index 00000000..74154062 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Bitcoin.java @@ -0,0 +1,57 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; + +import org.bitcoinj.core.NetworkParameters; +import org.bitcoinj.params.MainNetParams; +import org.bitcoinj.params.RegTestParams; +import org.bitcoinj.params.TestNet3Params; + +public abstract class Bitcoin extends Coin { + + public Bitcoin(Network network, NetworkParameters networkParameters) { + super("Bitcoin", "BTC", new Base58BitcoinAddressValidator(networkParameters), network); + } + + + public static class Mainnet extends Bitcoin { + + public Mainnet() { + super(Network.MAINNET, MainNetParams.get()); + } + } + + + public static class Testnet extends Bitcoin { + + public Testnet() { + super(Network.TESTNET, TestNet3Params.get()); + } + } + + + public static class Regtest extends Bitcoin { + + public Regtest() { + super(Network.REGTEST, RegTestParams.get()); + } + } +} diff --git a/src/main/java/bisq/asset/coins/BitcoinCash.java b/src/main/java/bisq/asset/coins/BitcoinCash.java new file mode 100644 index 00000000..b5e08305 --- /dev/null +++ b/src/main/java/bisq/asset/coins/BitcoinCash.java @@ -0,0 +1,11 @@ +package bisq.asset.coins; + +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; + +public class BitcoinCash extends Coin { + + public BitcoinCash() { + super("Bitcoin Cash", "BCH", new Base58BitcoinAddressValidator()); + } +} diff --git a/src/main/java/bisq/asset/coins/Ether.java b/src/main/java/bisq/asset/coins/Ether.java new file mode 100644 index 00000000..bb534c34 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Ether.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.EtherAddressValidator; + +public class Ether extends Coin { + + public Ether() { + super("Ether", "ETH", new EtherAddressValidator()); + } +} diff --git a/src/main/java/bisq/asset/coins/Instacash.java b/src/main/java/bisq/asset/coins/Instacash.java new file mode 100644 index 00000000..3b11eaa2 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Instacash.java @@ -0,0 +1,61 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.AddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +import org.bitcoinj.core.Address; +import org.bitcoinj.core.AddressFormatException; + +public class Instacash extends Coin { + + public Instacash() { + super("Instacash", "ICH", new InstacashAddressValidator()); + } + + + public static class InstacashAddressValidator implements AddressValidator { + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[A][a-km-zA-HJ-NP-Z1-9]{25,34}$")) + return AddressValidationResult.invalidStructure(); + + try { + Address.fromBase58(new InstacashParams(), address); + } catch (AddressFormatException ex) { + return AddressValidationResult.invalidAddress(ex); + } + + return AddressValidationResult.validAddress(); + } + } + + + public static class InstacashParams extends NetworkParametersAdapter { + + public InstacashParams() { + addressHeader = 23; + p2shHeader = 13; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/java/bisq/asset/tokens/Ellaism.java b/src/main/java/bisq/asset/tokens/Ellaism.java new file mode 100644 index 00000000..9d745e9b --- /dev/null +++ b/src/main/java/bisq/asset/tokens/Ellaism.java @@ -0,0 +1,10 @@ +package bisq.asset.tokens; + +import bisq.asset.Erc20Token; + +public class Ellaism extends Erc20Token { + + public Ellaism() { + super("Ellaism", "ELLA"); + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 4faff4c2..29432d0a 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -17,7 +17,9 @@ package bisq.core.locale; -import bisq.core.payment.validation.AssetProviderRegistry; +import bisq.asset.Asset; +import bisq.asset.AssetRegistry; +import bisq.asset.Token; import bisq.common.app.DevEnv; @@ -36,6 +38,9 @@ @Slf4j public class CurrencyUtil { + + private static final AssetRegistry assetRegistry = new AssetRegistry(); + private static String baseCurrencyCode = "BTC"; public static void setBaseCurrencyCode(String baseCurrencyCode) { @@ -92,21 +97,16 @@ public static List getAllSortedCryptoCurrencies() { return allSortedCryptoCurrencies; } - // Don't make a PR for adding a coin but follow the steps described here: - // https://forum.bisq.network/t/how-to-add-your-favorite-altcoin/ - public static List createAllSortedCryptoCurrenciesList() { - final List result = AssetProviderRegistry.getInstance() - .getProviders() - .stream() - .map(assetProvider -> new CryptoCurrency(assetProvider.getCurrencyCode(), assetProvider.getCurrencyName(), assetProvider.isAsset())) + private static List createAllSortedCryptoCurrenciesList() { + List result = assetRegistry.stream() + .filter(CurrencyUtil::assetIsNotBaseCurrency) + .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); result.add(new CryptoCurrency("BETR", "Better Betting", true)); if (DevEnv.DAO_TRADING_ACTIVATED) result.add(new CryptoCurrency("BSQ", "Bisq Token")); - if (!baseCurrencyCode.equals("BTC")) - result.add(new CryptoCurrency("BTC", "Bitcoin")); result.add(new CryptoCurrency("BCHC", "Bitcoin Clashic")); result.add(new CryptoCurrency("BTG", "Bitcoin Gold")); result.add(new CryptoCurrency("BURST", "Burstcoin")); @@ -124,7 +124,6 @@ public static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("DOGE", "Dogecoin")); result.add(new CryptoCurrency("DMC", "DynamicCoin")); result.add(new CryptoCurrency("ESP", "Espers")); - result.add(new CryptoCurrency("ETH", "Ether")); result.add(new CryptoCurrency("ETC", "Ether Classic")); result.add(new CryptoCurrency("XIN", "Infinity Economics")); result.add(new CryptoCurrency("IOP", "Internet Of People")); @@ -194,7 +193,6 @@ public static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("QWARK", "Qwark", true)); result.add(new CryptoCurrency("GEO", "GeoCoin", true)); result.add(new CryptoCurrency("GRANS", "10grans", true)); - result.add(new CryptoCurrency("ICH", "ICH")); result.add(new CryptoCurrency("PHR", "Phore")); result.sort(TradeCurrency::compareTo); @@ -407,4 +405,12 @@ public static String getNameAndCode(String currencyCode) { public static TradeCurrency getDefaultTradeCurrency() { return GlobalSettings.getDefaultTradeCurrency(); } + + private static boolean assetIsNotBaseCurrency(Asset asset) { + return !asset.getTickerSymbol().equals(baseCurrencyCode); + } + + private static CryptoCurrency assetToCryptoCurrency(Asset asset) { + return new CryptoCurrency(asset.getTickerSymbol(), asset.getName(), asset instanceof Token); + } } diff --git a/src/main/java/bisq/core/payment/validation/AbstractAssetProvider.java b/src/main/java/bisq/core/payment/validation/AbstractAssetProvider.java deleted file mode 100644 index 06d1e9f0..00000000 --- a/src/main/java/bisq/core/payment/validation/AbstractAssetProvider.java +++ /dev/null @@ -1,20 +0,0 @@ -package bisq.core.payment.validation; - -import bisq.core.locale.Res; -import bisq.core.util.validation.InputValidator; - -import org.bitcoinj.core.AddressFormatException; - -import org.jetbrains.annotations.NotNull; - -public abstract class AbstractAssetProvider implements AssetProvider { - - protected InputValidator.ValidationResult getRegexTestFailed() { - return new InputValidator.ValidationResult(false, Res.get("validation.altcoin.wrongStructure", getCurrencyCode())); - } - - @NotNull - protected String getErrorMessage(AddressFormatException e) { - return Res.get("validation.altcoin.invalidAddress", getCurrencyCode(), e.getMessage()); - } -} diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 274b0d8d..708eaf7a 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -18,6 +18,11 @@ package bisq.core.payment.validation; import bisq.core.app.BisqEnvironment; +import bisq.asset.AddressValidationResult; +import bisq.asset.Coin; +import bisq.asset.Asset; +import bisq.asset.AssetRegistry; +import bisq.core.btc.BaseCurrencyNetwork; import bisq.core.locale.Res; import bisq.core.payment.validation.altcoins.ByteballAddressValidator; import bisq.core.payment.validation.altcoins.KOTOAddressValidator; @@ -31,7 +36,6 @@ import bisq.core.payment.validation.params.AlcParams; import bisq.core.payment.validation.params.CageParams; import bisq.core.payment.validation.params.CreaParams; -import bisq.core.payment.validation.params.ICHParams; import bisq.core.payment.validation.params.IOPParams; import bisq.core.payment.validation.params.ODNParams; import bisq.core.payment.validation.params.OctocoinParams; @@ -67,6 +71,8 @@ import com.google.inject.Inject; +import java.util.Optional; + import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; @@ -74,12 +80,12 @@ @Slf4j public final class AltCoinAddressValidator extends InputValidator { - private final AssetProviderRegistry assetProviderRegistry; + private final AssetRegistry assetRegistry; private String currencyCode; @Inject - public AltCoinAddressValidator(AssetProviderRegistry assetProviderRegistry) { - this.assetProviderRegistry = assetProviderRegistry; + public AltCoinAddressValidator(AssetRegistry assetRegistry) { + this.assetRegistry = assetRegistry; } /////////////////////////////////////////////////////////////////////////////////////////// @@ -101,38 +107,21 @@ public ValidationResult validate(String input) { ValidationResult regexTestFailed = new ValidationResult(false, Res.get("validation.altcoin.wrongStructure", currencyCode)); - final AssetProvider assetProvider = assetProviderRegistry.getProviderByCurrencyCode(currencyCode); - if (null != assetProvider) { - return assetProvider.validateAddress(input); + Optional asset = assetRegistry.stream() + .filter(this::assetMatchesSelectedCurrencyCode) + .filter(this::assetIsNotBaseCurrencyForDifferentNetwork) + .findFirst(); + + if (asset.isPresent()) { + AddressValidationResult addressValidationResult = asset.get().validateAddress(input); + + if (addressValidationResult.isValid()) + return new ValidationResult(true); + + return new ValidationResult(false, Res.get(addressValidationResult.getI18nKey(), asset.get().getTickerSymbol(), addressValidationResult.getMessage())); } + switch (currencyCode) { - case "BTC": - try { - switch (BisqEnvironment.getBaseCurrencyNetwork()) { - case BTC_MAINNET: - Address.fromBase58(MainNetParams.get(), input); - break; - case BTC_TESTNET: - Address.fromBase58(TestNet3Params.get(), input); - break; - case BTC_REGTEST: - Address.fromBase58(RegTestParams.get(), input); - break; - case LTC_MAINNET: - case LTC_TESTNET: - case LTC_REGTEST: - case DASH_MAINNET: - case DASH_TESTNET: - case DASH_REGTEST: - // We cannot use MainNetParams because that would be one of the other base currencies, - // so we cloned the MainNetParams to BtcMainNetParamsForValidation - Address.fromBase58(BtcMainNetParamsForValidation.get(), input); - return new ValidationResult(true); - } - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } case "BSQ": if (!input.startsWith("B")) return new ValidationResult(false, Res.get("validation.altcoin.invalidAddress", @@ -208,12 +197,6 @@ public ValidationResult validate(String input) { } catch (AddressFormatException e) { return new ValidationResult(false, getErrorMessage(e)); } - case "ETH": - // 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); case "PIVX": if (input.matches("^[D][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { //noinspection ConstantConditions @@ -560,18 +543,6 @@ public ValidationResult validate(String input) { return regexTestFailed; else return new ValidationResult(true); - case "ICH": - if (input.matches("^[A][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { - //noinspection ConstantConditions - try { - Address.fromBase58(ICHParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } - } else { - return regexTestFailed; - } case "PHR": if (input.matches("^[P][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { //noinspection ConstantConditions @@ -597,4 +568,17 @@ public ValidationResult validate(String input) { private String getErrorMessage(AddressFormatException e) { return Res.get("validation.altcoin.invalidAddress", currencyCode, e.getMessage()); } + + private boolean assetMatchesSelectedCurrencyCode(Asset a) { + return currencyCode.equals(a.getTickerSymbol()); + } + + private boolean assetIsNotBaseCurrencyForDifferentNetwork(Asset asset) { + BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork(); + + return !(asset instanceof Coin) + || !asset.getTickerSymbol().equals(baseCurrencyNetwork.getCurrencyCode()) + || (((Coin) asset).getNetwork().name().equals(baseCurrencyNetwork.getNetwork())); + } + } diff --git a/src/main/java/bisq/core/payment/validation/AssetProvider.java b/src/main/java/bisq/core/payment/validation/AssetProvider.java deleted file mode 100644 index ba26d2a8..00000000 --- a/src/main/java/bisq/core/payment/validation/AssetProvider.java +++ /dev/null @@ -1,14 +0,0 @@ -package bisq.core.payment.validation; - -import bisq.core.util.validation.InputValidator; - -public interface AssetProvider { - - String getCurrencyCode(); - - String getCurrencyName(); - - boolean isAsset(); - - InputValidator.ValidationResult validateAddress(String input); -} diff --git a/src/main/java/bisq/core/payment/validation/AssetProviderRegistry.java b/src/main/java/bisq/core/payment/validation/AssetProviderRegistry.java deleted file mode 100644 index 2304426d..00000000 --- a/src/main/java/bisq/core/payment/validation/AssetProviderRegistry.java +++ /dev/null @@ -1,60 +0,0 @@ -package bisq.core.payment.validation; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.ServiceLoader; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public final class AssetProviderRegistry { - - private Map providers; - - private static AssetProviderRegistry instance; - - public static AssetProviderRegistry getInstance() { - if (null == instance) { - instance = new AssetProviderRegistry(); - } - return instance; - } - - private AssetProviderRegistry() { - } - - @Nullable - public AssetProvider getProviderByCurrencyCode(String code) { - return getProvidersMap().get(code); - } - - @Nonnull - public Collection getProviders() { - return Collections.unmodifiableCollection(getProvidersMap().values()); - } - - @Nonnull - private Map getProvidersMap() { - if (null == providers) { - initProviders(); - } - return providers; - } - - private void initProviders() { - providers = new HashMap<>(); - for (AssetProvider provider : ServiceLoader.load(AssetProvider.class)) { - String currencyCode = provider.getCurrencyCode(); - AssetProvider existingProvider = providers.get(currencyCode); - if (null != existingProvider) { - final String providerClassName = provider.getClass().getCanonicalName(); - final String existingProviderClassName = existingProvider.getClass().getCanonicalName(); - String message = String.format("AssetProvider %s wants to register itself for asset %s which is already registered with %s", providerClassName, currencyCode, existingProviderClassName); - throw new RuntimeException(message); - } - providers.put(currencyCode, provider); - } - } -} diff --git a/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAssetProvider.java b/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAssetProvider.java deleted file mode 100644 index 461404c9..00000000 --- a/src/main/java/bisq/core/payment/validation/altcoins/bch/BchAssetProvider.java +++ /dev/null @@ -1,36 +0,0 @@ -package bisq.core.payment.validation.altcoins.bch; - -import bisq.core.payment.validation.AbstractAssetProvider; -import bisq.core.payment.validation.params.btc.BtcMainNetParamsForValidation; -import bisq.core.util.validation.InputValidator; - -import org.bitcoinj.core.Address; -import org.bitcoinj.core.AddressFormatException; - -public class BchAssetProvider extends AbstractAssetProvider { - - @Override - public String getCurrencyCode() { - return "BCH"; - } - - @Override - public String getCurrencyName() { - return "Bitcoin Cash"; - } - - @Override - public boolean isAsset() { - return false; - } - - @Override - public InputValidator.ValidationResult validateAddress(String input) { - try { - Address.fromBase58(BtcMainNetParamsForValidation.get(), input); - return new InputValidator.ValidationResult(true); - } catch (AddressFormatException e) { - return new InputValidator.ValidationResult(false, getErrorMessage(e)); - } - } -} diff --git a/src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProvider.java b/src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProvider.java deleted file mode 100644 index ae84c21e..00000000 --- a/src/main/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProvider.java +++ /dev/null @@ -1,32 +0,0 @@ -package bisq.core.payment.validation.altcoins.ella; - -import bisq.core.payment.validation.AbstractAssetProvider; -import bisq.core.util.validation.InputValidator; - -public class EllaAssetProvider extends AbstractAssetProvider { - - @Override - public String getCurrencyCode() { - return "ELLA"; - } - - @Override - public String getCurrencyName() { - return "Ellaism"; - } - - @Override - public boolean isAsset() { - return false; - } - - @Override - public InputValidator.ValidationResult validateAddress(String input) { - // https://github.com/ethereum/web3.js/blob/master/lib/utils/utils.js#L403 - if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) { - return getRegexTestFailed(); - } else { - return new InputValidator.ValidationResult(true); - } - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset new file mode 100644 index 00000000..6fd2351b --- /dev/null +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -0,0 +1,7 @@ +bisq.asset.coins.Bitcoin$Mainnet +bisq.asset.coins.Bitcoin$Regtest +bisq.asset.coins.Bitcoin$Testnet +bisq.asset.coins.BitcoinCash +bisq.asset.coins.Ether +bisq.asset.coins.Instacash +bisq.asset.tokens.Ellaism diff --git a/src/main/resources/META-INF/services/bisq.core.payment.validation.AssetProvider b/src/main/resources/META-INF/services/bisq.core.payment.validation.AssetProvider deleted file mode 100644 index c31497bf..00000000 --- a/src/main/resources/META-INF/services/bisq.core.payment.validation.AssetProvider +++ /dev/null @@ -1,2 +0,0 @@ -bisq.core.payment.validation.altcoins.bch.BchAssetProvider -bisq.core.payment.validation.altcoins.ella.EllaAssetProvider diff --git a/src/test/java/bisq/asset/AbstractAssetTest.java b/src/test/java/bisq/asset/AbstractAssetTest.java new file mode 100644 index 00000000..94eae9df --- /dev/null +++ b/src/test/java/bisq/asset/AbstractAssetTest.java @@ -0,0 +1,63 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset; + +import bisq.core.btc.BaseCurrencyNetwork; +import bisq.core.locale.Res; + +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +public abstract class AbstractAssetTest { + + protected final Asset asset; + + public AbstractAssetTest(Asset asset) { + this.asset = asset; + } + + @Before + public void setup() { + BaseCurrencyNetwork baseCurrencyNetwork = BaseCurrencyNetwork.BTC_MAINNET; + Res.setBaseCurrencyCode(baseCurrencyNetwork.getCurrencyCode()); + Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName()); + } + + @Test + public void testBlank() { + assertInvalidAddress(""); + } + + @Test + public abstract void testValidAddresses(); + + @Test + public abstract void testInvalidAddresses(); + + protected void assertValidAddress(String address) { + AddressValidationResult result = asset.validateAddress(address); + assertThat(result.getMessage(), result.isValid(), is(true)); + } + + protected void assertInvalidAddress(String address) { + assertThat(asset.validateAddress(address).isValid(), is(false)); + } +} diff --git a/src/test/java/bisq/asset/coins/BitcoinCashTest.java b/src/test/java/bisq/asset/coins/BitcoinCashTest.java new file mode 100644 index 00000000..68b8f2f0 --- /dev/null +++ b/src/test/java/bisq/asset/coins/BitcoinCashTest.java @@ -0,0 +1,26 @@ +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class BitcoinCashTest extends AbstractAssetTest { + + public BitcoinCashTest() { + super(new BitcoinCash()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSH"); + assertValidAddress("1MEbUJ5v5MdDEqFJGz4SZp58KkaLdmXZ85"); + assertValidAddress("34dvotXMg5Gxc37TBVV2e5GUAfCFu7Ms4g"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("21HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSHa"); + assertInvalidAddress("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSHs"); + assertInvalidAddress("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSH#"); + } +} diff --git a/src/test/java/bisq/asset/coins/BitcoinTest.java b/src/test/java/bisq/asset/coins/BitcoinTest.java new file mode 100644 index 00000000..5f3dee7c --- /dev/null +++ b/src/test/java/bisq/asset/coins/BitcoinTest.java @@ -0,0 +1,27 @@ +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class BitcoinTest extends AbstractAssetTest { + + public BitcoinTest() { + super(new Bitcoin.Mainnet()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem"); + assertValidAddress("3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX"); + assertValidAddress("1111111111111111111114oLvT2"); + assertValidAddress("1BitcoinEaterAddressDontSendf59kuE"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq"); + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYheO"); + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhek#"); + } +} diff --git a/src/test/java/bisq/asset/coins/InstacashTest.java b/src/test/java/bisq/asset/coins/InstacashTest.java new file mode 100644 index 00000000..0309ae2d --- /dev/null +++ b/src/test/java/bisq/asset/coins/InstacashTest.java @@ -0,0 +1,29 @@ +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class InstacashTest extends AbstractAssetTest { + + public InstacashTest() { + super(new Instacash()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("AYx4EqKhomeMu2CTMx1AHdNMkjv6ygnvji"); + assertValidAddress("AcWyvE7texXcCsPLvW1btXhLimrDMpNdAu"); + assertValidAddress("AMfLeLotcvgaHQW374NmHZgs1qXF8P6kjc"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("aYzyJYqhnxF738QjqMqTku5Wft7x4GhVCr"); + assertInvalidAddress("DYzyJYqhnxF738QjqMqTku5Wft7x4GhVCr"); + assertInvalidAddress("xYzyJYqhnxF738QjqMqTku5Wft7x4GhVCr"); + assertInvalidAddress("1YzyJYqhnxF738QjqMqTku5Wft7x4GhVCr"); + assertInvalidAddress( + "AYzyJYqhnxF738QjqMqTku5Wft7x4GhVCr5vcz2NZLUDsoXGp5rAFUjKnb7DdkFbLp7aSpejCcC4FTxsVvDxq9YKSprzf"); + } +} diff --git a/src/test/java/bisq/asset/tokens/EllaismTest.java b/src/test/java/bisq/asset/tokens/EllaismTest.java new file mode 100644 index 00000000..4337710d --- /dev/null +++ b/src/test/java/bisq/asset/tokens/EllaismTest.java @@ -0,0 +1,25 @@ +package bisq.asset.tokens; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class EllaismTest extends AbstractAssetTest { + + public EllaismTest() { + super(new Ellaism()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("0x65767ec6d4d3d18a200842352485cdc37cbf3a21"); + assertValidAddress("65767ec6d4d3d18a200842352485cdc37cbf3a21"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("0x65767ec6d4d3d18a200842352485cdc37cbf3a216"); + assertInvalidAddress("0x65767ec6d4d3d18a200842352485cdc37cbf3a2g"); + assertInvalidAddress("65767ec6d4d3d18a200842352485cdc37cbf3a2g"); + } +} diff --git a/src/test/java/bisq/core/payment/validation/AbstractAltcoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AbstractAltcoinAddressValidatorTest.java index b61a8b5c..83df4e6b 100644 --- a/src/test/java/bisq/core/payment/validation/AbstractAltcoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AbstractAltcoinAddressValidatorTest.java @@ -2,26 +2,22 @@ import bisq.core.app.BisqEnvironment; import bisq.core.btc.BaseCurrencyNetwork; +import bisq.asset.AssetRegistry; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; -import org.jetbrains.annotations.NotNull; - import org.junit.Before; public abstract class AbstractAltcoinAddressValidatorTest { + protected AltCoinAddressValidator validator = new AltCoinAddressValidator(new AssetRegistry()); + @Before public void setup() { - final BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork(); - final String currencyCode = baseCurrencyNetwork.getCurrencyCode(); + BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork(); + String currencyCode = baseCurrencyNetwork.getCurrencyCode(); Res.setBaseCurrencyCode(currencyCode); Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName()); CurrencyUtil.setBaseCurrencyCode(currencyCode); } - - @NotNull - protected AltCoinAddressValidator getAltCoinAddressValidator() { - return new AltCoinAddressValidator(AssetProviderRegistry.getInstance()); - } } diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 07d4be2a..08cb23a2 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -26,7 +26,6 @@ public class AltCoinAddressValidatorTest extends AbstractAltcoinAddressValidator @Test public void testBTC() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("BTC"); assertTrue(validator.validate("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem").isValid); @@ -42,7 +41,6 @@ public void testBTC() { @Test public void testBSQ() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("BSQ"); assertTrue(validator.validate("B17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem").isValid); @@ -58,7 +56,6 @@ public void testBSQ() { @Test public void testLTC() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("LTC"); assertTrue(validator.validate("Lg3PX8wRWmApFCoCMAsPF5P9dPHYQHEWKW").isValid); @@ -73,7 +70,6 @@ public void testLTC() { @Test public void testDOGE() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("DOGE"); assertTrue(validator.validate("DEa7damK8MsbdCJztidBasZKVsDLJifWfE").isValid); @@ -88,7 +84,6 @@ public void testDOGE() { @Test public void testDASH() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("DASH"); assertTrue(validator.validate("XjNms118hx6dGyBqsrVMTbzMUmxDVijk7Y").isValid); @@ -103,7 +98,6 @@ public void testDASH() { @Test public void testETH() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ETH"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -117,7 +111,6 @@ public void testETH() { @Test public void testPIVX() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("PIVX"); assertTrue(validator.validate("DFJku78A14HYwPSzC5PtUmda7jMr5pbD2B").isValid); @@ -133,7 +126,6 @@ public void testPIVX() { @Test public void testIOP() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("IOP"); assertTrue(validator.validate("pKbz7iRUSiUaTgh4UuwQCnc6pWZnyCGWxM").isValid); @@ -145,7 +137,6 @@ public void testIOP() { @Test public void test888() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("888"); assertTrue(validator.validate("8TP9rh3SH6n9cSLmV22vnSNNw56LKGpLra").isValid); @@ -160,7 +151,6 @@ public void test888() { @Test public void testGBYTE() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("GBYTE"); assertTrue(validator.validate("BN7JXKXWEG4BVJ7NW6Q3Z7SMJNZJYM3G").isValid); @@ -174,7 +164,6 @@ public void testGBYTE() { @Test public void testNXT() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("NXT"); assertTrue(validator.validate("NXT-JM2U-U4AE-G7WF-3NP9F").isValid); @@ -192,7 +181,6 @@ public void testNXT() { // Added at 0.6.0 @Test public void testDCT() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("DCT"); assertTrue(validator.validate("ud6910c2790bda53bcc53cb131f8fa3bf").isValid); @@ -210,7 +198,6 @@ public void testDCT() { @Test public void testPNC() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("PNC"); assertTrue(validator.validate("3AB1qXhaU3hK5oAPQfwzN3QkM8LxAgL8vB").isValid); @@ -225,7 +212,6 @@ public void testPNC() { @Test public void testWAC() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("WAC"); assertTrue(validator.validate("WfEnB3VGrBqW7uamJMymymEwxMBYQKELKY").isValid); @@ -241,7 +227,6 @@ public void testWAC() { @Test public void testZEN() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ZEN"); assertTrue(validator.validate("znk62Ey7ptTyHgYLaLDTEwhLF6uN1DXTBfa").isValid); @@ -258,7 +243,6 @@ public void testZEN() { @Test public void testXCN() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("XCN"); assertTrue(validator.validate("CT49DTNo5itqYoAD6XTGyTKbe8z5nGY2D5").isValid); @@ -279,7 +263,6 @@ public void testXCN() { @Test public void testTRC() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("TRC"); assertTrue(validator.validate("1Bys8pZaKo4GTWcpArMg92cBgYqij8mKXt").isValid); @@ -298,7 +281,6 @@ public void testTRC() { @Test public void testINXT() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("INXT"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -312,7 +294,6 @@ public void testINXT() { @Test public void testPART() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("PART"); assertTrue(validator.validate("PZdYWHgyhuG7NHVCzEkkx3dcLKurTpvmo6").isValid); assertTrue(validator.validate("RJAPhgckEgRGVPZa9WoGSWW24spskSfLTQ").isValid); @@ -328,7 +309,6 @@ public void testPART() { // Added 0.6.1 @Test public void testMDC() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("MDC"); assertTrue(validator.validate("mHUisRLQ4vMXrWrVfGfiEHuD3KZqiUNvzH").isValid); @@ -342,7 +322,6 @@ public void testMDC() { @Test public void testBCHC() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("BCHC"); assertTrue(validator.validate("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSH").isValid); @@ -357,7 +336,6 @@ public void testBCHC() { @Test public void testBTG() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("BTG"); assertTrue(validator.validate("AehvQ57Fp168uY592LCUYBbyNEpiRAPufb").isValid); @@ -373,7 +351,6 @@ public void testBTG() { // Added 0.6.2 @Test public void testCAGE() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("CAGE"); assertTrue(validator.validate("Db97PgfdBDhXk8DmrDhrUPyydTCELn8YSb").isValid); @@ -389,7 +366,6 @@ public void testCAGE() { @Test public void testCRED() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("CRED"); assertTrue(validator.validate("0x65767ec6d4d3d18a200842352485cdc37cbf3a21").isValid); @@ -403,7 +379,6 @@ public void testCRED() { @Test public void testXSPEC() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("XSPEC"); assertTrue(validator.validate("SUZRHjTLSCr581qLsGqMqBD5f3oW2JHckn").isValid); @@ -419,7 +394,6 @@ public void testXSPEC() { // Added 0.6.3 @Test public void testWILD() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("WILD"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -433,7 +407,6 @@ public void testWILD() { @Test public void testONION() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ONION"); assertTrue(validator.validate("DbkkqXwdiWJNcpfw49f2xzTVEbvL1SYWDm").isValid); @@ -449,7 +422,6 @@ public void testONION() { // Added 0.6.4 @Test public void testCREA() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("CREA"); assertTrue(validator.validate("CGjh99QdHxCE6g9pGUucCJNeUyQPRJr4fE").isValid); @@ -464,7 +436,6 @@ public void testCREA() { @Test public void testXIN() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("XIN"); assertTrue(validator.validate("XIN-FXFA-LR6Y-QZAW-9V4SX").isValid); @@ -487,7 +458,6 @@ public void testXIN() { // Added 0.6.5 @Test public void testBETR() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("BETR"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -501,7 +471,6 @@ public void testBETR() { @Test public void testMVT() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("MVT"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -515,7 +484,6 @@ public void testMVT() { @Test public void testREF() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("REF"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -530,7 +498,6 @@ public void testREF() { // Added 0.6.6 @Test public void testSTL() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("STL"); assertTrue(validator.validate("Se3x7sVdvUnMMn2KoYLyYVHMJGRoB2R3V8K3LYuHAiEXgVac7vsmFiXUC8dSpJnjXDfwytKsQJV6HFH8MjwPagTJ2Aha46RZM").isValid); @@ -544,7 +511,6 @@ public void testSTL() { @Test public void testDAI() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("DAI"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -558,7 +524,6 @@ public void testDAI() { @Test public void testYTN() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("YTN"); assertTrue(validator.validate("YTgSv7bk5x5p6te3uf3HbUwgnf7zEJM4Jn").isValid); assertTrue(validator.validate("YVz19KtQUfyTP4AJS8sbRBqi7dkGTL2ovd").isValid); @@ -574,7 +539,6 @@ public void testYTN() { @Test public void testDARX() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("DARX"); assertTrue(validator.validate("RN8spHmkV6ZtRsquaTJMRZJujRQkkDNh2G").isValid); @@ -588,7 +552,6 @@ public void testDARX() { @Test public void testODN() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ODN"); assertTrue(validator.validate("XEfyuzk8yTp5eA9eVUeCW2PFbCFtNb6Jgv").isValid); @@ -604,7 +567,6 @@ public void testODN() { @Test public void testCDT() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("CDT"); assertTrue(validator.validate("DM7BjopQ3bGYxSPZ4yhfttxqnDrEkyc3sw").isValid); @@ -622,7 +584,6 @@ public void testCDT() { @Test public void testDGM() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("DGM"); assertTrue(validator.validate("DvaAgcLKrno2AC7kYhHVDCrkhx2xHFpXUf").isValid); @@ -636,7 +597,6 @@ public void testDGM() { @Test public void testSCS() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("SCS"); assertTrue(validator.validate("SNrVzPaFVCQGH4Rdch2EuhoyeWMfgWqk1J").isValid); @@ -652,7 +612,6 @@ public void testSCS() { @Test public void testSOS() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("SOS"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -666,7 +625,6 @@ public void testSOS() { @Test public void testACH() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ACH"); assertTrue(validator.validate("AciV7ZyJDpCg7kGGmbo97VjgjpVZkXRTMD").isValid); @@ -681,7 +639,6 @@ public void testACH() { @Test public void testVDN() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("VDN"); assertTrue(validator.validate("DG1KpSsSXd3uitgwHaA1i6T1Bj1hWEwAxB").isValid); @@ -700,7 +657,6 @@ public void testVDN() { // Added 0.7.0 @Test public void testALC() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ALC"); assertTrue(validator.validate("AQJTNtWcP7opxuR52Lf5vmoQTC8EHQ6GxV").isValid); @@ -716,7 +672,6 @@ public void testALC() { @Test public void testDIN() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("DIN"); assertTrue(validator.validate("DBmvak2TM8GpeiR3ZEVWAHWFZeiw9FG7jK").isValid); @@ -732,7 +687,6 @@ public void testDIN() { @Test public void testStraya() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("NAH"); assertTrue(validator.validate("SZHa3vS9ctDJwx3BziaqgN3zQMkYpgyP7f").isValid); @@ -748,7 +702,6 @@ public void testStraya() { @Test public void testROI() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ROI"); assertTrue(validator.validate("RSdzB2mFpQ6cR3HmEopbaRBjrEMWAwXBYn").isValid); @@ -763,7 +716,6 @@ public void testROI() { @Test public void testWMCC() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("WMCC"); assertTrue(validator.validate("wc1qke2es507uz0dcfx7eyvlfuemwys8xem48vp5rw").isValid); @@ -782,7 +734,6 @@ public void testWMCC() { @Test public void testRTO() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("RTO"); assertTrue(validator.validate("AHT1tiauD1GKvLnSL2RVuug1arn3cvFYw7PX5cUmCkM9MHuBn8yrGoHGHXP8ZV9FUR5Y5ntvhanwCMp8FK5bmLrqKxq7BRj").isValid); @@ -796,7 +747,6 @@ public void testRTO() { @Test public void testKOTO() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("KOTO"); assertTrue(validator.validate("k13dNgJJjf1SCU2Xv2jLnuUb5Q7zZx7P9vW").isValid); @@ -813,7 +763,6 @@ public void testKOTO() { @Test public void testUBQ() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("UBQ"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -827,7 +776,6 @@ public void testUBQ() { @Test public void testQWARK() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("QWARK"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -841,7 +789,6 @@ public void testQWARK() { @Test public void testGEO() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("GEO"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -855,7 +802,6 @@ public void testGEO() { @Test public void testGRANS() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("GRANS"); assertTrue(validator.validate("0x2a65Aca4D5fC5B5C859090a6c34d164135398226").isValid); @@ -869,7 +815,6 @@ public void testGRANS() { @Test public void testICH() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("ICH"); assertTrue(validator.validate("AYx4EqKhomeMu2CTMx1AHdNMkjv6ygnvji").isValid); @@ -888,7 +833,6 @@ public void testICH() { @Test public void testPHR() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); validator.setCurrencyCode("PHR"); assertTrue(validator.validate("PJCKDPyvfbf1yV7mYNeJ8Zb47hKRwVPYDj").isValid); diff --git a/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAssetProviderTest.java b/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAssetProviderTest.java deleted file mode 100644 index ab84c4bc..00000000 --- a/src/test/java/bisq/core/payment/validation/altcoins/bch/BchAssetProviderTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package bisq.core.payment.validation.altcoins.bch; - -import bisq.core.payment.validation.AbstractAltcoinAddressValidatorTest; -import bisq.core.payment.validation.AltCoinAddressValidator; - -import org.junit.Test; - -import static junit.framework.TestCase.assertFalse; -import static org.junit.Assert.assertTrue; - -public class BchAssetProviderTest extends AbstractAltcoinAddressValidatorTest { - - @Test - public void testBCH() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); - validator.setCurrencyCode("BCH"); - - assertTrue(validator.validate("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSH").isValid); - assertTrue(validator.validate("1MEbUJ5v5MdDEqFJGz4SZp58KkaLdmXZ85").isValid); - assertTrue(validator.validate("34dvotXMg5Gxc37TBVV2e5GUAfCFu7Ms4g").isValid); - - assertFalse(validator.validate("21HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSHa").isValid); - assertFalse(validator.validate("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSHs").isValid); - assertFalse(validator.validate("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSH#").isValid); - assertFalse(validator.validate("").isValid); - } - -} diff --git a/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProviderTest.java b/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProviderTest.java deleted file mode 100644 index b136fe70..00000000 --- a/src/test/java/bisq/core/payment/validation/altcoins/ella/EllaAssetProviderTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package bisq.core.payment.validation.altcoins.ella; - -import bisq.core.payment.validation.AbstractAltcoinAddressValidatorTest; -import bisq.core.payment.validation.AltCoinAddressValidator; - -import org.junit.Test; - -import static junit.framework.TestCase.assertFalse; -import static org.junit.Assert.assertTrue; - -public class EllaAssetProviderTest extends AbstractAltcoinAddressValidatorTest { - - @Test - public void testELLA() { - AltCoinAddressValidator validator = getAltCoinAddressValidator(); - validator.setCurrencyCode("ELLA"); - - assertTrue(validator.validate("0x65767ec6d4d3d18a200842352485cdc37cbf3a21").isValid); - assertTrue(validator.validate("65767ec6d4d3d18a200842352485cdc37cbf3a21").isValid); - - assertFalse(validator.validate("0x65767ec6d4d3d18a200842352485cdc37cbf3a216").isValid); - assertFalse(validator.validate("0x65767ec6d4d3d18a200842352485cdc37cbf3a2g").isValid); - assertFalse(validator.validate("65767ec6d4d3d18a200842352485cdc37cbf3a2g").isValid); - assertFalse(validator.validate("").isValid); - } - -} From 90262008a5c7abc16797f308fd4912b377888608 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 27 Mar 2018 15:04:13 +0200 Subject: [PATCH 007/106] Extract BSQ --- src/main/java/bisq/asset/coins/BSQ.java | 76 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 14 +++- .../validation/AltCoinAddressValidator.java | 22 ------ .../META-INF/services/bisq.asset.Asset | 3 + src/test/java/bisq/asset/coins/BSQTest.java | 27 +++++++ .../AltCoinAddressValidatorTest.java | 2 + 6 files changed, 118 insertions(+), 26 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/BSQ.java create mode 100644 src/test/java/bisq/asset/coins/BSQTest.java diff --git a/src/main/java/bisq/asset/coins/BSQ.java b/src/main/java/bisq/asset/coins/BSQ.java new file mode 100644 index 00000000..86f39f6e --- /dev/null +++ b/src/main/java/bisq/asset/coins/BSQ.java @@ -0,0 +1,76 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; + +import org.bitcoinj.core.NetworkParameters; +import org.bitcoinj.params.MainNetParams; +import org.bitcoinj.params.RegTestParams; +import org.bitcoinj.params.TestNet3Params; + +public class BSQ extends Coin { + + public BSQ(Network network, NetworkParameters networkParameters) { + super("BSQ", "BSQ", new BSQAddressValidator(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 BSQAddressValidator extends Base58BitcoinAddressValidator { + + public BSQAddressValidator(NetworkParameters networkParameters) { + super(networkParameters); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.startsWith("B")) + return AddressValidationResult.invalidAddress("BSQ address must start with 'B'"); + + String addressAsBtc = address.substring(1, address.length()); + + return super.validate(addressAsBtc); + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 29432d0a..b2ff7da5 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -17,9 +17,12 @@ package bisq.core.locale; +import bisq.core.app.BisqEnvironment; + import bisq.asset.Asset; import bisq.asset.AssetRegistry; import bisq.asset.Token; +import bisq.asset.coins.BSQ; import bisq.common.app.DevEnv; @@ -100,13 +103,11 @@ public static List getAllSortedCryptoCurrencies() { private static List createAllSortedCryptoCurrenciesList() { List result = assetRegistry.stream() .filter(CurrencyUtil::assetIsNotBaseCurrency) + .filter(CurrencyUtil::excludeBsqUnlessDaoTradingIsActive) .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); result.add(new CryptoCurrency("BETR", "Better Betting", true)); - if (DevEnv.DAO_TRADING_ACTIVATED) - result.add(new CryptoCurrency("BSQ", "Bisq Token")); - result.add(new CryptoCurrency("BCHC", "Bitcoin Clashic")); result.add(new CryptoCurrency("BTG", "Bitcoin Gold")); result.add(new CryptoCurrency("BURST", "Burstcoin")); @@ -213,7 +214,7 @@ private static List createAllSortedCryptoCurrenciesList() { public static List getMainCryptoCurrencies() { final List result = new ArrayList<>(); if (DevEnv.DAO_TRADING_ACTIVATED) - result.add(new CryptoCurrency("BSQ", "Bisq Token")); + result.add(new CryptoCurrency("BSQ", "BSQ")); if (!baseCurrencyCode.equals("BTC")) result.add(new CryptoCurrency("BTC", "Bitcoin")); if (!baseCurrencyCode.equals("DASH")) @@ -413,4 +414,9 @@ private static boolean assetIsNotBaseCurrency(Asset asset) { private static CryptoCurrency assetToCryptoCurrency(Asset asset) { return new CryptoCurrency(asset.getTickerSymbol(), asset.getName(), asset instanceof Token); } + + private static boolean excludeBsqUnlessDaoTradingIsActive(Asset asset) { + return (!(asset instanceof BSQ) || (DevEnv.DAO_TRADING_ACTIVATED + && ((BSQ) asset).getNetwork().name().equals(BisqEnvironment.getBaseCurrencyNetwork().getNetwork()))); + } } diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 708eaf7a..68c819ed 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -122,28 +122,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "BSQ": - if (!input.startsWith("B")) - return new ValidationResult(false, Res.get("validation.altcoin.invalidAddress", - currencyCode, "BSQ address must start with \"B\"")); - - String addressAsBtc = input.substring(1, input.length()); - try { - switch (BisqEnvironment.getBaseCurrencyNetwork()) { - case BTC_MAINNET: - Address.fromBase58(MainNetParams.get(), addressAsBtc); - break; - case BTC_TESTNET: - Address.fromBase58(TestNet3Params.get(), addressAsBtc); - break; - case BTC_REGTEST: - Address.fromBase58(RegTestParams.get(), addressAsBtc); - break; - } - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } case "LTC": try { switch (BisqEnvironment.getBaseCurrencyNetwork()) { diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 6fd2351b..0d0281c9 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -1,3 +1,6 @@ +bisq.asset.coins.BSQ$Mainnet +bisq.asset.coins.BSQ$Regtest +bisq.asset.coins.BSQ$Testnet bisq.asset.coins.Bitcoin$Mainnet bisq.asset.coins.Bitcoin$Regtest bisq.asset.coins.Bitcoin$Testnet diff --git a/src/test/java/bisq/asset/coins/BSQTest.java b/src/test/java/bisq/asset/coins/BSQTest.java new file mode 100644 index 00000000..de81898c --- /dev/null +++ b/src/test/java/bisq/asset/coins/BSQTest.java @@ -0,0 +1,27 @@ +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class BSQTest extends AbstractAssetTest { + + public BSQTest() { + super(new BSQ.Mainnet()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("B17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem"); + assertValidAddress("B3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX"); + assertValidAddress("B1111111111111111111114oLvT2"); + assertValidAddress("B1BitcoinEaterAddressDontSendf59kuE"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("B17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq"); + assertInvalidAddress("B17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYheO"); + assertInvalidAddress("B17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhek#"); + } +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 08cb23a2..aebf6e39 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -17,6 +17,7 @@ package bisq.core.payment.validation; +import org.junit.Ignore; import org.junit.Test; import static junit.framework.TestCase.assertFalse; @@ -40,6 +41,7 @@ public void testBTC() { } @Test + @Ignore public void testBSQ() { validator.setCurrencyCode("BSQ"); From 9fbed62a3eb9b12b5bb538e4451b3923d97c78d8 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 27 Mar 2018 12:51:21 +0200 Subject: [PATCH 008/106] Extract Litecoin --- src/main/java/bisq/asset/coins/Litecoin.java | 58 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 2 - .../validation/AltCoinAddressValidator.java | 26 --------- .../META-INF/services/bisq.asset.Asset | 3 + .../java/bisq/asset/coins/LitecoinTest.java | 26 +++++++++ 5 files changed, 87 insertions(+), 28 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Litecoin.java create mode 100644 src/test/java/bisq/asset/coins/LitecoinTest.java diff --git a/src/main/java/bisq/asset/coins/Litecoin.java b/src/main/java/bisq/asset/coins/Litecoin.java new file mode 100644 index 00000000..f77d2f09 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Litecoin.java @@ -0,0 +1,58 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; + +import org.libdohj.params.LitecoinMainNetParams; +import org.libdohj.params.LitecoinRegTestParams; +import org.libdohj.params.LitecoinTestNet3Params; + +import org.bitcoinj.core.NetworkParameters; + +public abstract class Litecoin extends Coin { + + public Litecoin(Network network, NetworkParameters networkParameters) { + super("Litecoin", "LTC", new Base58BitcoinAddressValidator(networkParameters), network); + } + + + public static class Mainnet extends Litecoin { + + public Mainnet() { + super(Network.MAINNET, LitecoinMainNetParams.get()); + } + } + + + public static class Testnet extends Litecoin { + + public Testnet() { + super(Network.TESTNET, LitecoinTestNet3Params.get()); + } + } + + + public static class Regtest extends Litecoin { + + public Regtest() { + super(Network.REGTEST, LitecoinRegTestParams.get()); + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index b2ff7da5..eb8d76d6 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -132,8 +132,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("GRC", "Gridcoin")); result.add(new CryptoCurrency("LBC", "LBRY Credits")); result.add(new CryptoCurrency("LSK", "Lisk")); - if (!baseCurrencyCode.equals("LTC")) - result.add(new CryptoCurrency("LTC", "Litecoin")); result.add(new CryptoCurrency("MAID", "MaidSafeCoin")); result.add(new CryptoCurrency("MDC", "Madcoin")); result.add(new CryptoCurrency("XMR", "Monero")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 68c819ed..3d7e6e67 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -58,9 +58,6 @@ import org.libdohj.params.DashRegTestParams; import org.libdohj.params.DashTestNet3Params; import org.libdohj.params.DogecoinMainNetParams; -import org.libdohj.params.LitecoinMainNetParams; -import org.libdohj.params.LitecoinRegTestParams; -import org.libdohj.params.LitecoinTestNet3Params; import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; @@ -122,29 +119,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "LTC": - try { - switch (BisqEnvironment.getBaseCurrencyNetwork()) { - case BTC_MAINNET: - case BTC_TESTNET: - case BTC_REGTEST: - case DASH_MAINNET: - case DASH_TESTNET: - case DASH_REGTEST: - case LTC_MAINNET: - Address.fromBase58(LitecoinMainNetParams.get(), input); - break; - case LTC_TESTNET: - Address.fromBase58(LitecoinTestNet3Params.get(), input); - break; - case LTC_REGTEST: - Address.fromBase58(LitecoinRegTestParams.get(), input); - break; - } - return new InputValidator.ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } case "DOGE": try { Address.fromBase58(DogecoinMainNetParams.get(), input); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 0d0281c9..059c5f65 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -7,4 +7,7 @@ bisq.asset.coins.Bitcoin$Testnet bisq.asset.coins.BitcoinCash bisq.asset.coins.Ether bisq.asset.coins.Instacash +bisq.asset.coins.Litecoin$Mainnet +bisq.asset.coins.Litecoin$Regtest +bisq.asset.coins.Litecoin$Testnet bisq.asset.tokens.Ellaism diff --git a/src/test/java/bisq/asset/coins/LitecoinTest.java b/src/test/java/bisq/asset/coins/LitecoinTest.java new file mode 100644 index 00000000..0fc62692 --- /dev/null +++ b/src/test/java/bisq/asset/coins/LitecoinTest.java @@ -0,0 +1,26 @@ +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class LitecoinTest extends AbstractAssetTest { + + public LitecoinTest() { + super(new Litecoin.Mainnet()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("Lg3PX8wRWmApFCoCMAsPF5P9dPHYQHEWKW"); + assertValidAddress("LTuoeY6RBHV3n3cfhXVVTbJbxzxnXs9ofm"); + assertValidAddress("LgfapHEPhZbRF9pMd5WPT35hFXcZS1USrW"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("1LgfapHEPhZbRF9pMd5WPT35hFXcZS1USrW"); + assertInvalidAddress("LgfapHEPhZbdRF9pMd5WPT35hFXcZS1USrW"); + assertInvalidAddress("LgfapHEPhZbRF9pMd5WPT35hFXcZS1USrW#"); + } +} From c2c7e40c4bb5240930458154913cbe33ef983675 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 27 Mar 2018 13:03:49 +0200 Subject: [PATCH 009/106] Extract Dogecoin --- src/main/java/bisq/asset/coins/Dogecoin.java | 30 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 8 ----- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/DogecoinTest.java | 26 ++++++++++++++++ 5 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Dogecoin.java create mode 100644 src/test/java/bisq/asset/coins/DogecoinTest.java diff --git a/src/main/java/bisq/asset/coins/Dogecoin.java b/src/main/java/bisq/asset/coins/Dogecoin.java new file mode 100644 index 00000000..159803e1 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Dogecoin.java @@ -0,0 +1,30 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; + +import org.libdohj.params.DogecoinMainNetParams; + +public class Dogecoin extends Coin { + + public Dogecoin() { + super("Dogecoin", "DOGE", new Base58BitcoinAddressValidator(DogecoinMainNetParams.get())); + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index eb8d76d6..304330b8 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -122,7 +122,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("DCT", "DECENT")); result.add(new CryptoCurrency("DCR", "Decred")); result.add(new CryptoCurrency("ONION", "DeepOnion")); - result.add(new CryptoCurrency("DOGE", "Dogecoin")); result.add(new CryptoCurrency("DMC", "DynamicCoin")); result.add(new CryptoCurrency("ESP", "Espers")); result.add(new CryptoCurrency("ETC", "Ether Classic")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 3d7e6e67..33f71cdd 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -57,7 +57,6 @@ import org.libdohj.params.DashMainNetParams; import org.libdohj.params.DashRegTestParams; import org.libdohj.params.DashTestNet3Params; -import org.libdohj.params.DogecoinMainNetParams; import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; @@ -119,13 +118,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "DOGE": - try { - Address.fromBase58(DogecoinMainNetParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } case "DASH": try { switch (BisqEnvironment.getBaseCurrencyNetwork()) { diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 059c5f65..d622730c 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -5,6 +5,7 @@ bisq.asset.coins.Bitcoin$Mainnet bisq.asset.coins.Bitcoin$Regtest bisq.asset.coins.Bitcoin$Testnet bisq.asset.coins.BitcoinCash +bisq.asset.coins.Dogecoin bisq.asset.coins.Ether bisq.asset.coins.Instacash bisq.asset.coins.Litecoin$Mainnet diff --git a/src/test/java/bisq/asset/coins/DogecoinTest.java b/src/test/java/bisq/asset/coins/DogecoinTest.java new file mode 100644 index 00000000..d3664494 --- /dev/null +++ b/src/test/java/bisq/asset/coins/DogecoinTest.java @@ -0,0 +1,26 @@ +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class DogecoinTest extends AbstractAssetTest { + + public DogecoinTest() { + super(new Dogecoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("DEa7damK8MsbdCJztidBasZKVsDLJifWfE"); + assertValidAddress("DNkkfdUvkCDiywYE98MTVp9nQJTgeZAiFr"); + assertValidAddress("DDWUYQ3GfMDj8hkx8cbnAMYkTzzAunAQxg"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("1DDWUYQ3GfMDj8hkx8cbnAMYkTzzAunAQxg"); + assertInvalidAddress("DDWUYQ3GfMDj8hkx8cbnAMYkTzzAunAQxgs"); + assertInvalidAddress("DDWUYQ3GfMDj8hkx8cbnAMYkTzzAunAQxg#"); + } +} From bd379961e4f5cabce6052ec8a27980025fd9a97c Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 27 Mar 2018 13:10:49 +0200 Subject: [PATCH 010/106] Extract Dash --- src/main/java/bisq/asset/coins/Dash.java | 58 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 2 - .../validation/AltCoinAddressValidator.java | 27 --------- .../META-INF/services/bisq.asset.Asset | 4 ++ src/test/java/bisq/asset/coins/DashTest.java | 27 +++++++++ 5 files changed, 89 insertions(+), 29 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Dash.java create mode 100644 src/test/java/bisq/asset/coins/DashTest.java diff --git a/src/main/java/bisq/asset/coins/Dash.java b/src/main/java/bisq/asset/coins/Dash.java new file mode 100644 index 00000000..3f9b7941 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Dash.java @@ -0,0 +1,58 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; + +import org.libdohj.params.DashMainNetParams; +import org.libdohj.params.DashRegTestParams; +import org.libdohj.params.DashTestNet3Params; + +import org.bitcoinj.core.NetworkParameters; + +public abstract class Dash extends Coin { + + public Dash(Network network, NetworkParameters networkParameters) { + super("Dash", "DASH", new Base58BitcoinAddressValidator(networkParameters), network); + } + + + public static class Mainnet extends Dash { + + public Mainnet() { + super(Network.MAINNET, DashMainNetParams.get()); + } + } + + + public static class Testnet extends Dash { + + public Testnet() { + super(Network.TESTNET, DashTestNet3Params.get()); + } + } + + + public static class Regtest extends Dash { + + public Regtest() { + super(Network.REGTEST, DashRegTestParams.get()); + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 304330b8..4ba600b3 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -117,8 +117,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("CREA", "Creativecoin")); result.add(new CryptoCurrency("XCN", "Cryptonite")); result.add(new CryptoCurrency("DNET", "DarkNet")); - if (!baseCurrencyCode.equals("DASH")) - result.add(new CryptoCurrency("DASH", "Dash")); result.add(new CryptoCurrency("DCT", "DECENT")); result.add(new CryptoCurrency("DCR", "Decred")); result.add(new CryptoCurrency("ONION", "DeepOnion")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 33f71cdd..84d05290 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -54,10 +54,6 @@ import bisq.core.payment.validation.params.btc.BtcMainNetParamsForValidation; import bisq.core.util.validation.InputValidator; -import org.libdohj.params.DashMainNetParams; -import org.libdohj.params.DashRegTestParams; -import org.libdohj.params.DashTestNet3Params; - import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; import org.bitcoinj.core.Base58; @@ -118,29 +114,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "DASH": - try { - switch (BisqEnvironment.getBaseCurrencyNetwork()) { - case BTC_MAINNET: - case BTC_TESTNET: - case BTC_REGTEST: - case LTC_MAINNET: - case LTC_TESTNET: - case LTC_REGTEST: - case DASH_MAINNET: - Address.fromBase58(DashMainNetParams.get(), input); - break; - case DASH_TESTNET: - Address.fromBase58(DashTestNet3Params.get(), input); - break; - case DASH_REGTEST: - Address.fromBase58(DashRegTestParams.get(), input); - break; - } - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } case "PIVX": if (input.matches("^[D][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { //noinspection ConstantConditions diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index d622730c..deac8fcb 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -5,6 +5,9 @@ bisq.asset.coins.Bitcoin$Mainnet bisq.asset.coins.Bitcoin$Regtest bisq.asset.coins.Bitcoin$Testnet bisq.asset.coins.BitcoinCash +bisq.asset.coins.Dash$Mainnet +bisq.asset.coins.Dash$Regtest +bisq.asset.coins.Dash$Testnet bisq.asset.coins.Dogecoin bisq.asset.coins.Ether bisq.asset.coins.Instacash @@ -12,3 +15,4 @@ bisq.asset.coins.Litecoin$Mainnet bisq.asset.coins.Litecoin$Regtest bisq.asset.coins.Litecoin$Testnet bisq.asset.tokens.Ellaism + diff --git a/src/test/java/bisq/asset/coins/DashTest.java b/src/test/java/bisq/asset/coins/DashTest.java new file mode 100644 index 00000000..5c0ff657 --- /dev/null +++ b/src/test/java/bisq/asset/coins/DashTest.java @@ -0,0 +1,27 @@ +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class DashTest extends AbstractAssetTest { + + public DashTest() { + super(new Dash.Mainnet()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("XjNms118hx6dGyBqsrVMTbzMUmxDVijk7Y"); + assertValidAddress("XjNPzWfzGiY1jHUmwn9JDSVMsTs6EtZQMc"); + assertValidAddress("XnaJzoAKTNa67Fpt1tLxD5bFMcyN4tCvTT"); + + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("1XnaJzoAKTNa67Fpt1tLxD5bFMcyN4tCvTT"); + assertInvalidAddress("XnaJzoAKTNa67Fpt1tLxD5bFMcyN4tCvTTd"); + assertInvalidAddress("XnaJzoAKTNa67Fpt1tLxD5bFMcyN4tCvTT#"); + } +} From f07e13e3811cf2e44b5dd8c2838fccd02acd0254 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 27 Mar 2018 13:13:41 +0200 Subject: [PATCH 011/106] Remove unused imports --- .../bisq/core/payment/validation/AltCoinAddressValidator.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 84d05290..4628190b 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -57,9 +57,6 @@ import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; import org.bitcoinj.core.Base58; -import org.bitcoinj.params.MainNetParams; -import org.bitcoinj.params.RegTestParams; -import org.bitcoinj.params.TestNet3Params; import com.google.inject.Inject; From a08ac117dd177281bca8467b4947c17559cd6e2f Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 27 Mar 2018 13:28:21 +0200 Subject: [PATCH 012/106] Extract PIVX --- src/main/java/bisq/asset/coins/PIVX.java | 56 +++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 13 --- .../payment/validation/params/PivxParams.java | 93 ------------------- .../META-INF/services/bisq.asset.Asset | 2 +- src/test/java/bisq/asset/coins/PIVXTest.java | 27 ++++++ 6 files changed, 84 insertions(+), 108 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/PIVX.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/PivxParams.java create mode 100644 src/test/java/bisq/asset/coins/PIVXTest.java diff --git a/src/main/java/bisq/asset/coins/PIVX.java b/src/main/java/bisq/asset/coins/PIVX.java new file mode 100644 index 00000000..35f00ba3 --- /dev/null +++ b/src/main/java/bisq/asset/coins/PIVX.java @@ -0,0 +1,56 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class PIVX extends Coin { + + public PIVX() { + super("PIVX", "PIVX", new PIVXAddressValidator()); + } + + + public static class PIVXAddressValidator extends Base58BitcoinAddressValidator { + + public PIVXAddressValidator() { + super(new PIVXParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[D][a-km-zA-HJ-NP-Z1-9]{25,34}$")) + return AddressValidationResult.invalidStructure(); + + return super.validate(address); + } + } + + + public static class PIVXParams extends NetworkParametersAdapter { + + public PIVXParams() { + addressHeader = 30; + p2shHeader = 13; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 4ba600b3..3f180137 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -141,7 +141,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("PART", "Particl")); result.add(new CryptoCurrency("PASC", "Pascal Coin", true)); result.add(new CryptoCurrency("PEPECASH", "Pepe Cash")); - result.add(new CryptoCurrency("PIVX", "PIVX")); result.add(new CryptoCurrency("POST", "PostCoin")); result.add(new CryptoCurrency("PNC", "Pranacoin")); result.add(new CryptoCurrency("RDD", "ReddCoin")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 4628190b..21c939c6 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -43,7 +43,6 @@ import bisq.core.payment.validation.params.PARTParams; import bisq.core.payment.validation.params.PNCParams; import bisq.core.payment.validation.params.PhoreParams; -import bisq.core.payment.validation.params.PivxParams; import bisq.core.payment.validation.params.SpeedCashParams; import bisq.core.payment.validation.params.StrayaParams; import bisq.core.payment.validation.params.TerracoinParams; @@ -111,18 +110,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "PIVX": - if (input.matches("^[D][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { - //noinspection ConstantConditions - try { - Address.fromBase58(PivxParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } - } else { - return regexTestFailed; - } case "IOP": if (input.matches("^[p][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { //noinspection ConstantConditions diff --git a/src/main/java/bisq/core/payment/validation/params/PivxParams.java b/src/main/java/bisq/core/payment/validation/params/PivxParams.java deleted file mode 100644 index 7dd5ea15..00000000 --- a/src/main/java/bisq/core/payment/validation/params/PivxParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class PivxParams extends NetworkParameters { - - private static PivxParams instance; - - public static synchronized PivxParams get() { - if (instance == null) { - instance = new PivxParams(); - } - return instance; - } - - // We only use the properties needed for address validation - public PivxParams() { - super(); - addressHeader = 30; - p2shHeader = 13; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - // default dummy implementations, not used... - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index deac8fcb..7f9b7a3b 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -14,5 +14,5 @@ bisq.asset.coins.Instacash bisq.asset.coins.Litecoin$Mainnet bisq.asset.coins.Litecoin$Regtest bisq.asset.coins.Litecoin$Testnet +bisq.asset.coins.PIVX bisq.asset.tokens.Ellaism - diff --git a/src/test/java/bisq/asset/coins/PIVXTest.java b/src/test/java/bisq/asset/coins/PIVXTest.java new file mode 100644 index 00000000..172f539c --- /dev/null +++ b/src/test/java/bisq/asset/coins/PIVXTest.java @@ -0,0 +1,27 @@ +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class PIVXTest extends AbstractAssetTest { + + public PIVXTest() { + super(new PIVX()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("DFJku78A14HYwPSzC5PtUmda7jMr5pbD2B"); + assertValidAddress("DAeiBSH4nudXgoxS4kY6uhTPobc7ALrWDA"); + assertValidAddress("DRbnCYbuMXdKU4y8dya9EnocL47gFjErWe"); + assertValidAddress("DTPAqTryNRCE2FgsxzohTtJXfCBCDnG6Rc"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq"); + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYheO"); + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhek#"); + } +} From 22cd1b441b5137ca838a2a38a715667ad52a7cff Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 27 Mar 2018 13:38:52 +0200 Subject: [PATCH 013/106] Extract Internet of People --- .../bisq/asset/coins/InternetOfPeople.java | 57 ++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 13 --- .../payment/validation/params/IOPParams.java | 93 ------------------- .../META-INF/services/bisq.asset.Asset | 1 + .../asset/coins/InternetOfPeopleTest.java | 40 ++++++++ 6 files changed, 98 insertions(+), 107 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/InternetOfPeople.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/IOPParams.java create mode 100644 src/test/java/bisq/asset/coins/InternetOfPeopleTest.java diff --git a/src/main/java/bisq/asset/coins/InternetOfPeople.java b/src/main/java/bisq/asset/coins/InternetOfPeople.java new file mode 100644 index 00000000..126cb434 --- /dev/null +++ b/src/main/java/bisq/asset/coins/InternetOfPeople.java @@ -0,0 +1,57 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class InternetOfPeople extends Coin { + + public InternetOfPeople() { + super("Internet of People", "IOP", new InternetOfPeopleAddressValidator()); + } + + + public static class InternetOfPeopleAddressValidator extends Base58BitcoinAddressValidator { + + public InternetOfPeopleAddressValidator() { + super(new InternetOfPeopleParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[p][a-km-zA-HJ-NP-Z1-9]{25,34}$")) + return AddressValidationResult.invalidStructure(); + + return super.validate(address); + } + } + + + public static class InternetOfPeopleParams extends NetworkParametersAdapter { + + public InternetOfPeopleParams() { + super(); + addressHeader = 117; + p2shHeader = 174; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 3f180137..3ac85701 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -124,7 +124,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("ESP", "Espers")); result.add(new CryptoCurrency("ETC", "Ether Classic")); result.add(new CryptoCurrency("XIN", "Infinity Economics")); - result.add(new CryptoCurrency("IOP", "Internet Of People")); result.add(new CryptoCurrency("INXT", "Internext", true)); result.add(new CryptoCurrency("GRC", "Gridcoin")); result.add(new CryptoCurrency("LBC", "LBRY Credits")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 21c939c6..937555ce 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -36,7 +36,6 @@ import bisq.core.payment.validation.params.AlcParams; import bisq.core.payment.validation.params.CageParams; import bisq.core.payment.validation.params.CreaParams; -import bisq.core.payment.validation.params.IOPParams; import bisq.core.payment.validation.params.ODNParams; import bisq.core.payment.validation.params.OctocoinParams; import bisq.core.payment.validation.params.OnionParams; @@ -110,18 +109,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "IOP": - if (input.matches("^[p][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { - //noinspection ConstantConditions - try { - Address.fromBase58(IOPParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } - } else { - return regexTestFailed; - } case "888": if (input.matches("^[83][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { if (OctocoinAddressValidator.ValidateAddress(input)) { diff --git a/src/main/java/bisq/core/payment/validation/params/IOPParams.java b/src/main/java/bisq/core/payment/validation/params/IOPParams.java deleted file mode 100644 index b1f49e68..00000000 --- a/src/main/java/bisq/core/payment/validation/params/IOPParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class IOPParams extends NetworkParameters { - - private static IOPParams instance; - - public static synchronized IOPParams get() { - if (instance == null) { - instance = new IOPParams(); - } - return instance; - } - - // We only use the properties needed for address validation - public IOPParams() { - super(); - addressHeader = 117; - p2shHeader = 174; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - // default dummy implementations, not used... - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 7f9b7a3b..8fec078c 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -10,6 +10,7 @@ bisq.asset.coins.Dash$Regtest bisq.asset.coins.Dash$Testnet bisq.asset.coins.Dogecoin bisq.asset.coins.Ether +bisq.asset.coins.InternetOfPeople bisq.asset.coins.Instacash bisq.asset.coins.Litecoin$Mainnet bisq.asset.coins.Litecoin$Regtest diff --git a/src/test/java/bisq/asset/coins/InternetOfPeopleTest.java b/src/test/java/bisq/asset/coins/InternetOfPeopleTest.java new file mode 100644 index 00000000..d6076798 --- /dev/null +++ b/src/test/java/bisq/asset/coins/InternetOfPeopleTest.java @@ -0,0 +1,40 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class InternetOfPeopleTest extends AbstractAssetTest { + + public InternetOfPeopleTest() { + super(new InternetOfPeople()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("pKbz7iRUSiUaTgh4UuwQCnc6pWZnyCGWxM"); + assertValidAddress("pAubDQFjUMaR93V4RjHYFh1YW1dzJ9YPW1"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem"); + } +} From df0931ed7352fce6b9c07dda3ea15414f9c37524 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 27 Mar 2018 13:39:07 +0200 Subject: [PATCH 014/106] Add missing license headers --- src/test/java/bisq/asset/coins/BSQTest.java | 17 +++++++++++++++++ .../java/bisq/asset/coins/BitcoinCashTest.java | 17 +++++++++++++++++ src/test/java/bisq/asset/coins/BitcoinTest.java | 17 +++++++++++++++++ src/test/java/bisq/asset/coins/DashTest.java | 17 +++++++++++++++++ .../java/bisq/asset/coins/DogecoinTest.java | 17 +++++++++++++++++ .../java/bisq/asset/coins/InstacashTest.java | 17 +++++++++++++++++ .../java/bisq/asset/coins/LitecoinTest.java | 17 +++++++++++++++++ src/test/java/bisq/asset/coins/PIVXTest.java | 17 +++++++++++++++++ .../java/bisq/asset/tokens/EllaismTest.java | 17 +++++++++++++++++ 9 files changed, 153 insertions(+) diff --git a/src/test/java/bisq/asset/coins/BSQTest.java b/src/test/java/bisq/asset/coins/BSQTest.java index de81898c..9bb9764b 100644 --- a/src/test/java/bisq/asset/coins/BSQTest.java +++ b/src/test/java/bisq/asset/coins/BSQTest.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.coins; import bisq.asset.AbstractAssetTest; diff --git a/src/test/java/bisq/asset/coins/BitcoinCashTest.java b/src/test/java/bisq/asset/coins/BitcoinCashTest.java index 68b8f2f0..fac081a3 100644 --- a/src/test/java/bisq/asset/coins/BitcoinCashTest.java +++ b/src/test/java/bisq/asset/coins/BitcoinCashTest.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.coins; import bisq.asset.AbstractAssetTest; diff --git a/src/test/java/bisq/asset/coins/BitcoinTest.java b/src/test/java/bisq/asset/coins/BitcoinTest.java index 5f3dee7c..bad08da8 100644 --- a/src/test/java/bisq/asset/coins/BitcoinTest.java +++ b/src/test/java/bisq/asset/coins/BitcoinTest.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.coins; import bisq.asset.AbstractAssetTest; diff --git a/src/test/java/bisq/asset/coins/DashTest.java b/src/test/java/bisq/asset/coins/DashTest.java index 5c0ff657..dd677c94 100644 --- a/src/test/java/bisq/asset/coins/DashTest.java +++ b/src/test/java/bisq/asset/coins/DashTest.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.coins; import bisq.asset.AbstractAssetTest; diff --git a/src/test/java/bisq/asset/coins/DogecoinTest.java b/src/test/java/bisq/asset/coins/DogecoinTest.java index d3664494..9351a877 100644 --- a/src/test/java/bisq/asset/coins/DogecoinTest.java +++ b/src/test/java/bisq/asset/coins/DogecoinTest.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.coins; import bisq.asset.AbstractAssetTest; diff --git a/src/test/java/bisq/asset/coins/InstacashTest.java b/src/test/java/bisq/asset/coins/InstacashTest.java index 0309ae2d..aea01bff 100644 --- a/src/test/java/bisq/asset/coins/InstacashTest.java +++ b/src/test/java/bisq/asset/coins/InstacashTest.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.coins; import bisq.asset.AbstractAssetTest; diff --git a/src/test/java/bisq/asset/coins/LitecoinTest.java b/src/test/java/bisq/asset/coins/LitecoinTest.java index 0fc62692..7da7f375 100644 --- a/src/test/java/bisq/asset/coins/LitecoinTest.java +++ b/src/test/java/bisq/asset/coins/LitecoinTest.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.coins; import bisq.asset.AbstractAssetTest; diff --git a/src/test/java/bisq/asset/coins/PIVXTest.java b/src/test/java/bisq/asset/coins/PIVXTest.java index 172f539c..a9092c40 100644 --- a/src/test/java/bisq/asset/coins/PIVXTest.java +++ b/src/test/java/bisq/asset/coins/PIVXTest.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.coins; import bisq.asset.AbstractAssetTest; diff --git a/src/test/java/bisq/asset/tokens/EllaismTest.java b/src/test/java/bisq/asset/tokens/EllaismTest.java index 4337710d..c98ae2c8 100644 --- a/src/test/java/bisq/asset/tokens/EllaismTest.java +++ b/src/test/java/bisq/asset/tokens/EllaismTest.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.tokens; import bisq.asset.AbstractAssetTest; From 981ca38eff1a2e67bf33bb5eb121fc1943f10358 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 27 Mar 2018 13:54:28 +0200 Subject: [PATCH 015/106] Extract Octocoin Note that the existing OctocoinAddressValidator was nothing more than a copied and pasted Base58 bitcoin address validator (identical to PNCAddressValidator, incidentally, which will also be deleted when we extract PNC). --- src/main/java/bisq/asset/coins/Octocoin.java | 56 +++++++++++ .../validation/AltCoinAddressValidator.java | 17 ---- .../altcoins/OctocoinAddressValidator.java | 65 ------------- .../validation/params/OctocoinParams.java | 93 ------------------- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/OctocoinTest.java | 43 +++++++++ 6 files changed, 100 insertions(+), 175 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Octocoin.java delete mode 100644 src/main/java/bisq/core/payment/validation/altcoins/OctocoinAddressValidator.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/OctocoinParams.java create mode 100644 src/test/java/bisq/asset/coins/OctocoinTest.java diff --git a/src/main/java/bisq/asset/coins/Octocoin.java b/src/main/java/bisq/asset/coins/Octocoin.java new file mode 100644 index 00000000..6801c242 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Octocoin.java @@ -0,0 +1,56 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class Octocoin extends Coin { + + public Octocoin() { + super("Octocoin", "888", new OctocoinAddressValidator()); + } + + + public static class OctocoinAddressValidator extends Base58BitcoinAddressValidator { + + public OctocoinAddressValidator() { + super(new OctocoinParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[83][a-km-zA-HJ-NP-Z1-9]{25,34}$")) + return AddressValidationResult.invalidStructure(); + + return super.validate(address); + } + } + + + public static class OctocoinParams extends NetworkParametersAdapter { + + public OctocoinParams() { + addressHeader = 18; + p2shHeader = 5; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 937555ce..146ff76d 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -27,7 +27,6 @@ import bisq.core.payment.validation.altcoins.ByteballAddressValidator; import bisq.core.payment.validation.altcoins.KOTOAddressValidator; import bisq.core.payment.validation.altcoins.NxtReedSolomonValidator; -import bisq.core.payment.validation.altcoins.OctocoinAddressValidator; import bisq.core.payment.validation.altcoins.PNCAddressValidator; import bisq.core.payment.validation.altcoins.WMCCAddressValidator; import bisq.core.payment.validation.altcoins.XCNAddressValidator; @@ -37,7 +36,6 @@ import bisq.core.payment.validation.params.CageParams; import bisq.core.payment.validation.params.CreaParams; import bisq.core.payment.validation.params.ODNParams; -import bisq.core.payment.validation.params.OctocoinParams; import bisq.core.payment.validation.params.OnionParams; import bisq.core.payment.validation.params.PARTParams; import bisq.core.payment.validation.params.PNCParams; @@ -109,21 +107,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "888": - if (input.matches("^[83][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { - if (OctocoinAddressValidator.ValidateAddress(input)) { - try { - Address.fromBase58(OctocoinParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } - } else { - return wrongChecksum; - } - } else { - return regexTestFailed; - } case "ZEC": // We only support t addresses (transparent transactions) if (input.startsWith("t")) diff --git a/src/main/java/bisq/core/payment/validation/altcoins/OctocoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/altcoins/OctocoinAddressValidator.java deleted file mode 100644 index c5f9cbb5..00000000 --- a/src/main/java/bisq/core/payment/validation/altcoins/OctocoinAddressValidator.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.altcoins; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import java.util.Arrays; - -public class OctocoinAddressValidator { - private final static String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; - - public static boolean ValidateAddress(String addr) { - if (addr.length() < 26 || addr.length() > 35) return false; - byte[] decoded = decodeBase58(addr, 58, 25); - if (decoded == null) return false; - - byte[] hash = getSha256(decoded, 0, 21, 2); - return hash != null && Arrays.equals(Arrays.copyOfRange(hash, 0, 4), Arrays.copyOfRange(decoded, 21, 25)); - } - - private static byte[] decodeBase58(String input, int base, int len) { - byte[] output = new byte[len]; - for (int i = 0; i < input.length(); i++) { - char t = input.charAt(i); - - int p = ALPHABET.indexOf(t); - if (p == -1) return null; - for (int j = len - 1; j >= 0; j--, p /= 256) { - p += base * (output[j] & 0xFF); - output[j] = (byte) (p % 256); - } - if (p != 0) return null; - } - - return output; - } - - private static byte[] getSha256(byte[] data, int start, int len, int recursion) { - if (recursion == 0) return data; - - try { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - md.update(Arrays.copyOfRange(data, start, start + len)); - return getSha256(md.digest(), 0, 32, recursion - 1); - } catch (NoSuchAlgorithmException e) { - return null; - } - } -} diff --git a/src/main/java/bisq/core/payment/validation/params/OctocoinParams.java b/src/main/java/bisq/core/payment/validation/params/OctocoinParams.java deleted file mode 100644 index ac000e15..00000000 --- a/src/main/java/bisq/core/payment/validation/params/OctocoinParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class OctocoinParams extends NetworkParameters { - - private static OctocoinParams instance; - - public static synchronized OctocoinParams get() { - if (instance == null) { - instance = new OctocoinParams(); - } - return instance; - } - - // We only use the properties needed for address validation - public OctocoinParams() { - super(); - addressHeader = 18; - p2shHeader = 5; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - // default dummy implementations, not used... - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 8fec078c..9607006c 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -15,5 +15,6 @@ bisq.asset.coins.Instacash bisq.asset.coins.Litecoin$Mainnet bisq.asset.coins.Litecoin$Regtest bisq.asset.coins.Litecoin$Testnet +bisq.asset.coins.Octocoin bisq.asset.coins.PIVX bisq.asset.tokens.Ellaism diff --git a/src/test/java/bisq/asset/coins/OctocoinTest.java b/src/test/java/bisq/asset/coins/OctocoinTest.java new file mode 100644 index 00000000..23029c44 --- /dev/null +++ b/src/test/java/bisq/asset/coins/OctocoinTest.java @@ -0,0 +1,43 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class OctocoinTest extends AbstractAssetTest { + + public OctocoinTest() { + super(new Octocoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("8TP9rh3SH6n9cSLmV22vnSNNw56LKGpLra"); + assertValidAddress("37NwrYsD1HxQW5zfLTuQcUUXGMPvQgzTSn"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("1ANNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i"); + assertInvalidAddress("38NwrYsD1HxQW5zfLT0QcUUXGMPvQgzTSn"); + assertInvalidAddress("8tP9rh3SH6n9cSLmV22vnSNNw56LKGpLrB"); + assertInvalidAddress("8Zbvjr"); + } +} From 49b119d7620664f3ff5b92bf32fdf220dd5f63eb Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 10:29:55 +0200 Subject: [PATCH 016/106] Extract Zcash --- .../bisq/asset/AddressValidationResult.java | 8 +++- src/main/java/bisq/asset/coins/Zcash.java | 41 ++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 15 +++---- .../META-INF/services/bisq.asset.Asset | 1 + src/test/java/bisq/asset/coins/ZcashTest.java | 43 +++++++++++++++++++ 6 files changed, 96 insertions(+), 13 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Zcash.java create mode 100644 src/test/java/bisq/asset/coins/ZcashTest.java diff --git a/src/main/java/bisq/asset/AddressValidationResult.java b/src/main/java/bisq/asset/AddressValidationResult.java index b426415c..2423e4bf 100644 --- a/src/main/java/bisq/asset/AddressValidationResult.java +++ b/src/main/java/bisq/asset/AddressValidationResult.java @@ -52,11 +52,15 @@ public static AddressValidationResult validAddress() { } public static AddressValidationResult invalidStructure() { - return new AddressValidationResult(false, "", "validation.altcoin.wrongStructure"); + return invalidAddress("", "validation.altcoin.wrongStructure"); } public static AddressValidationResult invalidAddress(String cause) { - return new AddressValidationResult(false, cause, "validation.altcoin.invalidAddress"); + return invalidAddress(cause, "validation.altcoin.invalidAddress"); + } + + public static AddressValidationResult invalidAddress(String cause, String i18nKey) { + return new AddressValidationResult(false, cause, i18nKey); } public static AddressValidationResult invalidAddress(Throwable cause) { diff --git a/src/main/java/bisq/asset/coins/Zcash.java b/src/main/java/bisq/asset/coins/Zcash.java new file mode 100644 index 00000000..243adad1 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Zcash.java @@ -0,0 +1,41 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.AddressValidator; +import bisq.asset.Coin; + +public class Zcash extends Coin { + + public Zcash() { + super("Zcash", "ZEC", new ZcashAddressValidator()); + } + + + public static class ZcashAddressValidator implements AddressValidator { + + @Override + public AddressValidationResult validate(String address) { + // We only support t addresses (transparent transactions) + if (!address.startsWith("t")) + return AddressValidationResult.invalidAddress("", "validation.altcoin.zAddressesNotSupported"); + return AddressValidationResult.validAddress(); + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 3ac85701..ead41765 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -159,7 +159,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("WAC", "WACoins")); result.add(new CryptoCurrency("WILD", "WILD Token", true)); result.add(new CryptoCurrency("XZC", "Zcoin")); - result.add(new CryptoCurrency("ZEC", "Zcash")); result.add(new CryptoCurrency("ZEN", "ZenCash")); // Added 0.6.6 diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 146ff76d..eae42ded 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -18,10 +18,6 @@ package bisq.core.payment.validation; import bisq.core.app.BisqEnvironment; -import bisq.asset.AddressValidationResult; -import bisq.asset.Coin; -import bisq.asset.Asset; -import bisq.asset.AssetRegistry; import bisq.core.btc.BaseCurrencyNetwork; import bisq.core.locale.Res; import bisq.core.payment.validation.altcoins.ByteballAddressValidator; @@ -50,6 +46,11 @@ import bisq.core.payment.validation.params.btc.BtcMainNetParamsForValidation; import bisq.core.util.validation.InputValidator; +import bisq.asset.AddressValidationResult; +import bisq.asset.Asset; +import bisq.asset.AssetRegistry; +import bisq.asset.Coin; + import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; import org.bitcoinj.core.Base58; @@ -107,12 +108,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "ZEC": - // We only support t addresses (transparent transactions) - if (input.startsWith("t")) - return validationResult; - else - return new ValidationResult(false, Res.get("validation.altcoin.zAddressesNotSupported")); case "GBYTE": return ByteballAddressValidator.validate(input); case "NXT": diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 9607006c..ac8d7828 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -17,4 +17,5 @@ bisq.asset.coins.Litecoin$Regtest bisq.asset.coins.Litecoin$Testnet bisq.asset.coins.Octocoin bisq.asset.coins.PIVX +bisq.asset.coins.Zcash bisq.asset.tokens.Ellaism diff --git a/src/test/java/bisq/asset/coins/ZcashTest.java b/src/test/java/bisq/asset/coins/ZcashTest.java new file mode 100644 index 00000000..44cb2f0c --- /dev/null +++ b/src/test/java/bisq/asset/coins/ZcashTest.java @@ -0,0 +1,43 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class ZcashTest extends AbstractAssetTest { + + public ZcashTest() { + super(new Zcash()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("t1K6LGT7z2uNTLxag6eK6XwGNpdkHbncBaK"); + assertValidAddress("t1ZjdqCGEkqL9nZ8fk9R6KA7bqNvXaVLUpF"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem"); + assertInvalidAddress("38NwrYsD1HxQW5zfLT0QcUUXGMPvQgzTSn"); + assertInvalidAddress("8tP9rh3SH6n9cSLmV22vnSNNw56LKGpLrB"); + assertInvalidAddress("8Zbvjr"); + } +} From db51bf6d94871fad1d98b2cdcb17de782dc65342 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 11:39:57 +0200 Subject: [PATCH 017/106] Extract Byteball --- src/main/java/bisq/asset/coins/Byteball.java | 196 ++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 3 - .../altcoins/ByteballAddressValidator.java | 186 ----------------- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/ByteballTest.java | 42 ++++ 6 files changed, 239 insertions(+), 190 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Byteball.java delete mode 100644 src/main/java/bisq/core/payment/validation/altcoins/ByteballAddressValidator.java create mode 100644 src/test/java/bisq/asset/coins/ByteballTest.java diff --git a/src/main/java/bisq/asset/coins/Byteball.java b/src/main/java/bisq/asset/coins/Byteball.java new file mode 100644 index 00000000..9932fd9d --- /dev/null +++ b/src/main/java/bisq/asset/coins/Byteball.java @@ -0,0 +1,196 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.AddressValidator; +import bisq.asset.Coin; + +import org.apache.commons.codec.binary.Base32; +import org.apache.commons.codec.binary.Base64; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class Byteball extends Coin { + + public Byteball() { + super("Byte", "GBYTE", new ByteballAddressValidator()); + } + + + public static class ByteballAddressValidator implements AddressValidator { + private static final Base32 base32 = new Base32(); + private static final Base64 base64 = new Base64(); + private static final String PI = "14159265358979323846264338327950288419716939937510"; + private static final String[] arrRelativeOffsets = PI.split(""); + @SuppressWarnings("CanBeFinal") + private static Integer[] arrOffsets160; + @SuppressWarnings("CanBeFinal") + private static Integer[] arrOffsets288; + + static { + try { + arrOffsets160 = calcOffsets(160); + } catch (Exception e) { + e.printStackTrace(); + } + try { + arrOffsets288 = calcOffsets(288); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public AddressValidationResult validate(String input) { + if (!isValidAddress(input)) { + return AddressValidationResult.invalidStructure(); + } + return AddressValidationResult.validAddress(); + } + + private static boolean isValidAddress(String address) { + return isValidChash(address, 32); + } + + private static boolean isValidChash(String str, int len) { + return (isStringOfLength(str, len) && isChashValid(str)); + } + + private static boolean isStringOfLength(String str, int len) { + return str.length() == len; + } + + private static void checkLength(int chash_length) throws Exception { + if (chash_length != 160 && chash_length != 288) + throw new Exception("unsupported c-hash length: " + chash_length); + } + + private static Integer[] calcOffsets(int chash_length) throws Exception { + checkLength(chash_length); + List arrOffsets = new ArrayList<>(chash_length); + int offset = 0; + int index = 0; + + for (int i = 0; offset < chash_length; i++) { + int relative_offset = Integer.parseInt(arrRelativeOffsets[i]); + if (relative_offset == 0) + continue; + offset += relative_offset; + if (chash_length == 288) + offset += 4; + if (offset >= chash_length) + break; + arrOffsets.add(offset); + //console.log("index="+index+", offset="+offset); + index++; + } + + if (index != 32) + throw new Exception("wrong number of checksum bits"); + + //noinspection ToArrayCallWithZeroLengthArrayArgument + return arrOffsets.toArray(new Integer[0]); + } + + private static ByteballAddressValidator.SeparatedData separateIntoCleanDataAndChecksum(String bin) throws Exception { + int len = bin.length(); + Integer[] arrOffsets; + if (len == 160) + arrOffsets = arrOffsets160; + else if (len == 288) + arrOffsets = arrOffsets288; + else + throw new Exception("bad length"); + StringBuilder arrFrags = new StringBuilder(); + StringBuilder arrChecksumBits = new StringBuilder(); + int start = 0; + //noinspection ForLoopReplaceableByForEach + for (int i = 0; i < arrOffsets.length; i++) { + arrFrags.append(bin.substring(start, arrOffsets[i])); + arrChecksumBits.append(bin.substring(arrOffsets[i], arrOffsets[i] + 1)); + start = arrOffsets[i] + 1; + } + // add last frag + if (start < bin.length()) + arrFrags.append(bin.substring(start)); + String binCleanData = arrFrags.toString(); + String binChecksum = arrChecksumBits.toString(); + return new ByteballAddressValidator.SeparatedData(binCleanData, binChecksum); + } + + private static String buffer2bin(byte[] buf) { + StringBuilder bytes = new StringBuilder(); + //noinspection ForLoopReplaceableByForEach + for (int i = 0; i < buf.length; i++) { + String bin = String.format("%8s", Integer.toBinaryString(buf[i] & 0xFF)).replace(' ', '0'); + bytes.append(bin); + } + return bytes.toString(); + } + + private static byte[] bin2buffer(String bin) { + int len = bin.length() / 8; + byte[] buf = new byte[len]; + for (int i = 0; i < len; i++) + buf[i] = (byte) Integer.parseInt(bin.substring(i * 8, (i + 1) * 8), 2); + return buf; + } + + private static boolean isChashValid(String encoded) { + int encoded_len = encoded.length(); + if (encoded_len != 32 && encoded_len != 48) // 160/5 = 32, 288/6 = 48 + return false; + byte[] chash = (encoded_len == 32) ? base32.decode(encoded) : base64.decode(encoded); + String binChash = buffer2bin(chash); + ByteballAddressValidator.SeparatedData separated; + try { + separated = separateIntoCleanDataAndChecksum(binChash); + } catch (Exception e) { + return false; + } + byte[] clean_data = bin2buffer(separated.clean_data); + byte[] checksum = bin2buffer(separated.checksum); + return Arrays.equals(getChecksum(clean_data), checksum); + } + + private static byte[] getChecksum(byte[] clean_data) { + + try { + byte[] full_checksum = MessageDigest.getInstance("SHA-256").digest(clean_data); + return new byte[]{full_checksum[5], full_checksum[13], full_checksum[21], full_checksum[29]}; + } catch (NoSuchAlgorithmException e) { + return null; + } + } + + private static class SeparatedData { + final String clean_data; + final String checksum; + + public SeparatedData(String clean_data, String checksum) { + this.clean_data = clean_data; + this.checksum = checksum; + } + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index ead41765..53da6083 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -111,7 +111,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("BCHC", "Bitcoin Clashic")); result.add(new CryptoCurrency("BTG", "Bitcoin Gold")); result.add(new CryptoCurrency("BURST", "Burstcoin")); - result.add(new CryptoCurrency("GBYTE", "Byte")); result.add(new CryptoCurrency("CAGE", "Cagecoin")); result.add(new CryptoCurrency("XCP", "Counterparty")); result.add(new CryptoCurrency("CREA", "Creativecoin")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index eae42ded..1a38bb83 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -20,7 +20,6 @@ import bisq.core.app.BisqEnvironment; import bisq.core.btc.BaseCurrencyNetwork; import bisq.core.locale.Res; -import bisq.core.payment.validation.altcoins.ByteballAddressValidator; import bisq.core.payment.validation.altcoins.KOTOAddressValidator; import bisq.core.payment.validation.altcoins.NxtReedSolomonValidator; import bisq.core.payment.validation.altcoins.PNCAddressValidator; @@ -108,8 +107,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "GBYTE": - return ByteballAddressValidator.validate(input); case "NXT": if (!input.startsWith("NXT-") || !input.equals(input.toUpperCase())) { return regexTestFailed; diff --git a/src/main/java/bisq/core/payment/validation/altcoins/ByteballAddressValidator.java b/src/main/java/bisq/core/payment/validation/altcoins/ByteballAddressValidator.java deleted file mode 100644 index 62e424ba..00000000 --- a/src/main/java/bisq/core/payment/validation/altcoins/ByteballAddressValidator.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.altcoins; - -import bisq.core.util.validation.InputValidator; - -import org.apache.commons.codec.binary.Base32; -import org.apache.commons.codec.binary.Base64; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * Created by DevAlexey on 19.12.2016. - */ -public class ByteballAddressValidator { - private static final Base32 base32 = new Base32(); - private static final Base64 base64 = new Base64(); - private static final String PI = "14159265358979323846264338327950288419716939937510"; - private static final String[] arrRelativeOffsets = PI.split(""); - @SuppressWarnings("CanBeFinal") - private static Integer[] arrOffsets160; - @SuppressWarnings("CanBeFinal") - private static Integer[] arrOffsets288; - - static { - try { - arrOffsets160 = calcOffsets(160); - } catch (Exception e) { - e.printStackTrace(); - } - try { - arrOffsets288 = calcOffsets(288); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static InputValidator.ValidationResult validate(String input) { - return new InputValidator.ValidationResult(isValidAddress(input)); - } - - private static boolean isValidAddress(String address) { - return isValidChash(address, 32); - } - - private static boolean isValidChash(String str, int len) { - return (isStringOfLength(str, len) && isChashValid(str)); - } - - private static boolean isStringOfLength(String str, int len) { - return str.length() == len; - } - - private static void checkLength(int chash_length) throws Exception { - if (chash_length != 160 && chash_length != 288) - throw new Exception("unsupported c-hash length: " + chash_length); - } - - private static Integer[] calcOffsets(int chash_length) throws Exception { - checkLength(chash_length); - List arrOffsets = new ArrayList<>(chash_length); - int offset = 0; - int index = 0; - - for (int i = 0; offset < chash_length; i++) { - int relative_offset = Integer.parseInt(arrRelativeOffsets[i]); - if (relative_offset == 0) - continue; - offset += relative_offset; - if (chash_length == 288) - offset += 4; - if (offset >= chash_length) - break; - arrOffsets.add(offset); - //console.log("index="+index+", offset="+offset); - index++; - } - - if (index != 32) - throw new Exception("wrong number of checksum bits"); - - //noinspection ToArrayCallWithZeroLengthArrayArgument - return arrOffsets.toArray(new Integer[0]); - } - - private static SeparatedData separateIntoCleanDataAndChecksum(String bin) throws Exception { - int len = bin.length(); - Integer[] arrOffsets; - if (len == 160) - arrOffsets = arrOffsets160; - else if (len == 288) - arrOffsets = arrOffsets288; - else - throw new Exception("bad length"); - StringBuilder arrFrags = new StringBuilder(); - StringBuilder arrChecksumBits = new StringBuilder(); - int start = 0; - //noinspection ForLoopReplaceableByForEach - for (int i = 0; i < arrOffsets.length; i++) { - arrFrags.append(bin.substring(start, arrOffsets[i])); - arrChecksumBits.append(bin.substring(arrOffsets[i], arrOffsets[i] + 1)); - start = arrOffsets[i] + 1; - } - // add last frag - if (start < bin.length()) - arrFrags.append(bin.substring(start)); - String binCleanData = arrFrags.toString(); - String binChecksum = arrChecksumBits.toString(); - return new SeparatedData(binCleanData, binChecksum); - } - - private static String buffer2bin(byte[] buf) { - StringBuilder bytes = new StringBuilder(); - //noinspection ForLoopReplaceableByForEach - for (int i = 0; i < buf.length; i++) { - String bin = String.format("%8s", Integer.toBinaryString(buf[i] & 0xFF)).replace(' ', '0'); - bytes.append(bin); - } - return bytes.toString(); - } - - private static byte[] bin2buffer(String bin) { - int len = bin.length() / 8; - byte[] buf = new byte[len]; - for (int i = 0; i < len; i++) - buf[i] = (byte) Integer.parseInt(bin.substring(i * 8, (i + 1) * 8), 2); - return buf; - } - - private static boolean isChashValid(String encoded) { - int encoded_len = encoded.length(); - if (encoded_len != 32 && encoded_len != 48) // 160/5 = 32, 288/6 = 48 - return false; - byte[] chash = (encoded_len == 32) ? base32.decode(encoded) : base64.decode(encoded); - String binChash = buffer2bin(chash); - SeparatedData separated; - try { - separated = separateIntoCleanDataAndChecksum(binChash); - } catch (Exception e) { - return false; - } - byte[] clean_data = bin2buffer(separated.clean_data); - byte[] checksum = bin2buffer(separated.checksum); - return Arrays.equals(getChecksum(clean_data), checksum); - } - - private static byte[] getChecksum(byte[] clean_data) { - - try { - byte[] full_checksum = MessageDigest.getInstance("SHA-256").digest(clean_data); - return new byte[]{full_checksum[5], full_checksum[13], full_checksum[21], full_checksum[29]}; - } catch (NoSuchAlgorithmException e) { - return null; - } - } - - private static class SeparatedData { - final String clean_data; - final String checksum; - - public SeparatedData(String clean_data, String checksum) { - this.clean_data = clean_data; - this.checksum = checksum; - } - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index ac8d7828..3e398e8a 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -5,6 +5,7 @@ bisq.asset.coins.Bitcoin$Mainnet bisq.asset.coins.Bitcoin$Regtest bisq.asset.coins.Bitcoin$Testnet bisq.asset.coins.BitcoinCash +bisq.asset.coins.Byteball bisq.asset.coins.Dash$Mainnet bisq.asset.coins.Dash$Regtest bisq.asset.coins.Dash$Testnet diff --git a/src/test/java/bisq/asset/coins/ByteballTest.java b/src/test/java/bisq/asset/coins/ByteballTest.java new file mode 100644 index 00000000..81d290c8 --- /dev/null +++ b/src/test/java/bisq/asset/coins/ByteballTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class ByteballTest extends AbstractAssetTest { + + public ByteballTest() { + super(new Byteball()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("BN7JXKXWEG4BVJ7NW6Q3Z7SMJNZJYM3G"); + assertValidAddress("XGKZODTTTRXIUA75TKONWHFDCU6634DE"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("XGKZODTGTRXIUA75TKONWHFDCU6634DE"); + assertInvalidAddress("XGKZODTTTRXIUA75TKONWHFDCU6634D"); + assertInvalidAddress("XGKZODTTTRXIUA75TKONWHFDCU6634DZ"); + } +} From b516ce313224d375ee166a06ef003af38bd9148b Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 11:50:11 +0200 Subject: [PATCH 018/106] Extract Nxt --- src/main/java/bisq/asset/coins/Nxt.java | 219 ++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 11 - .../altcoins/NxtReedSolomonValidator.java | 196 ---------------- .../META-INF/services/bisq.asset.Asset | 1 + src/test/java/bisq/asset/coins/NxtTest.java | 45 ++++ 6 files changed, 265 insertions(+), 208 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Nxt.java delete mode 100644 src/main/java/bisq/core/payment/validation/altcoins/NxtReedSolomonValidator.java create mode 100644 src/test/java/bisq/asset/coins/NxtTest.java diff --git a/src/main/java/bisq/asset/coins/Nxt.java b/src/main/java/bisq/asset/coins/Nxt.java new file mode 100644 index 00000000..9347cb06 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Nxt.java @@ -0,0 +1,219 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.AddressValidator; +import bisq.asset.Coin; + +public class Nxt extends Coin { + + public Nxt() { + super("Nxt", "NXT", new NxtAddressValidator()); + } + + + public static class NxtAddressValidator implements AddressValidator { + + @Override + public AddressValidationResult validate(String address) { + if (!address.startsWith("NXT-") || !address.equals(address.toUpperCase())) { + return AddressValidationResult.invalidStructure(); + } + try { + long accountId = NxtReedSolomonValidator.decode(address.substring(4)); + if (accountId == 0) { + return AddressValidationResult.invalidStructure(); + } + return AddressValidationResult.validAddress(); + } catch (NxtReedSolomonValidator.DecodeException e) { + return AddressValidationResult.invalidAddress(e); + } + } + } + + public static final class NxtReedSolomonValidator { + + private static final int[] initial_codeword = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + private static final int[] gexp = {1, 2, 4, 8, 16, 5, 10, 20, 13, 26, 17, 7, 14, 28, 29, 31, 27, 19, 3, 6, 12, 24, 21, 15, 30, 25, 23, 11, 22, 9, 18, 1}; + private static final int[] glog = {0, 0, 1, 18, 2, 5, 19, 11, 3, 29, 6, 27, 20, 8, 12, 23, 4, 10, 30, 17, 7, 22, 28, 26, 21, 25, 9, 16, 13, 14, 24, 15}; + private static final int[] codeword_map = {3, 2, 1, 0, 7, 6, 5, 4, 13, 14, 15, 16, 12, 8, 9, 10, 11}; + private static final String alphabet = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ"; + + private static final int base_32_length = 13; + private static final int base_10_length = 20; + + public static String encode(long plain) { + + String plain_string = Long.toUnsignedString(plain); + int length = plain_string.length(); + int[] plain_string_10 = new int[NxtReedSolomonValidator.base_10_length]; + for (int i = 0; i < length; i++) { + plain_string_10[i] = (int) plain_string.charAt(i) - (int) '0'; + } + + int codeword_length = 0; + int[] codeword = new int[NxtReedSolomonValidator.initial_codeword.length]; + + do { // base 10 to base 32 conversion + int new_length = 0; + int digit_32 = 0; + for (int i = 0; i < length; i++) { + digit_32 = digit_32 * 10 + plain_string_10[i]; + if (digit_32 >= 32) { + plain_string_10[new_length] = digit_32 >> 5; + digit_32 &= 31; + new_length += 1; + } else if (new_length > 0) { + plain_string_10[new_length] = 0; + new_length += 1; + } + } + length = new_length; + codeword[codeword_length] = digit_32; + codeword_length += 1; + } while (length > 0); + + int[] p = {0, 0, 0, 0}; + for (int i = NxtReedSolomonValidator.base_32_length - 1; i >= 0; i--) { + final int fb = codeword[i] ^ p[3]; + p[3] = p[2] ^ NxtReedSolomonValidator.gmult(30, fb); + p[2] = p[1] ^ NxtReedSolomonValidator.gmult(6, fb); + p[1] = p[0] ^ NxtReedSolomonValidator.gmult(9, fb); + p[0] = NxtReedSolomonValidator.gmult(17, fb); + } + + System.arraycopy(p, 0, codeword, NxtReedSolomonValidator.base_32_length, NxtReedSolomonValidator.initial_codeword.length - NxtReedSolomonValidator.base_32_length); + + StringBuilder cypher_string_builder = new StringBuilder(); + for (int i = 0; i < 17; i++) { + final int codework_index = NxtReedSolomonValidator.codeword_map[i]; + final int alphabet_index = codeword[codework_index]; + cypher_string_builder.append(NxtReedSolomonValidator.alphabet.charAt(alphabet_index)); + + if ((i & 3) == 3 && i < 13) { + cypher_string_builder.append('-'); + } + } + return cypher_string_builder.toString(); + } + + public static long decode(String cypher_string) throws DecodeException { + + int[] codeword = new int[NxtReedSolomonValidator.initial_codeword.length]; + System.arraycopy(NxtReedSolomonValidator.initial_codeword, 0, codeword, 0, NxtReedSolomonValidator.initial_codeword.length); + + int codeword_length = 0; + for (int i = 0; i < cypher_string.length(); i++) { + int position_in_alphabet = NxtReedSolomonValidator.alphabet.indexOf(cypher_string.charAt(i)); + + if (position_in_alphabet <= -1 || position_in_alphabet > NxtReedSolomonValidator.alphabet.length()) { + continue; + } + + if (codeword_length > 16) { + throw new CodewordTooLongException(); + } + + int codework_index = NxtReedSolomonValidator.codeword_map[codeword_length]; + codeword[codework_index] = position_in_alphabet; + codeword_length += 1; + } + + if (codeword_length == 17 && !NxtReedSolomonValidator.is_codeword_valid(codeword) || codeword_length != 17) { + throw new CodewordInvalidException(); + } + + int length = NxtReedSolomonValidator.base_32_length; + int[] cypher_string_32 = new int[length]; + for (int i = 0; i < length; i++) { + cypher_string_32[i] = codeword[length - i - 1]; + } + + StringBuilder plain_string_builder = new StringBuilder(); + do { // base 32 to base 10 conversion + int new_length = 0; + int digit_10 = 0; + + for (int i = 0; i < length; i++) { + digit_10 = digit_10 * 32 + cypher_string_32[i]; + + if (digit_10 >= 10) { + cypher_string_32[new_length] = digit_10 / 10; + digit_10 %= 10; + new_length += 1; + } else if (new_length > 0) { + cypher_string_32[new_length] = 0; + new_length += 1; + } + } + length = new_length; + plain_string_builder.append((char) (digit_10 + (int) '0')); + } while (length > 0); + + return Long.parseUnsignedLong(plain_string_builder.reverse().toString()); + } + + private static int gmult(int a, int b) { + if (a == 0 || b == 0) { + return 0; + } + + int idx = (NxtReedSolomonValidator.glog[a] + NxtReedSolomonValidator.glog[b]) % 31; + + return NxtReedSolomonValidator.gexp[idx]; + } + + private static boolean is_codeword_valid(int[] codeword) { + int sum = 0; + + for (int i = 1; i < 5; i++) { + int t = 0; + + for (int j = 0; j < 31; j++) { + if (j > 12 && j < 27) { + continue; + } + + int pos = j; + if (j > 26) { + pos -= 14; + } + + t ^= NxtReedSolomonValidator.gmult(codeword[pos], NxtReedSolomonValidator.gexp[(i * j) % 31]); + } + + sum |= t; + } + + return sum == 0; + } + + public abstract static class DecodeException extends Exception { + } + + static final class CodewordTooLongException extends DecodeException { + } + + static final class CodewordInvalidException extends DecodeException { + } + + private NxtReedSolomonValidator() { + } // never + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 53da6083..6268ebb7 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -134,7 +134,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("NAV", "Nav Coin")); result.add(new CryptoCurrency("NMC", "Namecoin")); result.add(new CryptoCurrency("NBT", "NuBits")); - result.add(new CryptoCurrency("NXT", "Nxt")); result.add(new CryptoCurrency("888", "OctoCoin")); result.add(new CryptoCurrency("PART", "Particl")); result.add(new CryptoCurrency("PASC", "Pascal Coin", true)); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 1a38bb83..c4d743bc 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -21,7 +21,6 @@ import bisq.core.btc.BaseCurrencyNetwork; import bisq.core.locale.Res; import bisq.core.payment.validation.altcoins.KOTOAddressValidator; -import bisq.core.payment.validation.altcoins.NxtReedSolomonValidator; import bisq.core.payment.validation.altcoins.PNCAddressValidator; import bisq.core.payment.validation.altcoins.WMCCAddressValidator; import bisq.core.payment.validation.altcoins.XCNAddressValidator; @@ -107,16 +106,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "NXT": - if (!input.startsWith("NXT-") || !input.equals(input.toUpperCase())) { - return regexTestFailed; - } - try { - long accountId = NxtReedSolomonValidator.decode(input.substring(4)); - return new ValidationResult(accountId != 0); - } catch (NxtReedSolomonValidator.DecodeException e) { - return wrongChecksum; - } case "DCT": if (input.matches("^(?=.{5,63}$)([a-z][a-z0-9-]+[a-z0-9])(\\.[a-z][a-z0-9-]+[a-z0-9])*$")) return new ValidationResult(true); diff --git a/src/main/java/bisq/core/payment/validation/altcoins/NxtReedSolomonValidator.java b/src/main/java/bisq/core/payment/validation/altcoins/NxtReedSolomonValidator.java deleted file mode 100644 index 477aed12..00000000 --- a/src/main/java/bisq/core/payment/validation/altcoins/NxtReedSolomonValidator.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ -/* - Reed Solomon Encoding and Decoding for Nxt - - Version: 1.0, license: Public Domain, coder: NxtChg (admin@nxtchg.com) - Java Version: ChuckOne (ChuckOne@mail.de). -*/ - -package bisq.core.payment.validation.altcoins; - -public final class NxtReedSolomonValidator { - - private static final int[] initial_codeword = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - private static final int[] gexp = {1, 2, 4, 8, 16, 5, 10, 20, 13, 26, 17, 7, 14, 28, 29, 31, 27, 19, 3, 6, 12, 24, 21, 15, 30, 25, 23, 11, 22, 9, 18, 1}; - private static final int[] glog = {0, 0, 1, 18, 2, 5, 19, 11, 3, 29, 6, 27, 20, 8, 12, 23, 4, 10, 30, 17, 7, 22, 28, 26, 21, 25, 9, 16, 13, 14, 24, 15}; - private static final int[] codeword_map = {3, 2, 1, 0, 7, 6, 5, 4, 13, 14, 15, 16, 12, 8, 9, 10, 11}; - private static final String alphabet = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ"; - - private static final int base_32_length = 13; - private static final int base_10_length = 20; - - public static String encode(long plain) { - - String plain_string = Long.toUnsignedString(plain); - int length = plain_string.length(); - int[] plain_string_10 = new int[NxtReedSolomonValidator.base_10_length]; - for (int i = 0; i < length; i++) { - plain_string_10[i] = (int) plain_string.charAt(i) - (int) '0'; - } - - int codeword_length = 0; - int[] codeword = new int[NxtReedSolomonValidator.initial_codeword.length]; - - do { // base 10 to base 32 conversion - int new_length = 0; - int digit_32 = 0; - for (int i = 0; i < length; i++) { - digit_32 = digit_32 * 10 + plain_string_10[i]; - if (digit_32 >= 32) { - plain_string_10[new_length] = digit_32 >> 5; - digit_32 &= 31; - new_length += 1; - } else if (new_length > 0) { - plain_string_10[new_length] = 0; - new_length += 1; - } - } - length = new_length; - codeword[codeword_length] = digit_32; - codeword_length += 1; - } while (length > 0); - - int[] p = {0, 0, 0, 0}; - for (int i = NxtReedSolomonValidator.base_32_length - 1; i >= 0; i--) { - final int fb = codeword[i] ^ p[3]; - p[3] = p[2] ^ NxtReedSolomonValidator.gmult(30, fb); - p[2] = p[1] ^ NxtReedSolomonValidator.gmult(6, fb); - p[1] = p[0] ^ NxtReedSolomonValidator.gmult(9, fb); - p[0] = NxtReedSolomonValidator.gmult(17, fb); - } - - System.arraycopy(p, 0, codeword, NxtReedSolomonValidator.base_32_length, NxtReedSolomonValidator.initial_codeword.length - NxtReedSolomonValidator.base_32_length); - - StringBuilder cypher_string_builder = new StringBuilder(); - for (int i = 0; i < 17; i++) { - final int codework_index = NxtReedSolomonValidator.codeword_map[i]; - final int alphabet_index = codeword[codework_index]; - cypher_string_builder.append(NxtReedSolomonValidator.alphabet.charAt(alphabet_index)); - - if ((i & 3) == 3 && i < 13) { - cypher_string_builder.append('-'); - } - } - return cypher_string_builder.toString(); - } - - public static long decode(String cypher_string) throws DecodeException { - - int[] codeword = new int[NxtReedSolomonValidator.initial_codeword.length]; - System.arraycopy(NxtReedSolomonValidator.initial_codeword, 0, codeword, 0, NxtReedSolomonValidator.initial_codeword.length); - - int codeword_length = 0; - for (int i = 0; i < cypher_string.length(); i++) { - int position_in_alphabet = NxtReedSolomonValidator.alphabet.indexOf(cypher_string.charAt(i)); - - if (position_in_alphabet <= -1 || position_in_alphabet > NxtReedSolomonValidator.alphabet.length()) { - continue; - } - - if (codeword_length > 16) { - throw new CodewordTooLongException(); - } - - int codework_index = NxtReedSolomonValidator.codeword_map[codeword_length]; - codeword[codework_index] = position_in_alphabet; - codeword_length += 1; - } - - if (codeword_length == 17 && !NxtReedSolomonValidator.is_codeword_valid(codeword) || codeword_length != 17) { - throw new CodewordInvalidException(); - } - - int length = NxtReedSolomonValidator.base_32_length; - int[] cypher_string_32 = new int[length]; - for (int i = 0; i < length; i++) { - cypher_string_32[i] = codeword[length - i - 1]; - } - - StringBuilder plain_string_builder = new StringBuilder(); - do { // base 32 to base 10 conversion - int new_length = 0; - int digit_10 = 0; - - for (int i = 0; i < length; i++) { - digit_10 = digit_10 * 32 + cypher_string_32[i]; - - if (digit_10 >= 10) { - cypher_string_32[new_length] = digit_10 / 10; - digit_10 %= 10; - new_length += 1; - } else if (new_length > 0) { - cypher_string_32[new_length] = 0; - new_length += 1; - } - } - length = new_length; - plain_string_builder.append((char) (digit_10 + (int) '0')); - } while (length > 0); - - return Long.parseUnsignedLong(plain_string_builder.reverse().toString()); - } - - private static int gmult(int a, int b) { - if (a == 0 || b == 0) { - return 0; - } - - int idx = (NxtReedSolomonValidator.glog[a] + NxtReedSolomonValidator.glog[b]) % 31; - - return NxtReedSolomonValidator.gexp[idx]; - } - - private static boolean is_codeword_valid(int[] codeword) { - int sum = 0; - - for (int i = 1; i < 5; i++) { - int t = 0; - - for (int j = 0; j < 31; j++) { - if (j > 12 && j < 27) { - continue; - } - - int pos = j; - if (j > 26) { - pos -= 14; - } - - t ^= NxtReedSolomonValidator.gmult(codeword[pos], NxtReedSolomonValidator.gexp[(i * j) % 31]); - } - - sum |= t; - } - - return sum == 0; - } - - public abstract static class DecodeException extends Exception { - } - - static final class CodewordTooLongException extends DecodeException { - } - - static final class CodewordInvalidException extends DecodeException { - } - - private NxtReedSolomonValidator() { - } // never -} - - diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 3e398e8a..5cd0815e 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -16,6 +16,7 @@ bisq.asset.coins.Instacash bisq.asset.coins.Litecoin$Mainnet bisq.asset.coins.Litecoin$Regtest bisq.asset.coins.Litecoin$Testnet +bisq.asset.coins.Nxt bisq.asset.coins.Octocoin bisq.asset.coins.PIVX bisq.asset.coins.Zcash diff --git a/src/test/java/bisq/asset/coins/NxtTest.java b/src/test/java/bisq/asset/coins/NxtTest.java new file mode 100644 index 00000000..a482e0b9 --- /dev/null +++ b/src/test/java/bisq/asset/coins/NxtTest.java @@ -0,0 +1,45 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class NxtTest extends AbstractAssetTest { + + public NxtTest() { + super(new Nxt()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("NXT-JM2U-U4AE-G7WF-3NP9F"); + assertValidAddress("NXT-6UNJ-UMFM-Z525-4S24M"); + assertValidAddress("NXT-2223-2222-KB8Y-22222"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("abcde"); + assertInvalidAddress("NXT-"); + assertInvalidAddress("NXT-JM2U-U4AE-G7WF-3ND9F"); + assertInvalidAddress("NXT-JM2U-U4AE-G7WF-3Np9F"); + assertInvalidAddress("NXT-2222-2222-2222-22222"); + } +} From 055acf207377e87a72c89a63db45ea4f756442a3 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 12:08:09 +0200 Subject: [PATCH 019/106] Extract Decent --- src/main/java/bisq/asset/coins/Decent.java | 36 +++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 -- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/DecentTest.java | 46 +++++++++++++++++++ 5 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Decent.java create mode 100644 src/test/java/bisq/asset/coins/DecentTest.java diff --git a/src/main/java/bisq/asset/coins/Decent.java b/src/main/java/bisq/asset/coins/Decent.java new file mode 100644 index 00000000..95f70fe2 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Decent.java @@ -0,0 +1,36 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.RegexAddressValidator; + +public class Decent extends Coin { + + public Decent() { + super("Decent", "DCT", new DecentAddressValidator()); + } + + + public static class DecentAddressValidator extends RegexAddressValidator { + + public DecentAddressValidator() { + super("^(?=.{5,63}$)([a-z][a-z0-9-]+[a-z0-9])(\\.[a-z][a-z0-9-]+[a-z0-9])*$"); + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 6268ebb7..59e72dc5 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -116,7 +116,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("CREA", "Creativecoin")); result.add(new CryptoCurrency("XCN", "Cryptonite")); result.add(new CryptoCurrency("DNET", "DarkNet")); - result.add(new CryptoCurrency("DCT", "DECENT")); result.add(new CryptoCurrency("DCR", "Decred")); result.add(new CryptoCurrency("ONION", "DeepOnion")); result.add(new CryptoCurrency("DMC", "DynamicCoin")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index c4d743bc..daa9219f 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -106,11 +106,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "DCT": - if (input.matches("^(?=.{5,63}$)([a-z][a-z0-9-]+[a-z0-9])(\\.[a-z][a-z0-9-]+[a-z0-9])*$")) - return new ValidationResult(true); - else - return regexTestFailed; case "PNC": if (input.matches("^[P3][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { if (PNCAddressValidator.ValidateAddress(input)) { diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 5cd0815e..4853f572 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -9,6 +9,7 @@ bisq.asset.coins.Byteball bisq.asset.coins.Dash$Mainnet bisq.asset.coins.Dash$Regtest bisq.asset.coins.Dash$Testnet +bisq.asset.coins.Decent bisq.asset.coins.Dogecoin bisq.asset.coins.Ether bisq.asset.coins.InternetOfPeople diff --git a/src/test/java/bisq/asset/coins/DecentTest.java b/src/test/java/bisq/asset/coins/DecentTest.java new file mode 100644 index 00000000..e35b0dcc --- /dev/null +++ b/src/test/java/bisq/asset/coins/DecentTest.java @@ -0,0 +1,46 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class DecentTest extends AbstractAssetTest { + + public DecentTest() { + super(new Decent()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("ud6910c2790bda53bcc53cb131f8fa3bf"); + assertValidAddress("decent-account123"); + assertValidAddress("decent.acc-123"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("my.acc123"); + assertInvalidAddress("123decent"); + assertInvalidAddress("decent_acc"); + assertInvalidAddress("dEcent"); + assertInvalidAddress("dct1"); + assertInvalidAddress("decent-"); + } +} From cfb24849732ee3da84700fd1ff05156ee9594e9b Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 12:32:37 +0200 Subject: [PATCH 020/106] Extract Pranacoin --- src/main/java/bisq/asset/coins/Pranacoin.java | 102 ++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 17 --- .../altcoins/PNCAddressValidator.java | 65 ----------- .../payment/validation/params/PNCParams.java | 92 ---------------- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/PranacoinTest.java | 43 ++++++++ 7 files changed, 146 insertions(+), 175 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Pranacoin.java delete mode 100644 src/main/java/bisq/core/payment/validation/altcoins/PNCAddressValidator.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/PNCParams.java create mode 100644 src/test/java/bisq/asset/coins/PranacoinTest.java diff --git a/src/main/java/bisq/asset/coins/Pranacoin.java b/src/main/java/bisq/asset/coins/Pranacoin.java new file mode 100644 index 00000000..c56113b2 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Pranacoin.java @@ -0,0 +1,102 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import java.util.Arrays; + +public class Pranacoin extends Coin { + + public Pranacoin() { + super("Pranacoin", "PNC", new PranacoinAddressValidator()); + } + + + public static class PranacoinAddressValidator extends Base58BitcoinAddressValidator { + + private final static String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; + + public PranacoinAddressValidator() { + super(new Pranacoin.PranacoinParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[P3][a-km-zA-HJ-NP-Z1-9]{25,34}$")) + return AddressValidationResult.invalidStructure(); + if (!validateAddress(address)) + return AddressValidationResult.invalidStructure(); + return super.validate(address); + } + + public static boolean validateAddress(String addr) { + if (addr.length() < 26 || addr.length() > 35) return false; + byte[] decoded = decodeBase58(addr, 58, 25); + if (decoded == null) return false; + + byte[] hash = getSha256(decoded, 0, 21, 2); + return hash != null && Arrays.equals(Arrays.copyOfRange(hash, 0, 4), Arrays.copyOfRange(decoded, 21, 25)); + } + + private static byte[] decodeBase58(String input, int base, int len) { + byte[] output = new byte[len]; + for (int i = 0; i < input.length(); i++) { + char t = input.charAt(i); + + int p = ALPHABET.indexOf(t); + if (p == -1) return null; + for (int j = len - 1; j >= 0; j--, p /= 256) { + p += base * (output[j] & 0xFF); + output[j] = (byte) (p % 256); + } + if (p != 0) return null; + } + + return output; + } + + private static byte[] getSha256(byte[] data, int start, int len, int recursion) { + if (recursion == 0) return data; + + try { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + md.update(Arrays.copyOfRange(data, start, start + len)); + return getSha256(md.digest(), 0, 32, recursion - 1); + } catch (NoSuchAlgorithmException e) { + return null; + } + } + } + + + public static class PranacoinParams extends NetworkParametersAdapter { + + public PranacoinParams() { + addressHeader = 55; + p2shHeader = 5; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 59e72dc5..af085132 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("PASC", "Pascal Coin", true)); result.add(new CryptoCurrency("PEPECASH", "Pepe Cash")); result.add(new CryptoCurrency("POST", "PostCoin")); - result.add(new CryptoCurrency("PNC", "Pranacoin")); result.add(new CryptoCurrency("RDD", "ReddCoin")); result.add(new CryptoCurrency("REF", "RefToken", true)); result.add(new CryptoCurrency("SFSC", "Safe FileSystem Coin")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index daa9219f..90f7531d 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -21,7 +21,6 @@ import bisq.core.btc.BaseCurrencyNetwork; import bisq.core.locale.Res; import bisq.core.payment.validation.altcoins.KOTOAddressValidator; -import bisq.core.payment.validation.altcoins.PNCAddressValidator; import bisq.core.payment.validation.altcoins.WMCCAddressValidator; import bisq.core.payment.validation.altcoins.XCNAddressValidator; import bisq.core.payment.validation.altcoins.YTNAddressValidator; @@ -32,7 +31,6 @@ import bisq.core.payment.validation.params.ODNParams; import bisq.core.payment.validation.params.OnionParams; import bisq.core.payment.validation.params.PARTParams; -import bisq.core.payment.validation.params.PNCParams; import bisq.core.payment.validation.params.PhoreParams; import bisq.core.payment.validation.params.SpeedCashParams; import bisq.core.payment.validation.params.StrayaParams; @@ -106,21 +104,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "PNC": - if (input.matches("^[P3][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { - if (PNCAddressValidator.ValidateAddress(input)) { - try { - Address.fromBase58(PNCParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } - } else { - return wrongChecksum; - } - } else { - return regexTestFailed; - } case "WAC": try { Address.fromBase58(WACoinsParams.get(), input); diff --git a/src/main/java/bisq/core/payment/validation/altcoins/PNCAddressValidator.java b/src/main/java/bisq/core/payment/validation/altcoins/PNCAddressValidator.java deleted file mode 100644 index fec3ad73..00000000 --- a/src/main/java/bisq/core/payment/validation/altcoins/PNCAddressValidator.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.altcoins; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import java.util.Arrays; - -public class PNCAddressValidator { - private final static String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; - - public static boolean ValidateAddress(String addr) { - if (addr.length() < 26 || addr.length() > 35) return false; - byte[] decoded = decodeBase58(addr, 58, 25); - if (decoded == null) return false; - - byte[] hash = getSha256(decoded, 0, 21, 2); - return hash != null && Arrays.equals(Arrays.copyOfRange(hash, 0, 4), Arrays.copyOfRange(decoded, 21, 25)); - } - - private static byte[] decodeBase58(String input, int base, int len) { - byte[] output = new byte[len]; - for (int i = 0; i < input.length(); i++) { - char t = input.charAt(i); - - int p = ALPHABET.indexOf(t); - if (p == -1) return null; - for (int j = len - 1; j >= 0; j--, p /= 256) { - p += base * (output[j] & 0xFF); - output[j] = (byte) (p % 256); - } - if (p != 0) return null; - } - - return output; - } - - private static byte[] getSha256(byte[] data, int start, int len, int recursion) { - if (recursion == 0) return data; - - try { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - md.update(Arrays.copyOfRange(data, start, start + len)); - return getSha256(md.digest(), 0, 32, recursion - 1); - } catch (NoSuchAlgorithmException e) { - return null; - } - } -} diff --git a/src/main/java/bisq/core/payment/validation/params/PNCParams.java b/src/main/java/bisq/core/payment/validation/params/PNCParams.java deleted file mode 100644 index 904e91a4..00000000 --- a/src/main/java/bisq/core/payment/validation/params/PNCParams.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class PNCParams extends NetworkParameters { - - private static PNCParams instance; - - public static synchronized PNCParams get() { - if (instance == null) { - instance = new PNCParams(); - } - return instance; - } - - public PNCParams() { - super(); - addressHeader = 55; - p2shHeader = 5; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } - -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 4853f572..3aa7a1d2 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -19,6 +19,7 @@ bisq.asset.coins.Litecoin$Regtest bisq.asset.coins.Litecoin$Testnet bisq.asset.coins.Nxt bisq.asset.coins.Octocoin +bisq.asset.coins.Pranacoin bisq.asset.coins.PIVX bisq.asset.coins.Zcash bisq.asset.tokens.Ellaism diff --git a/src/test/java/bisq/asset/coins/PranacoinTest.java b/src/test/java/bisq/asset/coins/PranacoinTest.java new file mode 100644 index 00000000..d4202f23 --- /dev/null +++ b/src/test/java/bisq/asset/coins/PranacoinTest.java @@ -0,0 +1,43 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class PranacoinTest extends AbstractAssetTest { + + public PranacoinTest() { + super(new Pranacoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("3AB1qXhaU3hK5oAPQfwzN3QkM8LxAgL8vB"); + assertValidAddress("PD57PGdk69yioZ6FD3zFNzVUeJhMf6Kti4"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("3AB1qXhaU3hK5oAPQfwzN3QkM8LxAgL8v"); + assertInvalidAddress("PD57PGdk69yioZ6FD3zFNzVUeJhMf6Kti42"); + assertInvalidAddress("PD57PGdk69yioZ6FD3zFNzVUeJhMMMKti4"); + assertInvalidAddress("PD57PG"); + } +} From 44fa4b2c2eac7172da23d09a74e63f54eacab73f Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 12:52:50 +0200 Subject: [PATCH 021/106] Extract Wacoin --- src/main/java/bisq/asset/coins/Wacoin.java | 40 ++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 8 -- .../validation/params/WACoinsParams.java | 93 ------------------- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/WacoinTest.java | 43 +++++++++ 6 files changed, 84 insertions(+), 102 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Wacoin.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/WACoinsParams.java create mode 100644 src/test/java/bisq/asset/coins/WacoinTest.java diff --git a/src/main/java/bisq/asset/coins/Wacoin.java b/src/main/java/bisq/asset/coins/Wacoin.java new file mode 100644 index 00000000..055467db --- /dev/null +++ b/src/main/java/bisq/asset/coins/Wacoin.java @@ -0,0 +1,40 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class Wacoin extends Coin { + + public Wacoin() { + super("WACoins", "WAC", new Base58BitcoinAddressValidator(new WacoinParams())); + } + + + public static class WacoinParams extends NetworkParametersAdapter { + + public WacoinParams() { + super(); + addressHeader = 73; + p2shHeader = 3; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index af085132..42081468 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -152,7 +152,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("UNO", "Unobtanium")); result.add(new CryptoCurrency("CRED", "Verify", true)); - result.add(new CryptoCurrency("WAC", "WACoins")); result.add(new CryptoCurrency("WILD", "WILD Token", true)); result.add(new CryptoCurrency("XZC", "Zcoin")); result.add(new CryptoCurrency("ZEN", "ZenCash")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 90f7531d..2a39bc8b 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -35,7 +35,6 @@ import bisq.core.payment.validation.params.SpeedCashParams; import bisq.core.payment.validation.params.StrayaParams; import bisq.core.payment.validation.params.TerracoinParams; -import bisq.core.payment.validation.params.WACoinsParams; import bisq.core.payment.validation.params.WMCCParams; import bisq.core.payment.validation.params.XspecParams; import bisq.core.payment.validation.params.btc.BTGParams; @@ -104,13 +103,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "WAC": - try { - Address.fromBase58(WACoinsParams.get(), input); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } - return new ValidationResult(true); case "ZEN": try { // Get the non Base58 form of the address and the bytecode of the first two bytes diff --git a/src/main/java/bisq/core/payment/validation/params/WACoinsParams.java b/src/main/java/bisq/core/payment/validation/params/WACoinsParams.java deleted file mode 100644 index 4ff44527..00000000 --- a/src/main/java/bisq/core/payment/validation/params/WACoinsParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class WACoinsParams extends NetworkParameters { - - private static WACoinsParams instance; - - public static synchronized WACoinsParams get() { - if (instance == null) { - instance = new WACoinsParams(); - } - return instance; - } - - // We only use the properties needed for address validation - public WACoinsParams() { - super(); - addressHeader = 73; - p2shHeader = 3; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - // default dummy implementations, not used... - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 3aa7a1d2..e087459e 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -21,5 +21,6 @@ bisq.asset.coins.Nxt bisq.asset.coins.Octocoin bisq.asset.coins.Pranacoin bisq.asset.coins.PIVX +bisq.asset.coins.Wacoin bisq.asset.coins.Zcash bisq.asset.tokens.Ellaism diff --git a/src/test/java/bisq/asset/coins/WacoinTest.java b/src/test/java/bisq/asset/coins/WacoinTest.java new file mode 100644 index 00000000..2bab95b3 --- /dev/null +++ b/src/test/java/bisq/asset/coins/WacoinTest.java @@ -0,0 +1,43 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class WacoinTest extends AbstractAssetTest { + + public WacoinTest() { + super(new Wacoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("WfEnB3VGrBqW7uamJMymymEwxMBYQKELKY"); + assertValidAddress("WTLWtNN5iJJQyTeMfZMMrfrDvdGZrYGP5U"); + assertValidAddress("WemK3MgwREsEaF4vdtYLxmMqAXp49C2LYQ"); + assertValidAddress("WZggcFY5cJdAxx9unBW5CVPAH8VLTxZ6Ym"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("abcde"); + assertInvalidAddress("mWvZ7nZAUzpRMFp2Bfjxz27Va47nUfB79E"); + assertInvalidAddress("WemK3MgwREsE23fgsadtYLxmMqAX9C2LYQ"); + }} From 267261bcee91f74a46d0dd69ff69bca7549e355e Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 13:37:17 +0200 Subject: [PATCH 022/106] Extract ZenCash --- src/main/java/bisq/asset/coins/ZenCash.java | 67 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 29 -------- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/ZenCashTest.java | 45 +++++++++++++ 5 files changed, 113 insertions(+), 30 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/ZenCash.java create mode 100644 src/test/java/bisq/asset/coins/ZenCashTest.java diff --git a/src/main/java/bisq/asset/coins/ZenCash.java b/src/main/java/bisq/asset/coins/ZenCash.java new file mode 100644 index 00000000..15db3ac4 --- /dev/null +++ b/src/main/java/bisq/asset/coins/ZenCash.java @@ -0,0 +1,67 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.AddressValidator; +import bisq.asset.Coin; + +import org.bitcoinj.core.AddressFormatException; +import org.bitcoinj.core.Base58; + +public class ZenCash extends Coin { + + public ZenCash() { + super("ZenCash", "ZEN", new ZenCashAddressValidator()); + } + + + public static class ZenCashAddressValidator implements AddressValidator { + + @Override + public AddressValidationResult validate(String address) { + byte[] byteAddress; + try { + // Get the non Base58 form of the address and the bytecode of the first two bytes + byteAddress = Base58.decodeChecked(address); + } catch (AddressFormatException e) { + // Unhandled Exception (probably a checksum error) + return AddressValidationResult.invalidAddress(e); + } + int version0 = byteAddress[0] & 0xFF; + int version1 = byteAddress[1] & 0xFF; + + // We only support public ("zn" (0x20,0x89), "t1" (0x1C,0xB8)) + // and multisig ("zs" (0x20,0x96), "t3" (0x1C,0xBD)) addresses + + // Fail for private addresses + if (version0 == 0x16 && version1 == 0x9A) { + // Address starts with "zc" + return AddressValidationResult.invalidAddress("", "validation.altcoin.zAddressesNotSupported"); + } else if (version0 == 0x1C && (version1 == 0xB8 || version1 == 0xBD)) { + // "t1" or "t3" address + return AddressValidationResult.validAddress(); + } else if (version0 == 0x20 && (version1 == 0x89 || version1 == 0x96)) { + // "zn" or "zs" address + return AddressValidationResult.validAddress(); + } + // Unknown Type + return AddressValidationResult.invalidStructure(); + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 42081468..34086d18 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -154,7 +154,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("CRED", "Verify", true)); result.add(new CryptoCurrency("WILD", "WILD Token", true)); result.add(new CryptoCurrency("XZC", "Zcoin")); - result.add(new CryptoCurrency("ZEN", "ZenCash")); // Added 0.6.6 result.add(new CryptoCurrency("STL", "Stellite")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 2a39bc8b..d73165de 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -48,7 +48,6 @@ import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; -import org.bitcoinj.core.Base58; import com.google.inject.Inject; @@ -103,34 +102,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "ZEN": - try { - // Get the non Base58 form of the address and the bytecode of the first two bytes - byte[] byteAddress = Base58.decodeChecked(input); - int version0 = byteAddress[0] & 0xFF; - int version1 = byteAddress[1] & 0xFF; - - // We only support public ("zn" (0x20,0x89), "t1" (0x1C,0xB8)) - // and multisig ("zs" (0x20,0x96), "t3" (0x1C,0xBD)) addresses - - // Fail for private addresses - if (version0 == 0x16 && version1 == 0x9A) { - // Address starts with "zc" - return new ValidationResult(false, Res.get("validation.altcoin.zAddressesNotSupported")); - } else if (version0 == 0x1C && (version1 == 0xB8 || version1 == 0xBD)) { - // "t1" or "t3" address - return new ValidationResult(true); - } else if (version0 == 0x20 && (version1 == 0x89 || version1 == 0x96)) { - // "zn" or "zs" address - return new ValidationResult(true); - } else { - // Unknown Type - return new ValidationResult(false); - } - } catch (AddressFormatException e) { - // Unhandled Exception (probably a checksum error) - return new ValidationResult(false); - } case "XCN": // https://bitcointalk.org/index.php?topic=1801595 return XCNAddressValidator.ValidateAddress(input); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index e087459e..c03875ed 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -23,4 +23,5 @@ bisq.asset.coins.Pranacoin bisq.asset.coins.PIVX bisq.asset.coins.Wacoin bisq.asset.coins.Zcash +bisq.asset.coins.ZenCash bisq.asset.tokens.Ellaism diff --git a/src/test/java/bisq/asset/coins/ZenCashTest.java b/src/test/java/bisq/asset/coins/ZenCashTest.java new file mode 100644 index 00000000..c25d8b7a --- /dev/null +++ b/src/test/java/bisq/asset/coins/ZenCashTest.java @@ -0,0 +1,45 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class ZenCashTest extends AbstractAssetTest { + + public ZenCashTest() { + super(new ZenCash()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("znk62Ey7ptTyHgYLaLDTEwhLF6uN1DXTBfa"); + assertValidAddress("znTqzi5rTXf6KJnX5tLaC5CMGHfeWJwy1c7"); + assertValidAddress("t1V9h2P9n4sYg629Xn4jVDPySJJxGmPb1HK"); + assertValidAddress("t3Ut4KUq2ZSMTPNE67pBU5LqYCi2q36KpXQ"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("zcKffBrza1cirFY47aKvXiV411NZMscf7zUY5bD1HwvkoQvKHgpxLYUHtMCLqBAeif1VwHmMjrMAKNrdCknCVqCzRNizHUq"); + assertInvalidAddress("AFTqzi5rTXf6KJnX5tLaC5CMGHfeWJwy1c7"); + assertInvalidAddress("zig-zag"); + assertInvalidAddress("0123456789"); + } +} From 956a5c60c9d2ed6ede6bff84ed534906093c1f5a Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 13:58:50 +0200 Subject: [PATCH 023/106] Extract Cryptonite --- .../java/bisq/asset/coins/Cryptonite.java | 90 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 4 - .../altcoins/XCNAddressValidator.java | 76 ---------------- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/CryptoniteTest.java | 49 ++++++++++ 6 files changed, 140 insertions(+), 81 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Cryptonite.java delete mode 100644 src/main/java/bisq/core/payment/validation/altcoins/XCNAddressValidator.java create mode 100644 src/test/java/bisq/asset/coins/CryptoniteTest.java diff --git a/src/main/java/bisq/asset/coins/Cryptonite.java b/src/main/java/bisq/asset/coins/Cryptonite.java new file mode 100644 index 00000000..7537765b --- /dev/null +++ b/src/main/java/bisq/asset/coins/Cryptonite.java @@ -0,0 +1,90 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.AddressValidator; +import bisq.asset.Coin; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import java.util.Arrays; + +public class Cryptonite extends Coin { + + public Cryptonite() { + super("Cryptonite", "XCN", new CryptoniteAddressValidator()); + } + + + public static class CryptoniteAddressValidator implements AddressValidator { + + private final static String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; + + @Override + public AddressValidationResult validate(String address) { + // https://bitcointalk.org/index.php?topic=1801595 + if (address.length() != 34) + return AddressValidationResult.invalidAddress("XCN_Addr_Invalid: Length must be 34!"); + if (!address.startsWith("C")) + return AddressValidationResult.invalidAddress("XCN_Addr_Invalid: must start with 'C'!"); + byte[] decoded = decodeBase58(address); + if (decoded == null) + return AddressValidationResult.invalidAddress("XCN_Addr_Invalid: Base58 decoder error!"); + + byte[] hash = getSha256(decoded, 21, 2); + if (hash == null || !Arrays.equals(Arrays.copyOfRange(hash, 0, 4), Arrays.copyOfRange(decoded, 21, 25))) + return AddressValidationResult.invalidAddress("XCN_Addr_Invalid: Checksum error!"); + return AddressValidationResult.validAddress(); + + } + + private static byte[] decodeBase58(String input) { + byte[] output = new byte[25]; + for (int i = 0; i < input.length(); i++) { + char t = input.charAt(i); + + int p = ALPHABET.indexOf(t); + if (p == -1) + return null; + for (int j = 25 - 1; j >= 0; j--, p /= 256) { + p += 58 * (output[j] & 0xFF); + output[j] = (byte) (p % 256); + } + if (p != 0) + return null; + } + + return output; + } + + private static byte[] getSha256(byte[] data, int len, int recursion) { + if (recursion == 0) + return data; + + try { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + md.update(Arrays.copyOfRange(data, 0, len)); + return getSha256(md.digest(), 32, recursion - 1); + } catch (NoSuchAlgorithmException e) { + return null; + } + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 34086d18..16b523e8 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -114,7 +114,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("CAGE", "Cagecoin")); result.add(new CryptoCurrency("XCP", "Counterparty")); result.add(new CryptoCurrency("CREA", "Creativecoin")); - result.add(new CryptoCurrency("XCN", "Cryptonite")); result.add(new CryptoCurrency("DNET", "DarkNet")); result.add(new CryptoCurrency("DCR", "Decred")); result.add(new CryptoCurrency("ONION", "DeepOnion")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index d73165de..feae5eca 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -22,7 +22,6 @@ import bisq.core.locale.Res; import bisq.core.payment.validation.altcoins.KOTOAddressValidator; import bisq.core.payment.validation.altcoins.WMCCAddressValidator; -import bisq.core.payment.validation.altcoins.XCNAddressValidator; import bisq.core.payment.validation.altcoins.YTNAddressValidator; import bisq.core.payment.validation.params.ACHParams; import bisq.core.payment.validation.params.AlcParams; @@ -102,9 +101,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "XCN": - // https://bitcointalk.org/index.php?topic=1801595 - return XCNAddressValidator.ValidateAddress(input); case "TRC": try { Address.fromBase58(TerracoinParams.get(), input); diff --git a/src/main/java/bisq/core/payment/validation/altcoins/XCNAddressValidator.java b/src/main/java/bisq/core/payment/validation/altcoins/XCNAddressValidator.java deleted file mode 100644 index 3d3274c4..00000000 --- a/src/main/java/bisq/core/payment/validation/altcoins/XCNAddressValidator.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with bisq. If not, see . - */ - -package bisq.core.payment.validation.altcoins; - -import bisq.core.util.validation.InputValidator.ValidationResult; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import java.util.Arrays; - -public class XCNAddressValidator { - private final static String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; - - public static ValidationResult ValidateAddress(String addr) { - if (addr.length() != 34) - return new ValidationResult(false, "XCN_Addr_Invalid: Length must be 34!"); - if (!addr.startsWith("C")) - return new ValidationResult(false, "XCN_Addr_Invalid: must start with 'C'!"); - byte[] decoded = decodeBase58(addr, 58, 25); - if (decoded == null) - return new ValidationResult(false, "XCN_Addr_Invalid: Base58 decoder error!"); - - byte[] hash = getSha256(decoded, 0, 21, 2); - if (hash == null || !Arrays.equals(Arrays.copyOfRange(hash, 0, 4), Arrays.copyOfRange(decoded, 21, 25))) - return new ValidationResult(false, "XCN_Addr_Invalid: Checksum error!"); - return new ValidationResult(true); - } - - private static byte[] decodeBase58(String input, int base, int len) { - byte[] output = new byte[len]; - for (int i = 0; i < input.length(); i++) { - char t = input.charAt(i); - - int p = ALPHABET.indexOf(t); - if (p == -1) - return null; - for (int j = len - 1; j >= 0; j--, p /= 256) { - p += base * (output[j] & 0xFF); - output[j] = (byte) (p % 256); - } - if (p != 0) - return null; - } - - return output; - } - - private static byte[] getSha256(byte[] data, int start, int len, int recursion) { - if (recursion == 0) - return data; - - try { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - md.update(Arrays.copyOfRange(data, start, start + len)); - return getSha256(md.digest(), 0, 32, recursion - 1); - } catch (NoSuchAlgorithmException e) { - return null; - } - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index c03875ed..47e61152 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -6,6 +6,7 @@ bisq.asset.coins.Bitcoin$Regtest bisq.asset.coins.Bitcoin$Testnet bisq.asset.coins.BitcoinCash bisq.asset.coins.Byteball +bisq.asset.coins.Cryptonite bisq.asset.coins.Dash$Mainnet bisq.asset.coins.Dash$Regtest bisq.asset.coins.Dash$Testnet diff --git a/src/test/java/bisq/asset/coins/CryptoniteTest.java b/src/test/java/bisq/asset/coins/CryptoniteTest.java new file mode 100644 index 00000000..85c3ee77 --- /dev/null +++ b/src/test/java/bisq/asset/coins/CryptoniteTest.java @@ -0,0 +1,49 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class CryptoniteTest extends AbstractAssetTest { + + public CryptoniteTest() { + super(new Cryptonite()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("CT49DTNo5itqYoAD6XTGyTKbe8z5nGY2D5"); + assertValidAddress("CGTta3M4t3yXu8uRgkKvaWd2d8DQvDPnpL"); + assertValidAddress("Cco3zGiEJMyz3wrndEr6wg5cm1oUAbBoR2"); + assertValidAddress("CPzmjGCDEdQuRffmbpkrYQtSiUAm4oZJgt"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("CT49DTNo5itqYoAD6XTGyTKbe8z5nGY2D4"); + assertInvalidAddress("CGTta3M4t3yXu8uRgkKvaWd2d8DQvDPnpl"); + assertInvalidAddress("Cco3zGiEJMyz3wrndEr6wg5cm1oUAbBoR1"); + assertInvalidAddress("CPzmjGCDEdQuRffmbpkrYQtSiUAm4oZJgT"); + assertInvalidAddress("CT49DTNo5itqYoAD6XTGyTKbe8z5nGY2Da"); + assertInvalidAddress("asdasd"); + assertInvalidAddress("cT49DTNo5itqYoAD6XTGyTKbe8z5nGY2Da"); + assertInvalidAddress("No5itqYoAD6XTGyTKbe8z5nGY2Da"); + } +} From f43d9fa6b0ab094c9eae9d63695bf77585b75bb7 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 14:03:02 +0200 Subject: [PATCH 024/106] Extract Terracoin --- src/main/java/bisq/asset/coins/Terracoin.java | 40 ++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 8 -- .../validation/params/TerracoinParams.java | 93 ------------------- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/TerracoinTest.java | 46 +++++++++ 6 files changed, 87 insertions(+), 102 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Terracoin.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/TerracoinParams.java create mode 100644 src/test/java/bisq/asset/coins/TerracoinTest.java diff --git a/src/main/java/bisq/asset/coins/Terracoin.java b/src/main/java/bisq/asset/coins/Terracoin.java new file mode 100644 index 00000000..bc8070d1 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Terracoin.java @@ -0,0 +1,40 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class Terracoin extends Coin { + + public Terracoin() { + super("Terracoin", "TRC", new Base58BitcoinAddressValidator(new TerracoinParams())); + } + + + public static class TerracoinParams extends NetworkParametersAdapter { + + public TerracoinParams() { + super(); + addressHeader = 0; + p2shHeader = 5; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 16b523e8..da25f45f 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -146,7 +146,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XSPEC", "Spectrecoin")); result.add(new CryptoCurrency("STEEM", "STEEM")); - result.add(new CryptoCurrency("TRC", "Terracoin")); result.add(new CryptoCurrency("MVT", "The Movement", true)); result.add(new CryptoCurrency("UNO", "Unobtanium")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index feae5eca..0fde0583 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -33,7 +33,6 @@ import bisq.core.payment.validation.params.PhoreParams; import bisq.core.payment.validation.params.SpeedCashParams; import bisq.core.payment.validation.params.StrayaParams; -import bisq.core.payment.validation.params.TerracoinParams; import bisq.core.payment.validation.params.WMCCParams; import bisq.core.payment.validation.params.XspecParams; import bisq.core.payment.validation.params.btc.BTGParams; @@ -101,13 +100,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "TRC": - try { - Address.fromBase58(TerracoinParams.get(), input); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } - return new ValidationResult(true); case "INXT": if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) return regexTestFailed; diff --git a/src/main/java/bisq/core/payment/validation/params/TerracoinParams.java b/src/main/java/bisq/core/payment/validation/params/TerracoinParams.java deleted file mode 100644 index 74a8a026..00000000 --- a/src/main/java/bisq/core/payment/validation/params/TerracoinParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class TerracoinParams extends NetworkParameters { - - private static TerracoinParams instance; - - public static synchronized TerracoinParams get() { - if (instance == null) { - instance = new TerracoinParams(); - } - return instance; - } - - // We only use the properties needed for address validation - public TerracoinParams() { - super(); - addressHeader = 0; - p2shHeader = 5; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - // default dummy implementations, not used... - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 47e61152..84708da7 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -22,6 +22,7 @@ bisq.asset.coins.Nxt bisq.asset.coins.Octocoin bisq.asset.coins.Pranacoin bisq.asset.coins.PIVX +bisq.asset.coins.Terracoin bisq.asset.coins.Wacoin bisq.asset.coins.Zcash bisq.asset.coins.ZenCash diff --git a/src/test/java/bisq/asset/coins/TerracoinTest.java b/src/test/java/bisq/asset/coins/TerracoinTest.java new file mode 100644 index 00000000..fdde5312 --- /dev/null +++ b/src/test/java/bisq/asset/coins/TerracoinTest.java @@ -0,0 +1,46 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class TerracoinTest extends AbstractAssetTest { + + public TerracoinTest() { + super(new Terracoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("1Bys8pZaKo4GTWcpArMg92cBgYqij8mKXt"); + assertValidAddress("12Ycuof6g5GRyWy56eQ3NvJpwAM8z9pb4g"); + assertValidAddress("1DEBTTVCn1h9bQS9scVP6UjoSsjbtJBvXF"); + assertValidAddress("18s142HdWDfDQXYBpuyMvsU3KHwryLxnCr"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("18s142HdWDfDQXYBpyuMvsU3KHwryLxnCr"); + assertInvalidAddress("18s142HdWDfDQXYBpuyMvsU3KHwryLxnC"); + assertInvalidAddress("8s142HdWDfDQXYBpuyMvsU3KHwryLxnCr"); + assertInvalidAddress("18s142HdWDfDQXYBuyMvsU3KHwryLxnCr"); + assertInvalidAddress("1asdasd"); + assertInvalidAddress("asdasd"); + }} From 0f5c3aaf90c620277d5a5444237547f3f3ce4c96 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 14:10:40 +0200 Subject: [PATCH 025/106] Extract Internext --- .../java/bisq/asset/tokens/Internext.java | 28 +++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 --- .../META-INF/services/bisq.asset.Asset | 3 +- .../java/bisq/asset/tokens/InternextTest.java | 42 +++++++++++++++++++ 5 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 src/main/java/bisq/asset/tokens/Internext.java create mode 100644 src/test/java/bisq/asset/tokens/InternextTest.java diff --git a/src/main/java/bisq/asset/tokens/Internext.java b/src/main/java/bisq/asset/tokens/Internext.java new file mode 100644 index 00000000..2265948b --- /dev/null +++ b/src/main/java/bisq/asset/tokens/Internext.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.Erc20Token; + +public class Internext extends Erc20Token { + + public Internext() { + super("Internext", "INXT"); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index da25f45f..f4569586 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -121,7 +121,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("ESP", "Espers")); result.add(new CryptoCurrency("ETC", "Ether Classic")); result.add(new CryptoCurrency("XIN", "Infinity Economics")); - result.add(new CryptoCurrency("INXT", "Internext", true)); result.add(new CryptoCurrency("GRC", "Gridcoin")); result.add(new CryptoCurrency("LBC", "LBRY Credits")); result.add(new CryptoCurrency("LSK", "Lisk")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 0fde0583..befe997c 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -100,11 +100,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "INXT": - if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) - return regexTestFailed; - else - return new ValidationResult(true); case "PART": if (input.matches("^[RP][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { //noinspection ConstantConditions diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 84708da7..adf2ce12 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -13,8 +13,8 @@ bisq.asset.coins.Dash$Testnet bisq.asset.coins.Decent bisq.asset.coins.Dogecoin bisq.asset.coins.Ether -bisq.asset.coins.InternetOfPeople bisq.asset.coins.Instacash +bisq.asset.coins.InternetOfPeople bisq.asset.coins.Litecoin$Mainnet bisq.asset.coins.Litecoin$Regtest bisq.asset.coins.Litecoin$Testnet @@ -27,3 +27,4 @@ bisq.asset.coins.Wacoin bisq.asset.coins.Zcash bisq.asset.coins.ZenCash bisq.asset.tokens.Ellaism +bisq.asset.tokens.Internext diff --git a/src/test/java/bisq/asset/tokens/InternextTest.java b/src/test/java/bisq/asset/tokens/InternextTest.java new file mode 100644 index 00000000..718bbd7e --- /dev/null +++ b/src/test/java/bisq/asset/tokens/InternextTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class InternextTest extends AbstractAssetTest { + + public InternextTest() { + super(new Internext()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("0x2a65Aca4D5fC5B5C859090a6c34d164135398226"); + assertValidAddress("2a65Aca4D5fC5B5C859090a6c34d164135398226"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d1641353982266"); + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + assertInvalidAddress("2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + } +} From da62f3a8b4be3bbc24e4731904ca76a6d64be12c Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 14:27:59 +0200 Subject: [PATCH 026/106] Extract Particl --- src/main/java/bisq/asset/coins/Particl.java | 55 +++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 13 --- .../payment/validation/params/PARTParams.java | 93 ------------------- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/ParticlTest.java | 44 +++++++++ 6 files changed, 100 insertions(+), 107 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Particl.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/PARTParams.java create mode 100644 src/test/java/bisq/asset/coins/ParticlTest.java diff --git a/src/main/java/bisq/asset/coins/Particl.java b/src/main/java/bisq/asset/coins/Particl.java new file mode 100644 index 00000000..c4fdcc2a --- /dev/null +++ b/src/main/java/bisq/asset/coins/Particl.java @@ -0,0 +1,55 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class Particl extends Coin { + + public Particl() { + super("Particl", "PART", new ParticlAddressValidator()); + } + + + public static class ParticlAddressValidator extends Base58BitcoinAddressValidator { + + public ParticlAddressValidator() { + super(new ParticlParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[RP][a-km-zA-HJ-NP-Z1-9]{25,34}$")) + return AddressValidationResult.invalidStructure(); + return super.validate(address); + } + } + + + public static class ParticlParams extends NetworkParametersAdapter { + + public ParticlParams() { + addressHeader = 56; + p2shHeader = 60; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index f4569586..99f0d71e 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -132,7 +132,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("NMC", "Namecoin")); result.add(new CryptoCurrency("NBT", "NuBits")); result.add(new CryptoCurrency("888", "OctoCoin")); - result.add(new CryptoCurrency("PART", "Particl")); result.add(new CryptoCurrency("PASC", "Pascal Coin", true)); result.add(new CryptoCurrency("PEPECASH", "Pepe Cash")); result.add(new CryptoCurrency("POST", "PostCoin")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index befe997c..aadfc56d 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -29,7 +29,6 @@ import bisq.core.payment.validation.params.CreaParams; import bisq.core.payment.validation.params.ODNParams; import bisq.core.payment.validation.params.OnionParams; -import bisq.core.payment.validation.params.PARTParams; import bisq.core.payment.validation.params.PhoreParams; import bisq.core.payment.validation.params.SpeedCashParams; import bisq.core.payment.validation.params.StrayaParams; @@ -100,18 +99,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "PART": - if (input.matches("^[RP][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { - //noinspection ConstantConditions - try { - Address.fromBase58(PARTParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } - } else { - return regexTestFailed; - } case "MDC": if (input.matches("^m[a-zA-Z0-9]{26,33}$")) return new ValidationResult(true); diff --git a/src/main/java/bisq/core/payment/validation/params/PARTParams.java b/src/main/java/bisq/core/payment/validation/params/PARTParams.java deleted file mode 100644 index 8ef5d70e..00000000 --- a/src/main/java/bisq/core/payment/validation/params/PARTParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class PARTParams extends NetworkParameters { - - private static PARTParams instance; - - public static synchronized PARTParams get() { - if (instance == null) { - instance = new PARTParams(); - } - return instance; - } - - // We only use the properties needed for address validation - public PARTParams() { - super(); - addressHeader = 56; - p2shHeader = 60; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - // default dummy implementations, not used... - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index adf2ce12..2e5f0d93 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -20,6 +20,7 @@ bisq.asset.coins.Litecoin$Regtest bisq.asset.coins.Litecoin$Testnet bisq.asset.coins.Nxt bisq.asset.coins.Octocoin +bisq.asset.coins.Particl bisq.asset.coins.Pranacoin bisq.asset.coins.PIVX bisq.asset.coins.Terracoin diff --git a/src/test/java/bisq/asset/coins/ParticlTest.java b/src/test/java/bisq/asset/coins/ParticlTest.java new file mode 100644 index 00000000..9e7a3985 --- /dev/null +++ b/src/test/java/bisq/asset/coins/ParticlTest.java @@ -0,0 +1,44 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class ParticlTest extends AbstractAssetTest { + + public ParticlTest() { + super(new Particl()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("PZdYWHgyhuG7NHVCzEkkx3dcLKurTpvmo6"); + assertValidAddress("RJAPhgckEgRGVPZa9WoGSWW24spskSfLTQ"); + assertValidAddress("PaqMewoBY4vufTkKeSy91su3CNwviGg4EK"); + assertValidAddress("PpWHwrkUKRYvbZbTic57YZ1zjmsV9X9Wu7"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq"); + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYheO"); + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhek"); + } +} From 8e67b8b071c2465cd7dd79217901951e262e756d Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 14:30:51 +0200 Subject: [PATCH 027/106] Extract Madcoin --- src/main/java/bisq/asset/coins/Madcoin.java | 29 +++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 --- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/MadcoinTest.java | 42 +++++++++++++++++++ 5 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Madcoin.java create mode 100644 src/test/java/bisq/asset/coins/MadcoinTest.java diff --git a/src/main/java/bisq/asset/coins/Madcoin.java b/src/main/java/bisq/asset/coins/Madcoin.java new file mode 100644 index 00000000..34b1b8b5 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Madcoin.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.RegexAddressValidator; + +public class Madcoin extends Coin { + + public Madcoin() { + super("Madcoin", "MDC", new RegexAddressValidator("^m[a-zA-Z0-9]{26,33}$")); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 99f0d71e..b9908c50 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -125,7 +125,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("LBC", "LBRY Credits")); result.add(new CryptoCurrency("LSK", "Lisk")); result.add(new CryptoCurrency("MAID", "MaidSafeCoin")); - result.add(new CryptoCurrency("MDC", "Madcoin")); result.add(new CryptoCurrency("XMR", "Monero")); result.add(new CryptoCurrency("MT", "Mycelium Token", true)); result.add(new CryptoCurrency("NAV", "Nav Coin")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index aadfc56d..44ba1be6 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -99,11 +99,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "MDC": - if (input.matches("^m[a-zA-Z0-9]{26,33}$")) - return new ValidationResult(true); - else - return regexTestFailed; case "BCHC": try { Address.fromBase58(BtcMainNetParamsForValidation.get(), input); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 2e5f0d93..47f19d4d 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -18,6 +18,7 @@ bisq.asset.coins.InternetOfPeople bisq.asset.coins.Litecoin$Mainnet bisq.asset.coins.Litecoin$Regtest bisq.asset.coins.Litecoin$Testnet +bisq.asset.coins.Madcoin bisq.asset.coins.Nxt bisq.asset.coins.Octocoin bisq.asset.coins.Particl diff --git a/src/test/java/bisq/asset/coins/MadcoinTest.java b/src/test/java/bisq/asset/coins/MadcoinTest.java new file mode 100644 index 00000000..b618979e --- /dev/null +++ b/src/test/java/bisq/asset/coins/MadcoinTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class MadcoinTest extends AbstractAssetTest { + + public MadcoinTest() { + super(new Madcoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("mHUisRLQ4vMXrWrVfGfiEHuD3KZqiUNvzH"); + assertValidAddress("mHbicWaTXNJDbeM6KXCit5JcmvMypwpq8T"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("LzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhe"); + assertInvalidAddress("miCVC7QcY917Cz427qTB"); + assertInvalidAddress("12KYrjTdVGjFMtaxERSk3gphreJ5US8aUP"); + } +} From 64c947af7fd64946f360515b5ffb8e2cbeb58bae Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 14:56:00 +0200 Subject: [PATCH 028/106] Extract Bitcoin Clashic --- .../java/bisq/asset/coins/BitcoinClashic.java | 30 ++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 8 - .../btc/BtcMainNetParamsForValidation.java | 163 ------------------ .../META-INF/services/bisq.asset.Asset | 1 + .../bisq/asset/coins/BitcoinClashicTest.java | 43 +++++ 6 files changed, 74 insertions(+), 172 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/BitcoinClashic.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/btc/BtcMainNetParamsForValidation.java create mode 100644 src/test/java/bisq/asset/coins/BitcoinClashicTest.java diff --git a/src/main/java/bisq/asset/coins/BitcoinClashic.java b/src/main/java/bisq/asset/coins/BitcoinClashic.java new file mode 100644 index 00000000..9eced4c5 --- /dev/null +++ b/src/main/java/bisq/asset/coins/BitcoinClashic.java @@ -0,0 +1,30 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; + +import org.bitcoinj.params.MainNetParams; + +public class BitcoinClashic extends Coin { + + public BitcoinClashic() { + super("Bitcoin Clashic", "BCHC", new Base58BitcoinAddressValidator(new MainNetParams())); + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index b9908c50..d09af3d8 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -108,7 +108,6 @@ private static List createAllSortedCryptoCurrenciesList() { .collect(Collectors.toList()); result.add(new CryptoCurrency("BETR", "Better Betting", true)); - result.add(new CryptoCurrency("BCHC", "Bitcoin Clashic")); result.add(new CryptoCurrency("BTG", "Bitcoin Gold")); result.add(new CryptoCurrency("BURST", "Burstcoin")); result.add(new CryptoCurrency("CAGE", "Cagecoin")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 44ba1be6..54c4a101 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -35,7 +35,6 @@ import bisq.core.payment.validation.params.WMCCParams; import bisq.core.payment.validation.params.XspecParams; import bisq.core.payment.validation.params.btc.BTGParams; -import bisq.core.payment.validation.params.btc.BtcMainNetParamsForValidation; import bisq.core.util.validation.InputValidator; import bisq.asset.AddressValidationResult; @@ -99,13 +98,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "BCHC": - try { - Address.fromBase58(BtcMainNetParamsForValidation.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } case "BTG": try { Address.fromBase58(BTGParams.get(), input); diff --git a/src/main/java/bisq/core/payment/validation/params/btc/BtcMainNetParamsForValidation.java b/src/main/java/bisq/core/payment/validation/params/btc/BtcMainNetParamsForValidation.java deleted file mode 100644 index 76428f1e..00000000 --- a/src/main/java/bisq/core/payment/validation/params/btc/BtcMainNetParamsForValidation.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -/* - * Copyright 2013 Google Inc. - * Copyright 2015 Andreas Schildbach - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package bisq.core.payment.validation.params.btc; - -import org.bitcoinj.core.ECKey; -import org.bitcoinj.core.Sha256Hash; -import org.bitcoinj.core.Utils; -import org.bitcoinj.net.discovery.HttpDiscovery; - -import java.net.URI; - -import static com.google.common.base.Preconditions.checkState; - -/** - * Parameters for the main production network on which people trade goods and services. - *

- * We cannot use MainNetParams because that would be one of the other base currencies, - * so we cloned the MainNetParams to BtcMainNetParamsForValidation - */ -public class BtcMainNetParamsForValidation extends AbstractBitcoinNetParams { - public static final int MAINNET_MAJORITY_WINDOW = 1000; - public static final int MAINNET_MAJORITY_REJECT_BLOCK_OUTDATED = 950; - public static final int MAINNET_MAJORITY_ENFORCE_BLOCK_UPGRADE = 750; - - public BtcMainNetParamsForValidation() { - super(); - interval = INTERVAL; - targetTimespan = TARGET_TIMESPAN; - maxTarget = Utils.decodeCompactBits(0x1d00ffffL); - dumpedPrivateKeyHeader = 128; - addressHeader = 0; - p2shHeader = 5; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - port = 8333; - packetMagic = 0xf9beb4d9L; - bip32HeaderPub = 0x0488B21E; //The 4 byte header that serializes in base58 to "xpub". - bip32HeaderPriv = 0x0488ADE4; //The 4 byte header that serializes in base58 to "xprv" - - majorityEnforceBlockUpgrade = MAINNET_MAJORITY_ENFORCE_BLOCK_UPGRADE; - majorityRejectBlockOutdated = MAINNET_MAJORITY_REJECT_BLOCK_OUTDATED; - majorityWindow = MAINNET_MAJORITY_WINDOW; - - genesisBlock.setDifficultyTarget(0x1d00ffffL); - genesisBlock.setTime(1231006505L); - genesisBlock.setNonce(2083236893); - id = ID_MAINNET; - subsidyDecreaseBlockCount = 210000; - spendableCoinbaseDepth = 100; - String genesisHash = genesisBlock.getHashAsString(); - checkState(genesisHash.equals("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"), - genesisHash); - - // This contains (at a minimum) the blocks which are not BIP30 compliant. BIP30 changed how duplicate - // transactions are handled. Duplicated transactions could occur in the case where a coinbase had the same - // extraNonce and the same outputs but appeared at different heights, and greatly complicated re-org handling. - // Having these here simplifies block connection logic considerably. - checkpoints.put(91722, Sha256Hash.wrap("00000000000271a2dc26e7667f8419f2e15416dc6955e5a6c6cdf3f2574dd08e")); - checkpoints.put(91812, Sha256Hash.wrap("00000000000af0aed4792b1acee3d966af36cf5def14935db8de83d6f9306f2f")); - checkpoints.put(91842, Sha256Hash.wrap("00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec")); - checkpoints.put(91880, Sha256Hash.wrap("00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721")); - checkpoints.put(200000, Sha256Hash.wrap("000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf")); - - dnsSeeds = new String[]{ - "seed.bitcoin.sipa.be", // Pieter Wuille - "dnsseed.bluematt.me", // Matt Corallo - "dnsseed.bitcoin.dashjr.org", // Luke Dashjr - "seed.bitcoinstats.com", // Chris Decker - "seed.bitnodes.io", // Addy Yeow - "bitseed.xf2.org", // Jeff Garzik - "seed.bitcoin.jonasschnelli.ch" // Jonas Schnelli - }; - httpSeeds = new HttpDiscovery.Details[]{ - // Andreas Schildbach - new HttpDiscovery.Details( - ECKey.fromPublicOnly(Utils.HEX.decode("0238746c59d46d5408bf8b1d0af5740fe1a6e1703fcb56b2953f0b965c740d256f")), - URI.create("http://httpseed.bitcoin.schildbach.de/peers") - ) - }; - - // note: These are in big-endian format, which is what the SeedPeers code expects. - // These values should be kept up-to-date as much as possible. - // - // these values were created using this tool: - // https://github.com/dan-da/names2ips - // - // with this exact command: - // $ ./names2ips.php --hostnames=seed.bitcoin.sipa.be,dnsseed.bluematt.me,dnsseed.bitcoin.dashjr.org,seed.bitcoinstats.com,seed.bitnodes.io --format=code --ipformat=hex --endian=big - - // Updated Nov. 4th 2017 - addrSeeds = new int[]{ - // -- seed.bitcoin.sipa.be -- - 0x254187d, 0x1af0735d, 0x20b72088, 0x30a1c321, 0x3515cb9f, 0x4539448a, 0x459caed5, - 0x4b0559d1, 0x5c88c9c1, 0x726fc523, 0x753b448a, 0x75b25c50, 0x7efc63b3, 0x8e79e849, - 0x914ff334, 0x93d60bc6, 0x9e1df618, 0xa7069f4b, 0xafbd5827, 0xb5a3ce62, 0xc635d054, - 0xc6fa4260, 0xc73aea63, 0xc7437558, 0xd78bbfd5, -// -- dnsseed.bluematt.me -- - 0x1a536adb, 0x20ecc692, 0x21117c4c, 0x4060d85b, 0x4a9caed5, 0x513caca3, 0x5a636358, - 0x675ad655, 0x75c0d4ad, 0xa5e3e8ad, 0xa6531525, 0xac08ab4c, 0xb2d7af41, 0xb4008bb9, - 0xb5064945, 0xc9fad02f, 0xcb59a28b, 0xd54ba834, 0xe04d0055, 0xed5d5848, 0xfb0a825e, -// -- dnsseed.bitcoin.dashjr.org -- - 0x858ba8c, 0xc201bb9, 0xdded4ad, 0x21fe312d, 0x330fc023, 0x4230b75f, 0x45667a7b, - 0x47370159, 0x64384e57, 0x67b1b14d, 0x6e2a0f33, 0x810c6e3b, 0x9f3a652e, 0xa0def550, - 0xab2d2d18, 0xb06a3850, 0xb7df01a9, 0xc8a8825e, 0xd3ace75c, 0xd5a0aa43, 0xdc0d599f, - 0xe1f00d47, 0xf1519f51, 0xfd83bd56, -// -- seed.bitcoinstats.com -- - 0x2e1ff68, 0x424bd6b, 0x7571e53, 0x14d33174, 0x18aac780, 0x1c5cd812, 0x40614032, - 0x40de1c4d, 0x688fd812, 0x73c6ffad, 0x7dc6ffad, 0x7ebd2149, 0x8c08d153, 0x90b5a6d3, - 0x986fd462, 0xae1c82aa, 0xbeffdc4a, 0xc0a1764b, 0xc0c0b1d3, 0xdff8c768, 0xe0e6a6d3, - 0xe23b0f34, 0xe35f372f, 0xe9ff4748, 0xeed8b943, -// -- seed.bitnodes.io -- - 0x4d3921f, 0xf480548, 0x1356b1d1, 0x1d25ddd8, 0x1d556056, 0x233d2567, 0x3058a2b2, - 0x3ee58c9e, 0x45ea0747, 0x4abd2088, 0x4d0d97d8, 0x5246b2b3, 0x5a0ae25b, 0x5a0ea9d9, - 0x5a55f450, 0x64610545, 0x6ed40d3e, 0x7a48cb4a, 0x98c5b35d, 0xaeb473bc, 0xdcefff86, - 0xe170d951, 0xe76280b2, 0xfa1f645e, 0xfb96466d, - }; - } - - private static BtcMainNetParamsForValidation instance; - - public static synchronized BtcMainNetParamsForValidation get() { - if (instance == null) { - instance = new BtcMainNetParamsForValidation(); - } - return instance; - } - - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 47f19d4d..a1932d44 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -5,6 +5,7 @@ bisq.asset.coins.Bitcoin$Mainnet bisq.asset.coins.Bitcoin$Regtest bisq.asset.coins.Bitcoin$Testnet bisq.asset.coins.BitcoinCash +bisq.asset.coins.BitcoinClashic bisq.asset.coins.Byteball bisq.asset.coins.Cryptonite bisq.asset.coins.Dash$Mainnet diff --git a/src/test/java/bisq/asset/coins/BitcoinClashicTest.java b/src/test/java/bisq/asset/coins/BitcoinClashicTest.java new file mode 100644 index 00000000..d94e76b2 --- /dev/null +++ b/src/test/java/bisq/asset/coins/BitcoinClashicTest.java @@ -0,0 +1,43 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class BitcoinClashicTest extends AbstractAssetTest { + + public BitcoinClashicTest() { + super(new BitcoinClashic()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSH"); + assertValidAddress("1MEbUJ5v5MdDEqFJGz4SZp58KkaLdmXZ85"); + assertValidAddress("34dvotXMg5Gxc37TBVV2e5GUAfCFu7Ms4g"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("21HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSHa"); + assertInvalidAddress("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSHs"); + assertInvalidAddress("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSH#"); + } +} From 15d937618eb4cb7a213892e12d2b09fdab400fd4 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 15:01:40 +0200 Subject: [PATCH 029/106] Extract Bitcoin Gold --- .../java/bisq/asset/coins/BitcoinGold.java | 53 +++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 8 -- .../validation/params/btc/BTGParams.java | 74 ------------------- .../META-INF/services/bisq.asset.Asset | 1 + .../bisq/asset/coins/BitcoinGoldTest.java | 43 +++++++++++ 6 files changed, 97 insertions(+), 83 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/BitcoinGold.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/btc/BTGParams.java create mode 100644 src/test/java/bisq/asset/coins/BitcoinGoldTest.java diff --git a/src/main/java/bisq/asset/coins/BitcoinGold.java b/src/main/java/bisq/asset/coins/BitcoinGold.java new file mode 100644 index 00000000..bd0e7c65 --- /dev/null +++ b/src/main/java/bisq/asset/coins/BitcoinGold.java @@ -0,0 +1,53 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +import org.bitcoinj.core.Utils; + +public class BitcoinGold extends Coin { + + public BitcoinGold() { + super("Bitcoin Gold", "BTG", new Base58BitcoinAddressValidator(new BitcoinGoldParams())); + } + + private static class BitcoinGoldParams extends NetworkParametersAdapter { + + public BitcoinGoldParams() { + interval = INTERVAL; + targetTimespan = TARGET_TIMESPAN; + maxTarget = Utils.decodeCompactBits(0x1d00ffffL); + dumpedPrivateKeyHeader = 128; + + // Address format is different to BTC, rest is the same + addressHeader = 38; + p2shHeader = 23; + + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + port = 8333; + packetMagic = 0xf9beb4d9L; + bip32HeaderPub = 0x0488B21E; //The 4 byte header that serializes in base58 to "xpub". + bip32HeaderPriv = 0x0488ADE4; //The 4 byte header that serializes in base58 to "xprv" + + id = ID_MAINNET; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index d09af3d8..57b80afa 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -108,7 +108,6 @@ private static List createAllSortedCryptoCurrenciesList() { .collect(Collectors.toList()); 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("CAGE", "Cagecoin")); result.add(new CryptoCurrency("XCP", "Counterparty")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 54c4a101..96dd48d7 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -34,7 +34,6 @@ import bisq.core.payment.validation.params.StrayaParams; import bisq.core.payment.validation.params.WMCCParams; import bisq.core.payment.validation.params.XspecParams; -import bisq.core.payment.validation.params.btc.BTGParams; import bisq.core.util.validation.InputValidator; import bisq.asset.AddressValidationResult; @@ -98,13 +97,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "BTG": - try { - Address.fromBase58(BTGParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } case "CAGE": if (input.matches("^[D][a-zA-Z0-9]{26,34}$")) { //noinspection ConstantConditions diff --git a/src/main/java/bisq/core/payment/validation/params/btc/BTGParams.java b/src/main/java/bisq/core/payment/validation/params/btc/BTGParams.java deleted file mode 100644 index d7f0ddf1..00000000 --- a/src/main/java/bisq/core/payment/validation/params/btc/BTGParams.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -/* - * Copyright 2013 Google Inc. - * Copyright 2015 Andreas Schildbach - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package bisq.core.payment.validation.params.btc; - -import org.bitcoinj.core.Utils; - -public class BTGParams extends AbstractBitcoinNetParams { - - public BTGParams() { - super(); - interval = INTERVAL; - targetTimespan = TARGET_TIMESPAN; - maxTarget = Utils.decodeCompactBits(0x1d00ffffL); - dumpedPrivateKeyHeader = 128; - - // Address format is different to BTC, rest is the same - addressHeader = 38; - p2shHeader = 23; - - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - port = 8333; - packetMagic = 0xf9beb4d9L; - bip32HeaderPub = 0x0488B21E; //The 4 byte header that serializes in base58 to "xpub". - bip32HeaderPriv = 0x0488ADE4; //The 4 byte header that serializes in base58 to "xprv" - - id = ID_MAINNET; - } - - private static BTGParams instance; - - public static synchronized BTGParams get() { - if (instance == null) { - instance = new BTGParams(); - } - return instance; - } - - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index a1932d44..822a577f 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -6,6 +6,7 @@ bisq.asset.coins.Bitcoin$Regtest bisq.asset.coins.Bitcoin$Testnet bisq.asset.coins.BitcoinCash bisq.asset.coins.BitcoinClashic +bisq.asset.coins.BitcoinGold bisq.asset.coins.Byteball bisq.asset.coins.Cryptonite bisq.asset.coins.Dash$Mainnet diff --git a/src/test/java/bisq/asset/coins/BitcoinGoldTest.java b/src/test/java/bisq/asset/coins/BitcoinGoldTest.java new file mode 100644 index 00000000..d17b8a3c --- /dev/null +++ b/src/test/java/bisq/asset/coins/BitcoinGoldTest.java @@ -0,0 +1,43 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class BitcoinGoldTest extends AbstractAssetTest { + + public BitcoinGoldTest() { + super(new BitcoinGold()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("AehvQ57Fp168uY592LCUYBbyNEpiRAPufb"); + assertValidAddress("GWaSW6PHfQKBv8EXV3xiqGG2zxKZh4XYNu"); + assertValidAddress("GLpT8yG2kwPMdMfgwekG6tEAa91PSmN4ZC"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("GVTPWDVJgLxo5ZYSPXPDxE4s7LE5cLRwCc1"); + assertInvalidAddress("1GVTPWDVJgLxo5ZYSPXPDxE4s7LE5cLRwCc"); + assertInvalidAddress("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSH"); + } +} From 0f3bfbb0428380e7269e2936bea4e138dd472d8a Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 15:05:51 +0200 Subject: [PATCH 030/106] Extract Cagecoin --- src/main/java/bisq/asset/coins/Cagecoin.java | 55 +++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 13 --- .../payment/validation/params/CageParams.java | 93 ------------------- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/CagecoinTest.java | 44 +++++++++ 6 files changed, 100 insertions(+), 107 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Cagecoin.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/CageParams.java create mode 100644 src/test/java/bisq/asset/coins/CagecoinTest.java diff --git a/src/main/java/bisq/asset/coins/Cagecoin.java b/src/main/java/bisq/asset/coins/Cagecoin.java new file mode 100644 index 00000000..2511ce62 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Cagecoin.java @@ -0,0 +1,55 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class Cagecoin extends Coin { + + public Cagecoin() { + super("Cagecoin", "CAGE", new CagecoinAddressValidator()); + } + + + public static class CagecoinAddressValidator extends Base58BitcoinAddressValidator { + + public CagecoinAddressValidator() { + super(new CagecoinParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[D][a-zA-Z0-9]{26,34}$")) + return AddressValidationResult.invalidStructure(); + return super.validate(address); + } + } + + + public static class CagecoinParams extends NetworkParametersAdapter { + + public CagecoinParams() { + addressHeader = 31; + p2shHeader = 13; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 57b80afa..f8128171 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -109,7 +109,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("BETR", "Better Betting", true)); result.add(new CryptoCurrency("BURST", "Burstcoin")); - result.add(new CryptoCurrency("CAGE", "Cagecoin")); result.add(new CryptoCurrency("XCP", "Counterparty")); result.add(new CryptoCurrency("CREA", "Creativecoin")); result.add(new CryptoCurrency("DNET", "DarkNet")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 96dd48d7..a82ed4e0 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -25,7 +25,6 @@ import bisq.core.payment.validation.altcoins.YTNAddressValidator; import bisq.core.payment.validation.params.ACHParams; import bisq.core.payment.validation.params.AlcParams; -import bisq.core.payment.validation.params.CageParams; import bisq.core.payment.validation.params.CreaParams; import bisq.core.payment.validation.params.ODNParams; import bisq.core.payment.validation.params.OnionParams; @@ -97,18 +96,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "CAGE": - if (input.matches("^[D][a-zA-Z0-9]{26,34}$")) { - //noinspection ConstantConditions - try { - Address.fromBase58(CageParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } - } else { - return regexTestFailed; - } case "CRED": if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) return regexTestFailed; diff --git a/src/main/java/bisq/core/payment/validation/params/CageParams.java b/src/main/java/bisq/core/payment/validation/params/CageParams.java deleted file mode 100644 index 0ac25baa..00000000 --- a/src/main/java/bisq/core/payment/validation/params/CageParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class CageParams extends NetworkParameters { - - private static CageParams instance; - - public static synchronized CageParams get() { - if (instance == null) { - instance = new CageParams(); - } - return instance; - } - - // We only use the properties needed for address validation - public CageParams() { - super(); - addressHeader = 31; - p2shHeader = 13; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - // default dummy implementations, not used... - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 822a577f..ddd99c59 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -8,6 +8,7 @@ bisq.asset.coins.BitcoinCash bisq.asset.coins.BitcoinClashic bisq.asset.coins.BitcoinGold bisq.asset.coins.Byteball +bisq.asset.coins.Cagecoin bisq.asset.coins.Cryptonite bisq.asset.coins.Dash$Mainnet bisq.asset.coins.Dash$Regtest diff --git a/src/test/java/bisq/asset/coins/CagecoinTest.java b/src/test/java/bisq/asset/coins/CagecoinTest.java new file mode 100644 index 00000000..ba1c3227 --- /dev/null +++ b/src/test/java/bisq/asset/coins/CagecoinTest.java @@ -0,0 +1,44 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class CagecoinTest extends AbstractAssetTest { + + public CagecoinTest() { + super(new Cagecoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("Db97PgfdBDhXk8DmrDhrUPyydTCELn8YSb"); + assertValidAddress("DYV4h7MTsQ91jqzbg94GFAAUbgdK7RZmpG"); + assertValidAddress("Db5y8iKtZ24DqgYpP2G8685vTWEvk3WACC"); + assertValidAddress("DjiQbPuBLJcVYUtzYMuFuzDwDYwb9mVhaK"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq"); + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d1641353982266"); + assertInvalidAddress("DNkkfdUvkCDiywYE98MTVp9nQJTgeZAiFr"); + } +} From 7d23f15fddce17f268d591b0366c8fb71eb909cb Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 15:13:03 +0200 Subject: [PATCH 031/106] Extract Verify --- src/main/java/bisq/asset/tokens/Verify.java | 28 +++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 --- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/tokens/VerifyTest.java | 42 +++++++++++++++++++ 5 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/tokens/Verify.java create mode 100644 src/test/java/bisq/asset/tokens/VerifyTest.java diff --git a/src/main/java/bisq/asset/tokens/Verify.java b/src/main/java/bisq/asset/tokens/Verify.java new file mode 100644 index 00000000..cd5e289e --- /dev/null +++ b/src/main/java/bisq/asset/tokens/Verify.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.Erc20Token; + +public class Verify extends Erc20Token { + + public Verify() { + super("Verify", "CRED"); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index f8128171..7bdd3ed9 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -143,7 +143,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("MVT", "The Movement", true)); result.add(new CryptoCurrency("UNO", "Unobtanium")); - result.add(new CryptoCurrency("CRED", "Verify", true)); result.add(new CryptoCurrency("WILD", "WILD Token", true)); result.add(new CryptoCurrency("XZC", "Zcoin")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index a82ed4e0..44f36074 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -96,11 +96,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "CRED": - if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) - return regexTestFailed; - else - return new ValidationResult(true); case "XSPEC": try { Address.fromBase58(XspecParams.get(), input); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index ddd99c59..f0775d37 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -33,3 +33,4 @@ bisq.asset.coins.Zcash bisq.asset.coins.ZenCash bisq.asset.tokens.Ellaism bisq.asset.tokens.Internext +bisq.asset.tokens.Verify diff --git a/src/test/java/bisq/asset/tokens/VerifyTest.java b/src/test/java/bisq/asset/tokens/VerifyTest.java new file mode 100644 index 00000000..352771cb --- /dev/null +++ b/src/test/java/bisq/asset/tokens/VerifyTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class VerifyTest extends AbstractAssetTest { + + public VerifyTest() { + super(new Verify()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("0x65767ec6d4d3d18a200842352485cdc37cbf3a21"); + assertValidAddress("65767ec6d4d3d18a200842352485cdc37cbf3a21"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("0x65767ec6d4d3d18a200842352485cdc37cbf3a216"); + assertInvalidAddress("0x65767ec6d4d3d18a200842352485cdc37cbf3a2g"); + assertInvalidAddress("65767ec6d4d3d18a200842352485cdc37cbf3a2g"); + } +} From 56ec783a0b30d85d967bf48f3f5f983f518110b8 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 15:18:03 +0200 Subject: [PATCH 032/106] Extract Spectrecoin --- .../java/bisq/asset/coins/Spectrecoin.java | 39 ++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 8 -- .../validation/params/XspecParams.java | 93 ------------------- .../META-INF/services/bisq.asset.Asset | 1 + .../bisq/asset/coins/SpectrecoinTest.java | 43 +++++++++ 6 files changed, 83 insertions(+), 102 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Spectrecoin.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/XspecParams.java create mode 100644 src/test/java/bisq/asset/coins/SpectrecoinTest.java diff --git a/src/main/java/bisq/asset/coins/Spectrecoin.java b/src/main/java/bisq/asset/coins/Spectrecoin.java new file mode 100644 index 00000000..ee9f7a76 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Spectrecoin.java @@ -0,0 +1,39 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class Spectrecoin extends Coin { + + public Spectrecoin() { + super("Spectrecoin", "XSPEC", new Base58BitcoinAddressValidator(new SpectrecoinParams())); + } + + + public static class SpectrecoinParams extends NetworkParametersAdapter { + + public SpectrecoinParams() { + addressHeader = 63; + p2shHeader = 136; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 7bdd3ed9..22ded662 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -137,7 +137,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("SC", "Siacoin")); result.add(new CryptoCurrency("SF", "Siafund")); result.add(new CryptoCurrency("SIB", "Sibcoin")); - result.add(new CryptoCurrency("XSPEC", "Spectrecoin")); result.add(new CryptoCurrency("STEEM", "STEEM")); result.add(new CryptoCurrency("MVT", "The Movement", true)); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 44f36074..17e46314 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -32,7 +32,6 @@ import bisq.core.payment.validation.params.SpeedCashParams; import bisq.core.payment.validation.params.StrayaParams; import bisq.core.payment.validation.params.WMCCParams; -import bisq.core.payment.validation.params.XspecParams; import bisq.core.util.validation.InputValidator; import bisq.asset.AddressValidationResult; @@ -96,13 +95,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "XSPEC": - try { - Address.fromBase58(XspecParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } case "WILD": // https://github.com/ethereum/web3.js/blob/master/lib/utils/utils.js#L403 if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) diff --git a/src/main/java/bisq/core/payment/validation/params/XspecParams.java b/src/main/java/bisq/core/payment/validation/params/XspecParams.java deleted file mode 100644 index b39886ab..00000000 --- a/src/main/java/bisq/core/payment/validation/params/XspecParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class XspecParams extends NetworkParameters { - - private static XspecParams instance; - - public static synchronized XspecParams get() { - if (instance == null) { - instance = new XspecParams(); - } - return instance; - } - - // We only use the properties needed for address validation - public XspecParams() { - super(); - addressHeader = 63; - p2shHeader = 136; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - // default dummy implementations, not used... - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index f0775d37..0e1481c6 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -27,6 +27,7 @@ bisq.asset.coins.Octocoin bisq.asset.coins.Particl bisq.asset.coins.Pranacoin bisq.asset.coins.PIVX +bisq.asset.coins.Spectrecoin bisq.asset.coins.Terracoin bisq.asset.coins.Wacoin bisq.asset.coins.Zcash diff --git a/src/test/java/bisq/asset/coins/SpectrecoinTest.java b/src/test/java/bisq/asset/coins/SpectrecoinTest.java new file mode 100644 index 00000000..b6ad8afc --- /dev/null +++ b/src/test/java/bisq/asset/coins/SpectrecoinTest.java @@ -0,0 +1,43 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class SpectrecoinTest extends AbstractAssetTest { + + public SpectrecoinTest() { + super(new Spectrecoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("SUZRHjTLSCr581qLsGqMqBD5f3oW2JHckn"); + assertValidAddress("SZ4S1oFfUa4a9s9Kg8bNRywucHiDZmcUuz"); + assertValidAddress("SdyjGEmgroK2vxBhkHE1MBUVRbUWpRAdVG"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq"); + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYheO"); + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhek"); + } +} From c263cf525157334804a1df21aa8abb8f6598d73d Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 15:21:04 +0200 Subject: [PATCH 033/106] Extract Wild Token --- .../java/bisq/asset/tokens/WildToken.java | 28 +++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 6 --- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/tokens/WildTokenTest.java | 42 +++++++++++++++++++ 5 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 src/main/java/bisq/asset/tokens/WildToken.java create mode 100644 src/test/java/bisq/asset/tokens/WildTokenTest.java diff --git a/src/main/java/bisq/asset/tokens/WildToken.java b/src/main/java/bisq/asset/tokens/WildToken.java new file mode 100644 index 00000000..4fcc4b71 --- /dev/null +++ b/src/main/java/bisq/asset/tokens/WildToken.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.Erc20Token; + +public class WildToken extends Erc20Token { + + public WildToken() { + super("WILD Token", "WILD"); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 22ded662..11f43fef 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -142,7 +142,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("MVT", "The Movement", true)); result.add(new CryptoCurrency("UNO", "Unobtanium")); - result.add(new CryptoCurrency("WILD", "WILD Token", true)); result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.6.6 diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 17e46314..e5f9cf9f 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -95,12 +95,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "WILD": - // 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); case "ONION": try { Address.fromBase58(OnionParams.get(), input); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 0e1481c6..f071963e 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -35,3 +35,4 @@ bisq.asset.coins.ZenCash bisq.asset.tokens.Ellaism bisq.asset.tokens.Internext bisq.asset.tokens.Verify +bisq.asset.tokens.WildToken diff --git a/src/test/java/bisq/asset/tokens/WildTokenTest.java b/src/test/java/bisq/asset/tokens/WildTokenTest.java new file mode 100644 index 00000000..d44c83d3 --- /dev/null +++ b/src/test/java/bisq/asset/tokens/WildTokenTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class WildTokenTest extends AbstractAssetTest { + + public WildTokenTest() { + super(new WildToken()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("0x2a65Aca4D5fC5B5C859090a6c34d164135398226"); + assertValidAddress("2a65Aca4D5fC5B5C859090a6c34d164135398226"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d1641353982266"); + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + assertInvalidAddress("2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + } +} From a33fe9d6df6f4dc1435f81a410782a45406455c2 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 15:28:18 +0200 Subject: [PATCH 034/106] Extract DeepOnion --- src/main/java/bisq/asset/coins/DeepOnion.java | 39 ++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 2 - .../validation/AltCoinAddressValidator.java | 8 -- .../validation/params/OnionParams.java | 93 ------------------- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/DeepOnionTest.java | 43 +++++++++ 6 files changed, 83 insertions(+), 103 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/DeepOnion.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/OnionParams.java create mode 100644 src/test/java/bisq/asset/coins/DeepOnionTest.java diff --git a/src/main/java/bisq/asset/coins/DeepOnion.java b/src/main/java/bisq/asset/coins/DeepOnion.java new file mode 100644 index 00000000..f811b3a3 --- /dev/null +++ b/src/main/java/bisq/asset/coins/DeepOnion.java @@ -0,0 +1,39 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class DeepOnion extends Coin { + + public DeepOnion() { + super("DeepOnion", "ONION", new Base58BitcoinAddressValidator(new DeepOnionParams())); + } + + + public static class DeepOnionParams extends NetworkParametersAdapter { + + public DeepOnionParams() { + addressHeader = 31; + p2shHeader = 78; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 11f43fef..84ac6684 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -113,7 +113,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("CREA", "Creativecoin")); result.add(new CryptoCurrency("DNET", "DarkNet")); result.add(new CryptoCurrency("DCR", "Decred")); - result.add(new CryptoCurrency("ONION", "DeepOnion")); result.add(new CryptoCurrency("DMC", "DynamicCoin")); result.add(new CryptoCurrency("ESP", "Espers")); result.add(new CryptoCurrency("ETC", "Ether Classic")); @@ -195,7 +194,6 @@ public static List getMainCryptoCurrencies() { if (!baseCurrencyCode.equals("DASH")) result.add(new CryptoCurrency("DASH", "Dash")); result.add(new CryptoCurrency("DCR", "Decred")); - result.add(new CryptoCurrency("ONION", "DeepOnion")); result.add(new CryptoCurrency("ETH", "Ether")); result.add(new CryptoCurrency("ETC", "Ether Classic")); result.add(new CryptoCurrency("GRC", "Gridcoin")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index e5f9cf9f..d44badd7 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -27,7 +27,6 @@ import bisq.core.payment.validation.params.AlcParams; import bisq.core.payment.validation.params.CreaParams; import bisq.core.payment.validation.params.ODNParams; -import bisq.core.payment.validation.params.OnionParams; import bisq.core.payment.validation.params.PhoreParams; import bisq.core.payment.validation.params.SpeedCashParams; import bisq.core.payment.validation.params.StrayaParams; @@ -95,13 +94,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "ONION": - try { - Address.fromBase58(OnionParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } case "CREA": try { Address.fromBase58(CreaParams.get(), input); diff --git a/src/main/java/bisq/core/payment/validation/params/OnionParams.java b/src/main/java/bisq/core/payment/validation/params/OnionParams.java deleted file mode 100644 index 1f7d55ad..00000000 --- a/src/main/java/bisq/core/payment/validation/params/OnionParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class OnionParams extends NetworkParameters { - - private static OnionParams instance; - - public static synchronized OnionParams get() { - if (instance == null) { - instance = new OnionParams(); - } - return instance; - } - - // We only use the properties needed for address validation - public OnionParams() { - super(); - addressHeader = 31; - p2shHeader = 78; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - // default dummy implementations, not used... - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index f071963e..64c6e688 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -14,6 +14,7 @@ bisq.asset.coins.Dash$Mainnet bisq.asset.coins.Dash$Regtest bisq.asset.coins.Dash$Testnet bisq.asset.coins.Decent +bisq.asset.coins.DeepOnion bisq.asset.coins.Dogecoin bisq.asset.coins.Ether bisq.asset.coins.Instacash diff --git a/src/test/java/bisq/asset/coins/DeepOnionTest.java b/src/test/java/bisq/asset/coins/DeepOnionTest.java new file mode 100644 index 00000000..d2df11aa --- /dev/null +++ b/src/test/java/bisq/asset/coins/DeepOnionTest.java @@ -0,0 +1,43 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class DeepOnionTest extends AbstractAssetTest { + + public DeepOnionTest() { + super(new DeepOnion()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("DbkkqXwdiWJNcpfw49f2xzTVEbvL1SYWDm"); + assertValidAddress("DetWWdj7VUTDg1yMhjgRfzvwTf4rRSoywK"); + assertValidAddress("Dr5aiywUzZgYHvrQgrCsk6qhxhFzM8VVUM"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq"); + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYheO"); + assertInvalidAddress("1HQQgsvLTgN9xD9hNmAgAreakzVzQUSLSH"); + } +} From 2ee9f137773c490a206341230809121764f8db31 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 15:34:22 +0200 Subject: [PATCH 035/106] Extract Creativecoin --- .../java/bisq/asset/coins/Creativecoin.java | 40 ++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 8 -- .../payment/validation/params/CreaParams.java | 96 ------------------- .../META-INF/services/bisq.asset.Asset | 1 + .../bisq/asset/coins/CreativecoinTest.java | 43 +++++++++ 6 files changed, 84 insertions(+), 105 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Creativecoin.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/CreaParams.java create mode 100644 src/test/java/bisq/asset/coins/CreativecoinTest.java diff --git a/src/main/java/bisq/asset/coins/Creativecoin.java b/src/main/java/bisq/asset/coins/Creativecoin.java new file mode 100644 index 00000000..aebe324b --- /dev/null +++ b/src/main/java/bisq/asset/coins/Creativecoin.java @@ -0,0 +1,40 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class Creativecoin extends Coin { + + public Creativecoin() { + super("Creativecoin", "CREA", new Base58BitcoinAddressValidator(new CreativecoinParams())); + } + + + public static class CreativecoinParams extends NetworkParametersAdapter { + + public CreativecoinParams() { + int segwitHeader = 35; + addressHeader = 28; + p2shHeader = 5; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader, segwitHeader}; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 84ac6684..6d359256 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -110,7 +110,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("BETR", "Better Betting", true)); result.add(new CryptoCurrency("BURST", "Burstcoin")); result.add(new CryptoCurrency("XCP", "Counterparty")); - result.add(new CryptoCurrency("CREA", "Creativecoin")); result.add(new CryptoCurrency("DNET", "DarkNet")); result.add(new CryptoCurrency("DCR", "Decred")); result.add(new CryptoCurrency("DMC", "DynamicCoin")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index d44badd7..5195dfa0 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -25,7 +25,6 @@ import bisq.core.payment.validation.altcoins.YTNAddressValidator; import bisq.core.payment.validation.params.ACHParams; import bisq.core.payment.validation.params.AlcParams; -import bisq.core.payment.validation.params.CreaParams; import bisq.core.payment.validation.params.ODNParams; import bisq.core.payment.validation.params.PhoreParams; import bisq.core.payment.validation.params.SpeedCashParams; @@ -94,13 +93,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "CREA": - try { - Address.fromBase58(CreaParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } case "XIN": if (!input.matches("^XIN-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{5}$")) return regexTestFailed; diff --git a/src/main/java/bisq/core/payment/validation/params/CreaParams.java b/src/main/java/bisq/core/payment/validation/params/CreaParams.java deleted file mode 100644 index d91427bf..00000000 --- a/src/main/java/bisq/core/payment/validation/params/CreaParams.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class CreaParams extends NetworkParameters { - - private static CreaParams instance; - - public static synchronized CreaParams get() { - if (instance == null) { - instance = new CreaParams(); - } - return instance; - } - - // We only use the properties needed for address validation - - public CreaParams() { - super(); - int segwitHeader = 35; - addressHeader = 28; - p2shHeader = 5; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader, segwitHeader}; - - } - - // default dummy implementations, not used... - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 64c6e688..b5df5705 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -9,6 +9,7 @@ bisq.asset.coins.BitcoinClashic bisq.asset.coins.BitcoinGold bisq.asset.coins.Byteball bisq.asset.coins.Cagecoin +bisq.asset.coins.Creativecoin bisq.asset.coins.Cryptonite bisq.asset.coins.Dash$Mainnet bisq.asset.coins.Dash$Regtest diff --git a/src/test/java/bisq/asset/coins/CreativecoinTest.java b/src/test/java/bisq/asset/coins/CreativecoinTest.java new file mode 100644 index 00000000..90d12e45 --- /dev/null +++ b/src/test/java/bisq/asset/coins/CreativecoinTest.java @@ -0,0 +1,43 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class CreativecoinTest extends AbstractAssetTest { + + public CreativecoinTest() { + super(new Creativecoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("CGjh99QdHxCE6g9pGUucCJNeUyQPRJr4fE"); + assertValidAddress("FTDYi4GoD3vFYFhEGbuifSZjs6udXVin7B"); + assertValidAddress("361uBxJvmg6f62dMYVM9b7GeR38phkkTyA"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("C7VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq"); + assertInvalidAddress("F7VZNX1SN5NtKa8UQFxwQbFeFc3iqRYheO"); + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhek#"); + } +} From c11df7b32a3bc4c22675fd33aa8fc978857c2dd7 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 15:51:00 +0200 Subject: [PATCH 036/106] Extract Infinity Economics --- .../bisq/asset/coins/InfinityEconomics.java | 29 +++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 -- .../META-INF/services/bisq.asset.Asset | 1 + .../asset/coins/InfinityEconomicsTest.java | 48 +++++++++++++++++++ 5 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/InfinityEconomics.java create mode 100644 src/test/java/bisq/asset/coins/InfinityEconomicsTest.java diff --git a/src/main/java/bisq/asset/coins/InfinityEconomics.java b/src/main/java/bisq/asset/coins/InfinityEconomics.java new file mode 100644 index 00000000..f5c55e26 --- /dev/null +++ b/src/main/java/bisq/asset/coins/InfinityEconomics.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.RegexAddressValidator; + +public class InfinityEconomics extends Coin { + + public InfinityEconomics() { + super("Infinity Economics", "XIN", new RegexAddressValidator("^XIN-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{5}$")); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 6d359256..2eb08d43 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -115,7 +115,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("DMC", "DynamicCoin")); result.add(new CryptoCurrency("ESP", "Espers")); result.add(new CryptoCurrency("ETC", "Ether Classic")); - result.add(new CryptoCurrency("XIN", "Infinity Economics")); result.add(new CryptoCurrency("GRC", "Gridcoin")); result.add(new CryptoCurrency("LBC", "LBRY Credits")); result.add(new CryptoCurrency("LSK", "Lisk")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 5195dfa0..e9c09145 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -93,11 +93,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "XIN": - if (!input.matches("^XIN-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{5}$")) - 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}$")) diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index b5df5705..6c2c3f86 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -18,6 +18,7 @@ bisq.asset.coins.Decent bisq.asset.coins.DeepOnion bisq.asset.coins.Dogecoin bisq.asset.coins.Ether +bisq.asset.coins.InfinityEconomics bisq.asset.coins.Instacash bisq.asset.coins.InternetOfPeople bisq.asset.coins.Litecoin$Mainnet diff --git a/src/test/java/bisq/asset/coins/InfinityEconomicsTest.java b/src/test/java/bisq/asset/coins/InfinityEconomicsTest.java new file mode 100644 index 00000000..44eca8ac --- /dev/null +++ b/src/test/java/bisq/asset/coins/InfinityEconomicsTest.java @@ -0,0 +1,48 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class InfinityEconomicsTest extends AbstractAssetTest { + + public InfinityEconomicsTest() { + super(new InfinityEconomics()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("XIN-FXFA-LR6Y-QZAW-9V4SX"); + assertValidAddress("XIN-JM2U-U4AE-G7WF-3NP9F"); + assertValidAddress("XIN-2223-2222-KB8Y-22222"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("abcde"); + assertInvalidAddress("XIN-"); + assertInvalidAddress("XIN-FXFA-LR6Y-QZAW-9V4SXA"); + assertInvalidAddress("NIX-FXFA-LR6Y-QZAW-9V4SX"); + assertInvalidAddress("XIN-FXF-LR6Y-QZAW-9V4SX"); + assertInvalidAddress("XIN-FXFA-LR6-QZAW-9V4SX"); + assertInvalidAddress("XIN-FXFA-LR6Y-QZA-9V4SX"); + assertInvalidAddress("XIN-FXFA-LR6Y-QZAW-9V4S"); + } +} From 159e975da4bb1e0222c765098b978712cc4f6684 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 15:52:11 +0200 Subject: [PATCH 037/106] Extract Better Betting --- .../java/bisq/asset/tokens/BetterBetting.java | 10 +++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 6 --- .../META-INF/services/bisq.asset.Asset | 1 + .../bisq/asset/tokens/BetterBettingTest.java | 42 +++++++++++++++++++ 5 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 src/main/java/bisq/asset/tokens/BetterBetting.java create mode 100644 src/test/java/bisq/asset/tokens/BetterBettingTest.java diff --git a/src/main/java/bisq/asset/tokens/BetterBetting.java b/src/main/java/bisq/asset/tokens/BetterBetting.java new file mode 100644 index 00000000..7feff0a5 --- /dev/null +++ b/src/main/java/bisq/asset/tokens/BetterBetting.java @@ -0,0 +1,10 @@ +package bisq.asset.tokens; + +import bisq.asset.Erc20Token; + +public class BetterBetting extends Erc20Token { + + public BetterBetting() { + super("Better Betting", "BETR"); + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 2eb08d43..d271e32e 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("BETR", "Better Betting", true)); result.add(new CryptoCurrency("BURST", "Burstcoin")); result.add(new CryptoCurrency("XCP", "Counterparty")); result.add(new CryptoCurrency("DNET", "DarkNet")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index e9c09145..c34b6020 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -93,12 +93,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - 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); case "MVT": if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) return regexTestFailed; diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 6c2c3f86..7aacab6d 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -35,6 +35,7 @@ bisq.asset.coins.Terracoin bisq.asset.coins.Wacoin bisq.asset.coins.Zcash bisq.asset.coins.ZenCash +bisq.asset.tokens.BetterBetting bisq.asset.tokens.Ellaism bisq.asset.tokens.Internext bisq.asset.tokens.Verify diff --git a/src/test/java/bisq/asset/tokens/BetterBettingTest.java b/src/test/java/bisq/asset/tokens/BetterBettingTest.java new file mode 100644 index 00000000..56107593 --- /dev/null +++ b/src/test/java/bisq/asset/tokens/BetterBettingTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class BetterBettingTest extends AbstractAssetTest { + + public BetterBettingTest() { + super(new BetterBetting()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("0x2a65Aca4D5fC5B5C859090a6c34d164135398226"); + assertValidAddress("2a65Aca4D5fC5B5C859090a6c34d164135398226"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d1641353982266"); + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + assertInvalidAddress("2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + } +} From 648c2e462d5f82e2650febf3dadc071c80628381 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 15:56:07 +0200 Subject: [PATCH 038/106] Extract Movement --- src/main/java/bisq/asset/tokens/Movement.java | 10 +++++ .../java/bisq/core/locale/CurrencyUtil.java | 2 - .../validation/AltCoinAddressValidator.java | 5 --- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/tokens/MovementTest.java | 42 +++++++++++++++++++ 5 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 src/main/java/bisq/asset/tokens/Movement.java create mode 100644 src/test/java/bisq/asset/tokens/MovementTest.java diff --git a/src/main/java/bisq/asset/tokens/Movement.java b/src/main/java/bisq/asset/tokens/Movement.java new file mode 100644 index 00000000..ee0df654 --- /dev/null +++ b/src/main/java/bisq/asset/tokens/Movement.java @@ -0,0 +1,10 @@ +package bisq.asset.tokens; + +import bisq.asset.Erc20Token; + +public class Movement extends Erc20Token { + + public Movement() { + super("The Movement", "MVT"); + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index d271e32e..04e44c67 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -135,8 +135,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("SIB", "Sibcoin")); result.add(new CryptoCurrency("STEEM", "STEEM")); - result.add(new CryptoCurrency("MVT", "The Movement", true)); - result.add(new CryptoCurrency("UNO", "Unobtanium")); result.add(new CryptoCurrency("XZC", "Zcoin")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index c34b6020..a942498d 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -93,11 +93,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "MVT": - if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) - return regexTestFailed; - else - return new ValidationResult(true); case "REF": // https://github.com/ethereum/web3.js/blob/master/lib/utils/utils.js#L403 if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 7aacab6d..1eb194e3 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -38,5 +38,6 @@ bisq.asset.coins.ZenCash bisq.asset.tokens.BetterBetting bisq.asset.tokens.Ellaism bisq.asset.tokens.Internext +bisq.asset.tokens.Movement bisq.asset.tokens.Verify bisq.asset.tokens.WildToken diff --git a/src/test/java/bisq/asset/tokens/MovementTest.java b/src/test/java/bisq/asset/tokens/MovementTest.java new file mode 100644 index 00000000..c63e59e7 --- /dev/null +++ b/src/test/java/bisq/asset/tokens/MovementTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class MovementTest extends AbstractAssetTest { + + public MovementTest() { + super(new Ellaism()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("0x2a65Aca4D5fC5B5C859090a6c34d164135398226"); + assertValidAddress("2a65Aca4D5fC5B5C859090a6c34d164135398226"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d1641353982266"); + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + assertInvalidAddress("2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + } +} From 5647b744891d8aa0c9845320f1a0549e7e7bb71f Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 16:05:08 +0200 Subject: [PATCH 039/106] Extract RefToken --- src/main/java/bisq/asset/tokens/RefToken.java | 10 +++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 6 --- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/tokens/RefTokenTest.java | 42 +++++++++++++++++++ 5 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 src/main/java/bisq/asset/tokens/RefToken.java create mode 100644 src/test/java/bisq/asset/tokens/RefTokenTest.java diff --git a/src/main/java/bisq/asset/tokens/RefToken.java b/src/main/java/bisq/asset/tokens/RefToken.java new file mode 100644 index 00000000..0d30cd8e --- /dev/null +++ b/src/main/java/bisq/asset/tokens/RefToken.java @@ -0,0 +1,10 @@ +package bisq.asset.tokens; + +import bisq.asset.Erc20Token; + +public class RefToken extends Erc20Token { + + public RefToken() { + super("RefToken", "REF"); + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 04e44c67..71cd8d38 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -128,7 +128,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("PEPECASH", "Pepe Cash")); result.add(new CryptoCurrency("POST", "PostCoin")); result.add(new CryptoCurrency("RDD", "ReddCoin")); - result.add(new CryptoCurrency("REF", "RefToken", true)); result.add(new CryptoCurrency("SFSC", "Safe FileSystem Coin")); result.add(new CryptoCurrency("SC", "Siacoin")); result.add(new CryptoCurrency("SF", "Siafund")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index a942498d..fe101c28 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -93,12 +93,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "REF": - // 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); case "STL": if (!input.matches("^(Se)\\d[0-9A-Za-z]{94}$")) return regexTestFailed; diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 1eb194e3..2eaae354 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -39,5 +39,6 @@ bisq.asset.tokens.BetterBetting bisq.asset.tokens.Ellaism bisq.asset.tokens.Internext bisq.asset.tokens.Movement +bisq.asset.tokens.RefToken bisq.asset.tokens.Verify bisq.asset.tokens.WildToken diff --git a/src/test/java/bisq/asset/tokens/RefTokenTest.java b/src/test/java/bisq/asset/tokens/RefTokenTest.java new file mode 100644 index 00000000..23cc9a6f --- /dev/null +++ b/src/test/java/bisq/asset/tokens/RefTokenTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class RefTokenTest extends AbstractAssetTest { + + public RefTokenTest() { + super(new BetterBetting()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("0x2a65Aca4D5fC5B5C859090a6c34d164135398226"); + assertValidAddress("2a65Aca4D5fC5B5C859090a6c34d164135398226"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d1641353982266"); + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + assertInvalidAddress("2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + } +} From f79e0557f8fa6ac0d12ed0287d8c8587dd049767 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 16:11:40 +0200 Subject: [PATCH 040/106] Extract Stellite --- src/main/java/bisq/asset/coins/Stellite.java | 29 +++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 --- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/StelliteTest.java | 42 +++++++++++++++++++ 5 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Stellite.java create mode 100644 src/test/java/bisq/asset/coins/StelliteTest.java diff --git a/src/main/java/bisq/asset/coins/Stellite.java b/src/main/java/bisq/asset/coins/Stellite.java new file mode 100644 index 00000000..29086fa7 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Stellite.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.RegexAddressValidator; + +public class Stellite extends Coin { + + public Stellite() { + super("Stellite", "STL", new RegexAddressValidator("^(Se)\\d[0-9A-Za-z]{94}$")); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 71cd8d38..bbcad663 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.6.6 - result.add(new CryptoCurrency("STL", "Stellite")); result.add(new CryptoCurrency("DAI", "Dai Stablecoin", true)); result.add(new CryptoCurrency("YTN", "Yenten")); result.add(new CryptoCurrency("DARX", "BitDaric")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index fe101c28..e71f5b27 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -93,11 +93,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "STL": - if (!input.matches("^(Se)\\d[0-9A-Za-z]{94}$")) - return regexTestFailed; - else - return new ValidationResult(true); case "DAI": // https://github.com/ethereum/web3.js/blob/master/lib/utils/utils.js#L403 if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 2eaae354..5d8a7f4f 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -31,6 +31,7 @@ bisq.asset.coins.Particl bisq.asset.coins.Pranacoin bisq.asset.coins.PIVX bisq.asset.coins.Spectrecoin +bisq.asset.coins.Stellite bisq.asset.coins.Terracoin bisq.asset.coins.Wacoin bisq.asset.coins.Zcash diff --git a/src/test/java/bisq/asset/coins/StelliteTest.java b/src/test/java/bisq/asset/coins/StelliteTest.java new file mode 100644 index 00000000..2ea2ec9b --- /dev/null +++ b/src/test/java/bisq/asset/coins/StelliteTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class StelliteTest extends AbstractAssetTest { + + public StelliteTest() { + super(new Stellite()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("Se3x7sVdvUnMMn2KoYLyYVHMJGRoB2R3V8K3LYuHAiEXgVac7vsmFiXUC8dSpJnjXDfwytKsQJV6HFH8MjwPagTJ2Aha46RZM"); + assertValidAddress("Se3F51UzpbVVnQRx2VNbcjfBoQJfeuyFF353i1jLnCZda9yVN3vy8csbYCESBvf38TFkchH1C1tMY6XHkC8L678K2vLsVZVMU"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("Se3x7svUnMMn2KoYLyYVHMJGRoB2R3V8K3LYuHAiEXgVac7vsmFiXUC8dSpJnjXDfwytKsQJV6HFH8MjwPagTJ2Aha46RZM"); + assertInvalidAddress("SX45GjRnvqheAgCpx4nJeKRjDtS5tYawxEP1GaTj79dTEm21Dtdxex6EHyDqBpofoDqW9k9uQWtkGgbbF8kiRSZ27AksBg7G111"); + assertInvalidAddress("Se3F51UzpbVVnQRx2VNbcjfBoQJfeuyFF353i1jLnCZda9yVN3vy8csbYCESBvf38TFkchH1C1tMY6XHkC8L678K2vLsVZVMUII"); + } +} From f1d84c0b7b5e5a42718f93d5443de5368fb822b5 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 16:15:39 +0200 Subject: [PATCH 041/106] Extract Dai Stablecoin --- .../java/bisq/asset/tokens/DaiStablecoin.java | 10 +++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 6 --- .../META-INF/services/bisq.asset.Asset | 1 + .../bisq/asset/tokens/DaiStablecoinTest.java | 42 +++++++++++++++++++ 5 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 src/main/java/bisq/asset/tokens/DaiStablecoin.java create mode 100644 src/test/java/bisq/asset/tokens/DaiStablecoinTest.java diff --git a/src/main/java/bisq/asset/tokens/DaiStablecoin.java b/src/main/java/bisq/asset/tokens/DaiStablecoin.java new file mode 100644 index 00000000..42705fb7 --- /dev/null +++ b/src/main/java/bisq/asset/tokens/DaiStablecoin.java @@ -0,0 +1,10 @@ +package bisq.asset.tokens; + +import bisq.asset.Erc20Token; + +public class DaiStablecoin extends Erc20Token { + + public DaiStablecoin() { + super("Dai Stablecoin", "DAI"); + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index bbcad663..0146f3b7 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.6.6 - result.add(new CryptoCurrency("DAI", "Dai Stablecoin", true)); result.add(new CryptoCurrency("YTN", "Yenten")); result.add(new CryptoCurrency("DARX", "BitDaric")); result.add(new CryptoCurrency("ODN", "Obsidian")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index e71f5b27..887ae0a3 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -93,12 +93,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "DAI": - // 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); case "YTN": return YTNAddressValidator.ValidateAddress(input); case "DARX": diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 5d8a7f4f..23797c5f 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -37,6 +37,7 @@ bisq.asset.coins.Wacoin bisq.asset.coins.Zcash bisq.asset.coins.ZenCash bisq.asset.tokens.BetterBetting +bisq.asset.tokens.DaiStablecoin bisq.asset.tokens.Ellaism bisq.asset.tokens.Internext bisq.asset.tokens.Movement diff --git a/src/test/java/bisq/asset/tokens/DaiStablecoinTest.java b/src/test/java/bisq/asset/tokens/DaiStablecoinTest.java new file mode 100644 index 00000000..d567cce5 --- /dev/null +++ b/src/test/java/bisq/asset/tokens/DaiStablecoinTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class DaiStablecoinTest extends AbstractAssetTest { + + public DaiStablecoinTest() { + super(new DaiStablecoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("0x2a65Aca4D5fC5B5C859090a6c34d164135398226"); + assertValidAddress("2a65Aca4D5fC5B5C859090a6c34d164135398226"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d1641353982266"); + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + assertInvalidAddress("2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + } +} From e750c3f0fc7d2d8bdf780d7ddfa5de83804cb9e8 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 16:23:40 +0200 Subject: [PATCH 042/106] Extract Yenten --- src/main/java/bisq/asset/coins/Yenten.java | 86 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 3 - .../altcoins/YTNAddressValidator.java | 77 ----------------- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/YentenTest.java | 45 ++++++++++ 6 files changed, 132 insertions(+), 81 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Yenten.java delete mode 100644 src/main/java/bisq/core/payment/validation/altcoins/YTNAddressValidator.java create mode 100644 src/test/java/bisq/asset/coins/YentenTest.java diff --git a/src/main/java/bisq/asset/coins/Yenten.java b/src/main/java/bisq/asset/coins/Yenten.java new file mode 100644 index 00000000..cb93cd2a --- /dev/null +++ b/src/main/java/bisq/asset/coins/Yenten.java @@ -0,0 +1,86 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.AddressValidator; +import bisq.asset.Coin; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import java.util.Arrays; + +public class Yenten extends Coin { + + public Yenten() { + super("Yenten", "YTN", new YentenAddressValidator()); + } + + + public static class YentenAddressValidator implements AddressValidator { + private final static String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; + + public AddressValidationResult validate(String addr) { + if (addr.length() != 34) + return AddressValidationResult.invalidAddress("YTN_Addr_Invalid: Length must be 34!"); + if (!addr.startsWith("Y")) + return AddressValidationResult.invalidAddress("YTN_Addr_Invalid: must start with 'Y'!"); + byte[] decoded = decodeBase58(addr); + if (decoded == null) + return AddressValidationResult.invalidAddress("YTN_Addr_Invalid: Base58 decoder error!"); + + byte[] hash = getSha256(decoded, 21, 2); + if (hash == null || !Arrays.equals(Arrays.copyOfRange(hash, 0, 4), Arrays.copyOfRange(decoded, 21, 25))) + return AddressValidationResult.invalidAddress("YTN_Addr_Invalid: Checksum error!"); + return AddressValidationResult.validAddress(); + } + + private static byte[] decodeBase58(String input) { + byte[] output = new byte[25]; + for (int i = 0; i < input.length(); i++) { + char t = input.charAt(i); + + int p = ALPHABET.indexOf(t); + if (p == -1) + return null; + for (int j = 25 - 1; j >= 0; j--, p /= 256) { + p += 58 * (output[j] & 0xFF); + output[j] = (byte) (p % 256); + } + if (p != 0) + return null; + } + + return output; + } + + private static byte[] getSha256(byte[] data, int len, int recursion) { + if (recursion == 0) + return data; + + try { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + md.update(Arrays.copyOfRange(data, 0, len)); + return getSha256(md.digest(), 32, recursion - 1); + } catch (NoSuchAlgorithmException e) { + return null; + } + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 0146f3b7..c8f28fbb 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.6.6 - result.add(new CryptoCurrency("YTN", "Yenten")); result.add(new CryptoCurrency("DARX", "BitDaric")); result.add(new CryptoCurrency("ODN", "Obsidian")); result.add(new CryptoCurrency("CDT", "Cassubian Detk")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 887ae0a3..948f26c3 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -22,7 +22,6 @@ import bisq.core.locale.Res; import bisq.core.payment.validation.altcoins.KOTOAddressValidator; import bisq.core.payment.validation.altcoins.WMCCAddressValidator; -import bisq.core.payment.validation.altcoins.YTNAddressValidator; import bisq.core.payment.validation.params.ACHParams; import bisq.core.payment.validation.params.AlcParams; import bisq.core.payment.validation.params.ODNParams; @@ -93,8 +92,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "YTN": - return YTNAddressValidator.ValidateAddress(input); case "DARX": if (!input.matches("^[R][a-km-zA-HJ-NP-Z1-9]{25,34}$")) return regexTestFailed; diff --git a/src/main/java/bisq/core/payment/validation/altcoins/YTNAddressValidator.java b/src/main/java/bisq/core/payment/validation/altcoins/YTNAddressValidator.java deleted file mode 100644 index 16fca2aa..00000000 --- a/src/main/java/bisq/core/payment/validation/altcoins/YTNAddressValidator.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with bisq. If not, see . - */ - -package bisq.core.payment.validation.altcoins; - - -import bisq.core.util.validation.InputValidator.ValidationResult; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import java.util.Arrays; - -public class YTNAddressValidator { - private final static String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; - - public static ValidationResult ValidateAddress(String addr) { - if (addr.length() != 34) - return new ValidationResult(false, "YTN_Addr_Invalid: Length must be 34!"); - if (!addr.startsWith("Y")) - return new ValidationResult(false, "YTN_Addr_Invalid: must start with 'Y'!"); - byte[] decoded = decodeBase58(addr, 58, 25); - if (decoded == null) - return new ValidationResult(false, "YTN_Addr_Invalid: Base58 decoder error!"); - - byte[] hash = getSha256(decoded, 0, 21, 2); - if (hash == null || !Arrays.equals(Arrays.copyOfRange(hash, 0, 4), Arrays.copyOfRange(decoded, 21, 25))) - return new ValidationResult(false, "YTN_Addr_Invalid: Checksum error!"); - return new ValidationResult(true); - } - - private static byte[] decodeBase58(String input, int base, int len) { - byte[] output = new byte[len]; - for (int i = 0; i < input.length(); i++) { - char t = input.charAt(i); - - int p = ALPHABET.indexOf(t); - if (p == -1) - return null; - for (int j = len - 1; j >= 0; j--, p /= 256) { - p += base * (output[j] & 0xFF); - output[j] = (byte) (p % 256); - } - if (p != 0) - return null; - } - - return output; - } - - private static byte[] getSha256(byte[] data, int start, int len, int recursion) { - if (recursion == 0) - return data; - - try { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - md.update(Arrays.copyOfRange(data, start, start + len)); - return getSha256(md.digest(), 0, 32, recursion - 1); - } catch (NoSuchAlgorithmException e) { - return null; - } - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 23797c5f..85e5af2c 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -34,6 +34,7 @@ bisq.asset.coins.Spectrecoin bisq.asset.coins.Stellite bisq.asset.coins.Terracoin bisq.asset.coins.Wacoin +bisq.asset.coins.Yenten bisq.asset.coins.Zcash bisq.asset.coins.ZenCash bisq.asset.tokens.BetterBetting diff --git a/src/test/java/bisq/asset/coins/YentenTest.java b/src/test/java/bisq/asset/coins/YentenTest.java new file mode 100644 index 00000000..e5a9efee --- /dev/null +++ b/src/test/java/bisq/asset/coins/YentenTest.java @@ -0,0 +1,45 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class YentenTest extends AbstractAssetTest { + + public YentenTest() { + super(new Yenten()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("YTgSv7bk5x5p6te3uf3HbUwgnf7zEJM4Jn"); + assertValidAddress("YVz19KtQUfyTP4AJS8sbRBqi7dkGTL2ovd"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("YiTwGuv3opowtPF5w8LUWBXFmaxc9S68ha"); + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq"); + assertInvalidAddress("YVZNX1SN5NtKa8UQFxwQbFeFc3iqRYheO"); + assertInvalidAddress("YiTwGuv3opowtPF5w8LUWBlFmaxc9S68hz"); + assertInvalidAddress("YiTwGuv3opowtPF5w8LUWB0Fmaxc9S68hz"); + assertInvalidAddress("YiTwGuv3opowtPF5w8LUWBIFmaxc9S68hz"); + } +} From ddc77e71da17cd736ca660ecfa1d7fad1e5ff3a3 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 16:28:18 +0200 Subject: [PATCH 043/106] Extract BitDaric --- src/main/java/bisq/asset/coins/BitDaric.java | 29 +++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 --- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/BitDaricTest.java | 43 +++++++++++++++++++ 5 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/BitDaric.java create mode 100644 src/test/java/bisq/asset/coins/BitDaricTest.java diff --git a/src/main/java/bisq/asset/coins/BitDaric.java b/src/main/java/bisq/asset/coins/BitDaric.java new file mode 100644 index 00000000..6fd6f93f --- /dev/null +++ b/src/main/java/bisq/asset/coins/BitDaric.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.RegexAddressValidator; + +public class BitDaric extends Coin { + + public BitDaric() { + super("BitDaric", "DARX", new RegexAddressValidator("^[R][a-km-zA-HJ-NP-Z1-9]{25,34}$")); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index c8f28fbb..f5b60fea 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.6.6 - result.add(new CryptoCurrency("DARX", "BitDaric")); result.add(new CryptoCurrency("ODN", "Obsidian")); result.add(new CryptoCurrency("CDT", "Cassubian Detk")); result.add(new CryptoCurrency("DGM", "DigiMoney")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 948f26c3..cccffb44 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -92,11 +92,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "DARX": - if (!input.matches("^[R][a-km-zA-HJ-NP-Z1-9]{25,34}$")) - return regexTestFailed; - else - return new ValidationResult(true); case "ODN": try { Address.fromBase58(ODNParams.get(), input); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 85e5af2c..6001121e 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -7,6 +7,7 @@ bisq.asset.coins.Bitcoin$Testnet bisq.asset.coins.BitcoinCash bisq.asset.coins.BitcoinClashic bisq.asset.coins.BitcoinGold +bisq.asset.coins.BitDaric bisq.asset.coins.Byteball bisq.asset.coins.Cagecoin bisq.asset.coins.Creativecoin diff --git a/src/test/java/bisq/asset/coins/BitDaricTest.java b/src/test/java/bisq/asset/coins/BitDaricTest.java new file mode 100644 index 00000000..4face3b7 --- /dev/null +++ b/src/test/java/bisq/asset/coins/BitDaricTest.java @@ -0,0 +1,43 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class BitDaricTest extends AbstractAssetTest { + + public BitDaricTest() { + super(new BitDaric()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("RN8spHmkV6ZtRsquaTJMRZJujRQkkDNh2G"); + assertValidAddress("RTD9jtKybd7TeM597t5MkNof84GPka34R7"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("LAPc1FumbYifKpfBpGbRLuPcLAJwHUxeyu"); + assertInvalidAddress("ROPc1FumbYifKpfBpGbRLuPcLAJwHUxeyu"); + assertInvalidAddress("rN8spHmkV6ZtROquaTJMRZJujRQkkDNh2G"); + assertInvalidAddress("1NxrMzHCjG8X9kqTEZBXUNB5PC58DSXAht"); + } +} From 4f3f151404467b77335e29c8e4f2ad45d6a87fb1 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 16:33:07 +0200 Subject: [PATCH 044/106] Extract Obsidian --- src/main/java/bisq/asset/coins/Obsidian.java | 39 ++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 8 -- .../payment/validation/params/ODNParams.java | 93 ------------------- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/ObsidianTest.java | 44 +++++++++ 6 files changed, 84 insertions(+), 102 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Obsidian.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/ODNParams.java create mode 100644 src/test/java/bisq/asset/coins/ObsidianTest.java diff --git a/src/main/java/bisq/asset/coins/Obsidian.java b/src/main/java/bisq/asset/coins/Obsidian.java new file mode 100644 index 00000000..0eebb7ce --- /dev/null +++ b/src/main/java/bisq/asset/coins/Obsidian.java @@ -0,0 +1,39 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class Obsidian extends Coin { + + public Obsidian() { + super("Obsidian", "ODN", new Base58BitcoinAddressValidator(new ObsidianParams())); + } + + + public static class ObsidianParams extends NetworkParametersAdapter { + + public ObsidianParams() { + addressHeader = 75; + p2shHeader = 125; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index f5b60fea..d0e16085 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.6.6 - result.add(new CryptoCurrency("ODN", "Obsidian")); result.add(new CryptoCurrency("CDT", "Cassubian Detk")); result.add(new CryptoCurrency("DGM", "DigiMoney")); result.add(new CryptoCurrency("SCS", "SpeedCash")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index cccffb44..81705b41 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -24,7 +24,6 @@ import bisq.core.payment.validation.altcoins.WMCCAddressValidator; import bisq.core.payment.validation.params.ACHParams; import bisq.core.payment.validation.params.AlcParams; -import bisq.core.payment.validation.params.ODNParams; import bisq.core.payment.validation.params.PhoreParams; import bisq.core.payment.validation.params.SpeedCashParams; import bisq.core.payment.validation.params.StrayaParams; @@ -92,13 +91,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "ODN": - try { - Address.fromBase58(ODNParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } case "CDT": if (input.startsWith("D")) return new ValidationResult(true); diff --git a/src/main/java/bisq/core/payment/validation/params/ODNParams.java b/src/main/java/bisq/core/payment/validation/params/ODNParams.java deleted file mode 100644 index a8af1049..00000000 --- a/src/main/java/bisq/core/payment/validation/params/ODNParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class ODNParams extends NetworkParameters { - - private static ODNParams instance; - - public static synchronized ODNParams get() { - if (instance == null) { - instance = new ODNParams(); - } - return instance; - } - - // We only use the properties needed for address validation - public ODNParams() { - super(); - addressHeader = 75; - p2shHeader = 125; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - // default dummy implementations, not used... - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 6001121e..e9ccb270 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -27,6 +27,7 @@ bisq.asset.coins.Litecoin$Regtest bisq.asset.coins.Litecoin$Testnet bisq.asset.coins.Madcoin bisq.asset.coins.Nxt +bisq.asset.coins.Obsidian bisq.asset.coins.Octocoin bisq.asset.coins.Particl bisq.asset.coins.Pranacoin diff --git a/src/test/java/bisq/asset/coins/ObsidianTest.java b/src/test/java/bisq/asset/coins/ObsidianTest.java new file mode 100644 index 00000000..bf7daa80 --- /dev/null +++ b/src/test/java/bisq/asset/coins/ObsidianTest.java @@ -0,0 +1,44 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class ObsidianTest extends AbstractAssetTest { + + public ObsidianTest() { + super(new Obsidian()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("XEfyuzk8yTp5eA9eVUeCW2PFbCFtNb6Jgv"); + assertValidAddress("XJegzjV2GK9CeQLNNcc5GVSSqTkv1XMxSF"); + assertValidAddress("XLfvvLuwjUrz2kf5gghEmUPFE3vFvwfEiL"); + assertValidAddress("XNC1e9TfUApfBsH9JCubioS5XGuwFLbsP4"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq"); + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d1641353982266"); + assertInvalidAddress("SSnwqFBiyqK1n4BV7kPX86iesev2NobhEo"); + } +} From a0f5b0a60c44132d534fc4aa3f2fabeaa475b060 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 16:39:06 +0200 Subject: [PATCH 045/106] Extract Cassubian Detk --- .../java/bisq/asset/coins/CassubianDetk.java | 29 ++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 -- .../META-INF/services/bisq.asset.Asset | 1 + .../bisq/asset/coins/CassubianDetkTest.java | 46 +++++++++++++++++++ 5 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/CassubianDetk.java create mode 100644 src/test/java/bisq/asset/coins/CassubianDetkTest.java diff --git a/src/main/java/bisq/asset/coins/CassubianDetk.java b/src/main/java/bisq/asset/coins/CassubianDetk.java new file mode 100644 index 00000000..6a396d56 --- /dev/null +++ b/src/main/java/bisq/asset/coins/CassubianDetk.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.RegexAddressValidator; + +public class CassubianDetk extends Coin { + + public CassubianDetk() { + super("Cassubian Detk", "CDT", new RegexAddressValidator("^D.*")); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index d0e16085..ec60b49b 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.6.6 - result.add(new CryptoCurrency("CDT", "Cassubian Detk")); result.add(new CryptoCurrency("DGM", "DigiMoney")); result.add(new CryptoCurrency("SCS", "SpeedCash")); result.add(new CryptoCurrency("SOS", "SOS Coin", true)); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 81705b41..8c251375 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -91,11 +91,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "CDT": - if (input.startsWith("D")) - return new ValidationResult(true); - else - return new ValidationResult(false); case "DGM": if (input.matches("^[D-E][a-zA-Z0-9]{33}$")) return new ValidationResult(true); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index e9ccb270..869e49cd 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -10,6 +10,7 @@ bisq.asset.coins.BitcoinGold bisq.asset.coins.BitDaric bisq.asset.coins.Byteball bisq.asset.coins.Cagecoin +bisq.asset.coins.CassubianDetk bisq.asset.coins.Creativecoin bisq.asset.coins.Cryptonite bisq.asset.coins.Dash$Mainnet diff --git a/src/test/java/bisq/asset/coins/CassubianDetkTest.java b/src/test/java/bisq/asset/coins/CassubianDetkTest.java new file mode 100644 index 00000000..4ea5f219 --- /dev/null +++ b/src/test/java/bisq/asset/coins/CassubianDetkTest.java @@ -0,0 +1,46 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class CassubianDetkTest extends AbstractAssetTest { + + public CassubianDetkTest() { + super(new CassubianDetk()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("DM7BjopQ3bGYxSPZ4yhfttxqnDrEkyc3sw"); + assertValidAddress("DB4CaJ81SiT3VtpGC8K1RMirPJZjsmKiZd"); + assertValidAddress("DE7uB1mws1RwYNDPpfEnQ7a4i9tdqqV1Lf"); + assertValidAddress("DJ8FnzVCa8AXEBt5aqPcJubKRzanQKvxkY"); + assertValidAddress("D5QmzfBjwrUyAKtvectJL7kBawfWtwdJqz"); + assertValidAddress("DDRJemKbVtTVV8r2jSG9wevv3JeUj2edAr"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq"); + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d1641353982266"); + assertInvalidAddress("SSnwqFBiyqK1n4BV7kPX86iesev2NobhEo"); + } +} From 034d62a4aad26e2cb97d73ed7d9520e36294e397 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 16:43:38 +0200 Subject: [PATCH 046/106] Extract DigiMoney --- src/main/java/bisq/asset/coins/DigiMoney.java | 29 +++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 --- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/DigiMoneyTest.java | 42 +++++++++++++++++++ 5 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/DigiMoney.java create mode 100644 src/test/java/bisq/asset/coins/DigiMoneyTest.java diff --git a/src/main/java/bisq/asset/coins/DigiMoney.java b/src/main/java/bisq/asset/coins/DigiMoney.java new file mode 100644 index 00000000..7ee8b8f6 --- /dev/null +++ b/src/main/java/bisq/asset/coins/DigiMoney.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.RegexAddressValidator; + +public class DigiMoney extends Coin { + + public DigiMoney() { + super("DigiMoney", "DGM", new RegexAddressValidator("^[D-E][a-zA-Z0-9]{33}$")); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index ec60b49b..aaa04b60 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.6.6 - result.add(new CryptoCurrency("DGM", "DigiMoney")); result.add(new CryptoCurrency("SCS", "SpeedCash")); result.add(new CryptoCurrency("SOS", "SOS Coin", true)); result.add(new CryptoCurrency("ACH", "AchieveCoin")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 8c251375..a24d41fa 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -91,11 +91,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "DGM": - if (input.matches("^[D-E][a-zA-Z0-9]{33}$")) - return new ValidationResult(true); - else - return regexTestFailed; case "SCS": try { Address.fromBase58(SpeedCashParams.get(), input); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 869e49cd..18a1069d 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -18,6 +18,7 @@ bisq.asset.coins.Dash$Regtest bisq.asset.coins.Dash$Testnet bisq.asset.coins.Decent bisq.asset.coins.DeepOnion +bisq.asset.coins.DigiMoney bisq.asset.coins.Dogecoin bisq.asset.coins.Ether bisq.asset.coins.InfinityEconomics diff --git a/src/test/java/bisq/asset/coins/DigiMoneyTest.java b/src/test/java/bisq/asset/coins/DigiMoneyTest.java new file mode 100644 index 00000000..1db4f9c8 --- /dev/null +++ b/src/test/java/bisq/asset/coins/DigiMoneyTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class DigiMoneyTest extends AbstractAssetTest { + + public DigiMoneyTest() { + super(new DigiMoney()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("DvaAgcLKrno2AC7kYhHVDCrkhx2xHFpXUf"); + assertValidAddress("E9p49poRmnuLdnu55bzKe7t48xtYv2bRES"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("0xmnuL9poRmnuLd55bzKe7t48xtYv2bRES"); + assertInvalidAddress("DvaAgcLKrno2AC7kYhHVDC"); + assertInvalidAddress("19p49poRmnuLdnu55bzKe7t48xtYv2bRES"); + } +} From 0ad058c4cf0870204cfe8652ea3b07d38a9469f8 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 16:48:28 +0200 Subject: [PATCH 047/106] Extract SpeedCash --- src/main/java/bisq/asset/coins/SpeedCash.java | 39 ++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 8 -- .../validation/params/SpeedCashParams.java | 93 ------------------- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/SpeedCashTest.java | 44 +++++++++ 6 files changed, 84 insertions(+), 102 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/SpeedCash.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/SpeedCashParams.java create mode 100644 src/test/java/bisq/asset/coins/SpeedCashTest.java diff --git a/src/main/java/bisq/asset/coins/SpeedCash.java b/src/main/java/bisq/asset/coins/SpeedCash.java new file mode 100644 index 00000000..3ecb35a1 --- /dev/null +++ b/src/main/java/bisq/asset/coins/SpeedCash.java @@ -0,0 +1,39 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class SpeedCash extends Coin { + + public SpeedCash() { + super("SpeedCash", "SCS", new Base58BitcoinAddressValidator(new SpeedCashParams())); + } + + + public static class SpeedCashParams extends NetworkParametersAdapter { + + public SpeedCashParams() { + addressHeader = 63; + p2shHeader = 85; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index aaa04b60..fc3f1fcd 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.6.6 - result.add(new CryptoCurrency("SCS", "SpeedCash")); result.add(new CryptoCurrency("SOS", "SOS Coin", true)); result.add(new CryptoCurrency("ACH", "AchieveCoin")); result.add(new CryptoCurrency("VDN", "vDinar")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index a24d41fa..762e4032 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -25,7 +25,6 @@ import bisq.core.payment.validation.params.ACHParams; import bisq.core.payment.validation.params.AlcParams; import bisq.core.payment.validation.params.PhoreParams; -import bisq.core.payment.validation.params.SpeedCashParams; import bisq.core.payment.validation.params.StrayaParams; import bisq.core.payment.validation.params.WMCCParams; import bisq.core.util.validation.InputValidator; @@ -91,13 +90,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "SCS": - try { - Address.fromBase58(SpeedCashParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } case "SOS": if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) return regexTestFailed; diff --git a/src/main/java/bisq/core/payment/validation/params/SpeedCashParams.java b/src/main/java/bisq/core/payment/validation/params/SpeedCashParams.java deleted file mode 100644 index abfb1c64..00000000 --- a/src/main/java/bisq/core/payment/validation/params/SpeedCashParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class SpeedCashParams extends NetworkParameters { - - private static SpeedCashParams instance; - - public static synchronized SpeedCashParams get() { - if (instance == null) { - instance = new SpeedCashParams(); - } - return instance; - } - - // We only use the properties needed for address validation - public SpeedCashParams() { - super(); - addressHeader = 63; - p2shHeader = 85; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - // default dummy implementations, not used... - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 18a1069d..d689cd33 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -35,6 +35,7 @@ bisq.asset.coins.Particl bisq.asset.coins.Pranacoin bisq.asset.coins.PIVX bisq.asset.coins.Spectrecoin +bisq.asset.coins.SpeedCash bisq.asset.coins.Stellite bisq.asset.coins.Terracoin bisq.asset.coins.Wacoin diff --git a/src/test/java/bisq/asset/coins/SpeedCashTest.java b/src/test/java/bisq/asset/coins/SpeedCashTest.java new file mode 100644 index 00000000..9df1f125 --- /dev/null +++ b/src/test/java/bisq/asset/coins/SpeedCashTest.java @@ -0,0 +1,44 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class SpeedCashTest extends AbstractAssetTest { + + public SpeedCashTest() { + super(new SpeedCash()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("SNrVzPaFVCQGH4Rdch2EuhoyeWMfgWqk1J"); + assertValidAddress("SXPvGe87gdCFQH8zPU3JdKNGwAa4c6979r"); + assertValidAddress("STGvWjZdkwDeNoYa73cqMrAFFYm5xtJndc"); + assertValidAddress("SVPZMBgDxBVDRisdDZGD1XQwyAz8RBbo3J"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("SVPZMBgDxBVDRisdDZGD1XQwyAz8RBbo3R"); + assertInvalidAddress("mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn"); + assertInvalidAddress("XLfvvLuwjUrz2kf5gghEmUPFE3vFvwfEiL"); + } +} From 335496b7ccce58d187d4a15a6ddd3b967602cde6 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 16:55:31 +0200 Subject: [PATCH 048/106] Extract SOS Coin --- src/main/java/bisq/asset/tokens/SosCoin.java | 10 +++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 --- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/tokens/SosCoinTest.java | 42 +++++++++++++++++++ 5 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/tokens/SosCoin.java create mode 100644 src/test/java/bisq/asset/tokens/SosCoinTest.java diff --git a/src/main/java/bisq/asset/tokens/SosCoin.java b/src/main/java/bisq/asset/tokens/SosCoin.java new file mode 100644 index 00000000..f1072949 --- /dev/null +++ b/src/main/java/bisq/asset/tokens/SosCoin.java @@ -0,0 +1,10 @@ +package bisq.asset.tokens; + +import bisq.asset.Erc20Token; + +public class SosCoin extends Erc20Token { + + public SosCoin() { + super("SOS Coin", "SOS"); + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index fc3f1fcd..8d56c68d 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.6.6 - result.add(new CryptoCurrency("SOS", "SOS Coin", true)); result.add(new CryptoCurrency("ACH", "AchieveCoin")); result.add(new CryptoCurrency("VDN", "vDinar")); result.add(new CryptoCurrency("WMCC", "WorldMobileCoin")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 762e4032..da9b4f64 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -90,11 +90,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "SOS": - if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) - return regexTestFailed; - else - return new ValidationResult(true); case "ACH": try { Address.fromBase58(ACHParams.get(), input); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index d689cd33..cee3b11c 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -48,5 +48,6 @@ bisq.asset.tokens.Ellaism bisq.asset.tokens.Internext bisq.asset.tokens.Movement bisq.asset.tokens.RefToken +bisq.asset.tokens.SosCoin bisq.asset.tokens.Verify bisq.asset.tokens.WildToken diff --git a/src/test/java/bisq/asset/tokens/SosCoinTest.java b/src/test/java/bisq/asset/tokens/SosCoinTest.java new file mode 100644 index 00000000..7a105e40 --- /dev/null +++ b/src/test/java/bisq/asset/tokens/SosCoinTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class SosCoinTest extends AbstractAssetTest { + + public SosCoinTest() { + super(new SosCoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("0x2a65Aca4D5fC5B5C859090a6c34d164135398226"); + assertValidAddress("2a65Aca4D5fC5B5C859090a6c34d164135398226"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d1641353982266"); + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + assertInvalidAddress("2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + } +} From c89fe8aa8711eccf879e0dffa54c57775590150c Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 28 Mar 2018 17:00:36 +0200 Subject: [PATCH 049/106] Extract AchieveCoin --- .../java/bisq/asset/coins/Achievecoin.java | 54 +++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 8 -- .../payment/validation/params/ACHParams.java | 75 ------------------- .../META-INF/services/bisq.asset.Asset | 1 + .../bisq/asset/coins/AchievecoinTest.java | 43 +++++++++++ 6 files changed, 98 insertions(+), 84 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Achievecoin.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/ACHParams.java create mode 100644 src/test/java/bisq/asset/coins/AchievecoinTest.java diff --git a/src/main/java/bisq/asset/coins/Achievecoin.java b/src/main/java/bisq/asset/coins/Achievecoin.java new file mode 100644 index 00000000..726d0bdc --- /dev/null +++ b/src/main/java/bisq/asset/coins/Achievecoin.java @@ -0,0 +1,54 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +import org.bitcoinj.core.Utils; + +public class Achievecoin extends Coin { + + public Achievecoin() { + super("AchieveCoin", "ACH", new Base58BitcoinAddressValidator(new AchievecoinParams())); + } + + + public static class AchievecoinParams extends NetworkParametersAdapter { + + public AchievecoinParams() { + interval = INTERVAL; + targetTimespan = TARGET_TIMESPAN; + maxTarget = Utils.decodeCompactBits(0x1d00ffffL); + dumpedPrivateKeyHeader = 128; + + // Address format is different to BTC, rest is the same + addressHeader = 23; //BTG 38; + p2shHeader = 34; //BTG 23; + + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + port = 7337; //BTC and BTG 8333 + packetMagic = 0x1461de3cL; //BTG 0xe1476d44L, BTC 0xf9beb4d9L; + bip32HeaderPub = 0x02651F71; //BTG and BTC 0x0488B21E; //The 4 byte header that serializes in base58 to "xpub". + bip32HeaderPriv = 0x02355E56; //BTG and BTC 0x0488ADE4; //The 4 byte header that serializes in base58 to "xprv" + + id = ID_MAINNET; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 8d56c68d..84a12698 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.6.6 - result.add(new CryptoCurrency("ACH", "AchieveCoin")); result.add(new CryptoCurrency("VDN", "vDinar")); result.add(new CryptoCurrency("WMCC", "WorldMobileCoin")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index da9b4f64..7b297b8e 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -22,7 +22,6 @@ import bisq.core.locale.Res; import bisq.core.payment.validation.altcoins.KOTOAddressValidator; import bisq.core.payment.validation.altcoins.WMCCAddressValidator; -import bisq.core.payment.validation.params.ACHParams; import bisq.core.payment.validation.params.AlcParams; import bisq.core.payment.validation.params.PhoreParams; import bisq.core.payment.validation.params.StrayaParams; @@ -90,13 +89,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "ACH": - try { - Address.fromBase58(ACHParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } case "VDN": if (!input.matches("^[D][0-9a-zA-Z]{33}$")) return regexTestFailed; diff --git a/src/main/java/bisq/core/payment/validation/params/ACHParams.java b/src/main/java/bisq/core/payment/validation/params/ACHParams.java deleted file mode 100644 index 3e5ef7f9..00000000 --- a/src/main/java/bisq/core/payment/validation/params/ACHParams.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -/* - * Copyright 2013 Google Inc. - * Copyright 2015 Andreas Schildbach - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.Utils; -import org.bitcoinj.params.AbstractBitcoinNetParams; - -public class ACHParams extends AbstractBitcoinNetParams { - - public ACHParams() { - super(); - interval = INTERVAL; - targetTimespan = TARGET_TIMESPAN; - maxTarget = Utils.decodeCompactBits(0x1d00ffffL); - dumpedPrivateKeyHeader = 128; - - // Address format is different to BTC, rest is the same - addressHeader = 23; //BTG 38; - p2shHeader = 34; //BTG 23; - - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - port = 7337; //BTC and BTG 8333 - packetMagic = 0x1461de3cL; //BTG 0xe1476d44L, BTC 0xf9beb4d9L; - bip32HeaderPub = 0x02651F71; //BTG and BTC 0x0488B21E; //The 4 byte header that serializes in base58 to "xpub". - bip32HeaderPriv = 0x02355E56; //BTG and BTC 0x0488ADE4; //The 4 byte header that serializes in base58 to "xprv" - - id = ID_MAINNET; - } - - private static ACHParams instance; - - public static synchronized ACHParams get() { - if (instance == null) { - instance = new ACHParams(); - } - return instance; - } - - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index cee3b11c..9bee8e00 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -1,3 +1,4 @@ +bisq.asset.coins.Achievecoin bisq.asset.coins.BSQ$Mainnet bisq.asset.coins.BSQ$Regtest bisq.asset.coins.BSQ$Testnet diff --git a/src/test/java/bisq/asset/coins/AchievecoinTest.java b/src/test/java/bisq/asset/coins/AchievecoinTest.java new file mode 100644 index 00000000..ccdfe87c --- /dev/null +++ b/src/test/java/bisq/asset/coins/AchievecoinTest.java @@ -0,0 +1,43 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class AchievecoinTest extends AbstractAssetTest { + + public AchievecoinTest() { + super(new Achievecoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("AciV7ZyJDpCg7kGGmbo97VjgjpVZkXRTMD"); + assertValidAddress("ARhW8anWaZtExdK2cQkBwsvsQZ9TkC9bwH"); + assertValidAddress("AcxpGTWX4zFiD8p8hfYw99RXV7MY2y8hs9"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("GWaSW6PHfQKBv8EXV3xiqGG2zxKZh4XYNu"); + assertInvalidAddress("AcxpGTWX4zFiD8p8hfY099RXV7MY2y8hs9"); + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem"); + } +} From 934dbf6b47900fa8208cd3b977d1956c7b93bef4 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 08:34:50 +0200 Subject: [PATCH 050/106] Extract vDinar --- src/main/java/bisq/asset/coins/VDinar.java | 29 ++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 -- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/VDinarTest.java | 47 +++++++++++++++++++ 5 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/VDinar.java create mode 100644 src/test/java/bisq/asset/coins/VDinarTest.java diff --git a/src/main/java/bisq/asset/coins/VDinar.java b/src/main/java/bisq/asset/coins/VDinar.java new file mode 100644 index 00000000..ee4e37ac --- /dev/null +++ b/src/main/java/bisq/asset/coins/VDinar.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.RegexAddressValidator; + +public class VDinar extends Coin { + + public VDinar() { + super("vDinar", "VDN", new RegexAddressValidator("^[D][0-9a-zA-Z]{33}$")); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 84a12698..3f2448f7 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.6.6 - result.add(new CryptoCurrency("VDN", "vDinar")); result.add(new CryptoCurrency("WMCC", "WorldMobileCoin")); // Added 0.7.0 diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 7b297b8e..86743603 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -89,11 +89,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "VDN": - if (!input.matches("^[D][0-9a-zA-Z]{33}$")) - return regexTestFailed; - else - return new ValidationResult(true); case "ALC": if (input.matches("^[A][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { //noinspection ConstantConditions diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 9bee8e00..99b1bc34 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -39,6 +39,7 @@ bisq.asset.coins.Spectrecoin bisq.asset.coins.SpeedCash bisq.asset.coins.Stellite bisq.asset.coins.Terracoin +bisq.asset.coins.VDinar bisq.asset.coins.Wacoin bisq.asset.coins.Yenten bisq.asset.coins.Zcash diff --git a/src/test/java/bisq/asset/coins/VDinarTest.java b/src/test/java/bisq/asset/coins/VDinarTest.java new file mode 100644 index 00000000..51f83b1b --- /dev/null +++ b/src/test/java/bisq/asset/coins/VDinarTest.java @@ -0,0 +1,47 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class VDinarTest extends AbstractAssetTest { + + public VDinarTest() { + super(new VDinar()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("DG1KpSsSXd3uitgwHaA1i6T1Bj1hWEwAxB"); + assertValidAddress("DPEfTj1C9tTKEqkLPUwtUtCZHd7ViedBmZ"); + assertValidAddress("DLzjxv6Rk9hMYEFHBLqvyT8pkfS43u9Md5"); + assertValidAddress("DHexLqYt4ooDDnpmfEMSa1oJBbaZBxURZH"); + assertValidAddress("DHPybrRc2iqeE4aU8mmXKf8v38JTDyH2V9"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq"); + assertInvalidAddress("3CDJNfdWX8m2NwuGUV3nhXHXEeLygMXoAj"); + assertInvalidAddress("DG1KpSsSXd3uitgwHaA1i6T1BjSHORTER"); + assertInvalidAddress("DG1KpSsSXd3uitgwHaA1i6T1Bj1hWLONGER"); + assertInvalidAddress("HG1KpSsSXd3uitgwHaA1i6T1Bj1hWEwAxB"); + } +} From 731845e9a2cff70814d9de00f95d3bb581fc8b18 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 08:41:47 +0200 Subject: [PATCH 051/106] Extract Anglecoin --- src/main/java/bisq/asset/coins/Angelcoin.java | 54 +++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 13 --- .../payment/validation/params/AlcParams.java | 93 ------------------- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/AngelcoinTest.java | 44 +++++++++ 6 files changed, 99 insertions(+), 107 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Angelcoin.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/AlcParams.java create mode 100644 src/test/java/bisq/asset/coins/AngelcoinTest.java diff --git a/src/main/java/bisq/asset/coins/Angelcoin.java b/src/main/java/bisq/asset/coins/Angelcoin.java new file mode 100644 index 00000000..72ef9a33 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Angelcoin.java @@ -0,0 +1,54 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class Angelcoin extends Coin { + + public Angelcoin() { + super("Angelcoin", "ALC", new AngelcoinAddressValidator()); + } + + public static class AngelcoinAddressValidator extends Base58BitcoinAddressValidator { + + public AngelcoinAddressValidator() { + super(new AngelcoinParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[A][a-km-zA-HJ-NP-Z1-9]{25,34}$")) + return AddressValidationResult.invalidStructure(); + + return super.validate(address); + } + } + + public static class AngelcoinParams extends NetworkParametersAdapter { + + public AngelcoinParams() { + addressHeader = 23; + p2shHeader = 5; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 3f2448f7..3e4b3fda 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -141,7 +141,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("WMCC", "WorldMobileCoin")); // Added 0.7.0 - result.add(new CryptoCurrency("ALC", "Angelcoin")); result.add(new CryptoCurrency("DIN", "Dinero")); result.add(new CryptoCurrency("NAH", "Strayacoin")); result.add(new CryptoCurrency("ROI", "ROIcoin")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 86743603..9318fe6b 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -22,7 +22,6 @@ import bisq.core.locale.Res; import bisq.core.payment.validation.altcoins.KOTOAddressValidator; import bisq.core.payment.validation.altcoins.WMCCAddressValidator; -import bisq.core.payment.validation.params.AlcParams; import bisq.core.payment.validation.params.PhoreParams; import bisq.core.payment.validation.params.StrayaParams; import bisq.core.payment.validation.params.WMCCParams; @@ -89,18 +88,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "ALC": - if (input.matches("^[A][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { - //noinspection ConstantConditions - try { - Address.fromBase58(AlcParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } - } else { - return regexTestFailed; - } case "DIN": if (!input.matches("^[D][0-9a-zA-Z]{33}$")) return regexTestFailed; diff --git a/src/main/java/bisq/core/payment/validation/params/AlcParams.java b/src/main/java/bisq/core/payment/validation/params/AlcParams.java deleted file mode 100644 index d8fafaf5..00000000 --- a/src/main/java/bisq/core/payment/validation/params/AlcParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class AlcParams extends NetworkParameters { - - private static AlcParams instance; - - public static synchronized AlcParams get() { - if (instance == null) { - instance = new AlcParams(); - } - return instance; - } - - // We only use the properties needed for address validation - public AlcParams() { - super(); - addressHeader = 23; - p2shHeader = 5; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - // default dummy implementations, not used... - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 99b1bc34..4d4e7660 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -1,4 +1,5 @@ bisq.asset.coins.Achievecoin +bisq.asset.coins.Angelcoin bisq.asset.coins.BSQ$Mainnet bisq.asset.coins.BSQ$Regtest bisq.asset.coins.BSQ$Testnet diff --git a/src/test/java/bisq/asset/coins/AngelcoinTest.java b/src/test/java/bisq/asset/coins/AngelcoinTest.java new file mode 100644 index 00000000..c584261d --- /dev/null +++ b/src/test/java/bisq/asset/coins/AngelcoinTest.java @@ -0,0 +1,44 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class AngelcoinTest extends AbstractAssetTest { + + public AngelcoinTest() { + super(new Angelcoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("AQJTNtWcP7opxuR52Lf5vmoQTC8EHQ6GxV"); + assertValidAddress("ALEK7jttmqtx2ZhXHg69Zr426qKBnzYA9E"); + assertValidAddress("AP1egWUthPoYvZL57aBk4RPqUgjG1fJGn6"); + assertValidAddress("AST3zfvPdZ35npxAVC8ABgVCxxDLwTmAHU"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("1AQJTNtWcP7opxuR52Lf5vmoQTC8EHQ6GxV"); + assertInvalidAddress("1ALEK7jttmqtx2ZhXHg69Zr426qKBnzYA9E"); + assertInvalidAddress("1AP1egWUthPoYvZL57aBk4RPqUgjG1fJGn6"); + } +} From aa22f58648d42a6a9b032b2d745686b58e40f339 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 08:44:07 +0200 Subject: [PATCH 052/106] Extract Dinero --- src/main/java/bisq/asset/coins/Dinero.java | 29 ++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 --- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/DineroTest.java | 44 +++++++++++++++++++ 5 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Dinero.java create mode 100644 src/test/java/bisq/asset/coins/DineroTest.java diff --git a/src/main/java/bisq/asset/coins/Dinero.java b/src/main/java/bisq/asset/coins/Dinero.java new file mode 100644 index 00000000..78506658 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Dinero.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.RegexAddressValidator; + +public class Dinero extends Coin { + + public Dinero() { + super("Dinero", "DIN", new RegexAddressValidator("^[D][0-9a-zA-Z]{33}$")); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 3e4b3fda..ae4f3d17 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -141,7 +141,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("WMCC", "WorldMobileCoin")); // Added 0.7.0 - result.add(new CryptoCurrency("DIN", "Dinero")); result.add(new CryptoCurrency("NAH", "Strayacoin")); result.add(new CryptoCurrency("ROI", "ROIcoin")); result.add(new CryptoCurrency("RTO", "Arto")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 9318fe6b..910d6052 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -88,11 +88,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "DIN": - if (!input.matches("^[D][0-9a-zA-Z]{33}$")) - return regexTestFailed; - else - return new ValidationResult(true); case "NAH": if (input.matches("^[S][a-zA-Z0-9]{26,34}$")) { //noinspection ConstantConditions diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 4d4e7660..23fb834e 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -21,6 +21,7 @@ bisq.asset.coins.Dash$Testnet bisq.asset.coins.Decent bisq.asset.coins.DeepOnion bisq.asset.coins.DigiMoney +bisq.asset.coins.Dinero bisq.asset.coins.Dogecoin bisq.asset.coins.Ether bisq.asset.coins.InfinityEconomics diff --git a/src/test/java/bisq/asset/coins/DineroTest.java b/src/test/java/bisq/asset/coins/DineroTest.java new file mode 100644 index 00000000..fb8789fd --- /dev/null +++ b/src/test/java/bisq/asset/coins/DineroTest.java @@ -0,0 +1,44 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class DineroTest extends AbstractAssetTest { + + public DineroTest() { + super(new Dinero()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("DBmvak2TM8GpeiR3ZEVWAHWFZeiw9FG7jK"); + assertValidAddress("DDWit1CcocL2j3CzfmZgz4bx2DE1h8tugv"); + assertValidAddress("DF8D75bjz6i8azUHgmbV3awpn6tni5W43B"); + assertValidAddress("DJquenkkiFVNpF7vVLg2xKnxCjKwnYb6Ay"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("1QbFeFc3iqRYhemqq7VZNX1SN5NtKa8UQFxw"); + assertInvalidAddress("7rrpfJKZC7t1R2FPKrsvfkcE8KBLuSyVYAjt"); + assertInvalidAddress("QFxwQbFeFc3iqRYhek"); + } +} From 1295c8d562e7c204ec967d7d680fdcac9c55c7fa Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 08:58:14 +0200 Subject: [PATCH 053/106] Extract Strayacoin --- .../java/bisq/asset/coins/Strayacoin.java | 56 +++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 13 --- .../validation/params/StrayaParams.java | 93 ------------------- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/StrayacoinTest.java | 44 +++++++++ 6 files changed, 101 insertions(+), 107 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Strayacoin.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/StrayaParams.java create mode 100644 src/test/java/bisq/asset/coins/StrayacoinTest.java diff --git a/src/main/java/bisq/asset/coins/Strayacoin.java b/src/main/java/bisq/asset/coins/Strayacoin.java new file mode 100644 index 00000000..cedaa60a --- /dev/null +++ b/src/main/java/bisq/asset/coins/Strayacoin.java @@ -0,0 +1,56 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class Strayacoin extends Coin { + + public Strayacoin() { + super("Strayacoin", "NAH", new StrayacoinAddressValidator()); + } + + + public static class StrayacoinAddressValidator extends Base58BitcoinAddressValidator { + + public StrayacoinAddressValidator() { + super(new StrayacoinParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[S][a-zA-Z0-9]{26,34}$")) + return AddressValidationResult.invalidStructure(); + + return super.validate(address); + } + } + + + public static class StrayacoinParams extends NetworkParametersAdapter { + + public StrayacoinParams() { + addressHeader = 63; + p2shHeader = 50; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index ae4f3d17..56cb830b 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -141,7 +141,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("WMCC", "WorldMobileCoin")); // Added 0.7.0 - result.add(new CryptoCurrency("NAH", "Strayacoin")); result.add(new CryptoCurrency("ROI", "ROIcoin")); result.add(new CryptoCurrency("RTO", "Arto")); result.add(new CryptoCurrency("KOTO", "Koto")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 910d6052..a00958c0 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -23,7 +23,6 @@ import bisq.core.payment.validation.altcoins.KOTOAddressValidator; import bisq.core.payment.validation.altcoins.WMCCAddressValidator; import bisq.core.payment.validation.params.PhoreParams; -import bisq.core.payment.validation.params.StrayaParams; import bisq.core.payment.validation.params.WMCCParams; import bisq.core.util.validation.InputValidator; @@ -88,18 +87,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "NAH": - if (input.matches("^[S][a-zA-Z0-9]{26,34}$")) { - //noinspection ConstantConditions - try { - Address.fromBase58(StrayaParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } - } else { - return regexTestFailed; - } case "ROI": if (!input.matches("^[R][0-9a-zA-Z]{33}$")) return regexTestFailed; diff --git a/src/main/java/bisq/core/payment/validation/params/StrayaParams.java b/src/main/java/bisq/core/payment/validation/params/StrayaParams.java deleted file mode 100644 index 6d168c29..00000000 --- a/src/main/java/bisq/core/payment/validation/params/StrayaParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class StrayaParams extends NetworkParameters { - - private static StrayaParams instance; - - public static synchronized StrayaParams get() { - if (instance == null) { - instance = new StrayaParams(); - } - return instance; - } - - // We only use the properties needed for address validation - public StrayaParams() { - super(); - addressHeader = 63; - p2shHeader = 50; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - // default dummy implementations, not used... - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 23fb834e..683b6a96 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -40,6 +40,7 @@ bisq.asset.coins.PIVX bisq.asset.coins.Spectrecoin bisq.asset.coins.SpeedCash bisq.asset.coins.Stellite +bisq.asset.coins.Strayacoin bisq.asset.coins.Terracoin bisq.asset.coins.VDinar bisq.asset.coins.Wacoin diff --git a/src/test/java/bisq/asset/coins/StrayacoinTest.java b/src/test/java/bisq/asset/coins/StrayacoinTest.java new file mode 100644 index 00000000..514bf0da --- /dev/null +++ b/src/test/java/bisq/asset/coins/StrayacoinTest.java @@ -0,0 +1,44 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class StrayacoinTest extends AbstractAssetTest { + + public StrayacoinTest() { + super(new Strayacoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("SZHa3vS9ctDJwx3BziaqgN3zQMkYpgyP7f"); + assertValidAddress("SefAdKgyqdg7wd1emhFynPs44d1b2Ca2U1"); + assertValidAddress("SSw6555umxHsPZgE96KoyiEVY3CDuJRBQc"); + assertValidAddress("SYwJ6aXQkmt3ExuaXBSCmyiHRn8fUpxXUi"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemqq"); + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d1641353982266"); + assertInvalidAddress("DNkkfdUvkCDiywYE98MTVp9nQJTgeZAiFr"); + } +} From 560c588c048373c857ee48bfbe0b20760619e682 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 09:02:07 +0200 Subject: [PATCH 054/106] Extract ROIcoin --- src/main/java/bisq/asset/coins/Roicoin.java | 29 +++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 --- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/RoicoinTest.java | 42 +++++++++++++++++++ 5 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Roicoin.java create mode 100644 src/test/java/bisq/asset/coins/RoicoinTest.java diff --git a/src/main/java/bisq/asset/coins/Roicoin.java b/src/main/java/bisq/asset/coins/Roicoin.java new file mode 100644 index 00000000..519a247c --- /dev/null +++ b/src/main/java/bisq/asset/coins/Roicoin.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.RegexAddressValidator; + +public class Roicoin extends Coin { + + public Roicoin() { + super("ROIcoin", "ROI", new RegexAddressValidator("^[R][0-9a-zA-Z]{33}$")); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 56cb830b..daac5933 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -141,7 +141,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("WMCC", "WorldMobileCoin")); // Added 0.7.0 - result.add(new CryptoCurrency("ROI", "ROIcoin")); result.add(new CryptoCurrency("RTO", "Arto")); result.add(new CryptoCurrency("KOTO", "Koto")); result.add(new CryptoCurrency("UBQ", "Ubiq")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index a00958c0..8a506357 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -87,11 +87,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "ROI": - if (!input.matches("^[R][0-9a-zA-Z]{33}$")) - return regexTestFailed; - else - return new ValidationResult(true); case "WMCC": return WMCCAddressValidator.ValidateAddress(WMCCParams.get(), input); case "RTO": diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 683b6a96..8ed1bb0d 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -37,6 +37,7 @@ bisq.asset.coins.Octocoin bisq.asset.coins.Particl bisq.asset.coins.Pranacoin bisq.asset.coins.PIVX +bisq.asset.coins.Roicoin bisq.asset.coins.Spectrecoin bisq.asset.coins.SpeedCash bisq.asset.coins.Stellite diff --git a/src/test/java/bisq/asset/coins/RoicoinTest.java b/src/test/java/bisq/asset/coins/RoicoinTest.java new file mode 100644 index 00000000..7970354c --- /dev/null +++ b/src/test/java/bisq/asset/coins/RoicoinTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class RoicoinTest extends AbstractAssetTest { + + public RoicoinTest() { + super(new Roicoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("RSdzB2mFpQ6cR3HmEopbaRBjrEMWAwXBYn"); + assertValidAddress("RBQN9ybF5JzsPQdsiHMpGfkA5HpwddKvmU"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("1RBQN9ybF5JzsPQdsiHMpGfkA5HpwddKvmU"); + assertInvalidAddress("RBQN9ybF5JzsPQdsiHMpGfkA5HpwddKvmU1"); + assertInvalidAddress("RBQN9ybF5JzsPQdsiHMpGfkA5HpwddKvmU#"); + } +} From 98893f7fcd35f092bec0ac5c6935bf6928574258 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 09:31:33 +0200 Subject: [PATCH 055/106] Extract WorldMobileCoin --- .../bisq/asset/coins/WorldMobileCoin.java | 266 ++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 3 - .../validation/AltCoinAddressValidator.java | 4 - .../altcoins/WMCCAddressValidator.java | 242 ---------------- .../payment/validation/params/WMCCParams.java | 93 ------ .../META-INF/services/bisq.asset.Asset | 1 + .../bisq/asset/coins/WorldMobileCoinTest.java | 47 ++++ 7 files changed, 314 insertions(+), 342 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/WorldMobileCoin.java delete mode 100644 src/main/java/bisq/core/payment/validation/altcoins/WMCCAddressValidator.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/WMCCParams.java create mode 100644 src/test/java/bisq/asset/coins/WorldMobileCoinTest.java diff --git a/src/main/java/bisq/asset/coins/WorldMobileCoin.java b/src/main/java/bisq/asset/coins/WorldMobileCoin.java new file mode 100644 index 00000000..08476ff7 --- /dev/null +++ b/src/main/java/bisq/asset/coins/WorldMobileCoin.java @@ -0,0 +1,266 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.AddressValidator; +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +import org.bitcoinj.core.AddressFormatException; +import org.bitcoinj.core.NetworkParameters; +import org.bitcoinj.core.VersionedChecksummedBytes; +import org.bitcoinj.params.Networks; + +import java.io.ByteArrayOutputStream; + +import java.util.Arrays; +import java.util.Locale; + +import javax.annotation.Nullable; + +public class WorldMobileCoin extends Coin { + + public WorldMobileCoin() { + super("WorldMobileCoin", "WMCC", new WorldMobileCoinAddressValidator()); + } + + + public static class WorldMobileCoinAddressValidator implements AddressValidator { + + private final Base58BitcoinAddressValidator base58BitcoinAddressValidator; + private final NetworkParameters networkParameters; + + public WorldMobileCoinAddressValidator() { + networkParameters = new WorldMobileCoinParams(); + base58BitcoinAddressValidator = new Base58BitcoinAddressValidator(networkParameters); + } + + public AddressValidationResult validate(String address) { + if (!isLowerCase(address)) { + return base58BitcoinAddressValidator.validate(address); + } + + try { + WitnessAddress.fromBech32(networkParameters, address); + } catch (AddressFormatException ex) { + return AddressValidationResult.invalidAddress(ex); + } + + return AddressValidationResult.validAddress(); + } + + private static boolean isLowerCase(String str) { + char ch; + for (int i = 0; i < str.length(); i++) { + ch = str.charAt(i); + if (Character.isDigit(ch)) + continue; + if (!Character.isLowerCase(ch)) + return false; + } + return true; + } + + } + + public static class WorldMobileCoinParams extends NetworkParametersAdapter { + + public WorldMobileCoinParams() { + addressHeader = 0x49; + p2shHeader = 0x4b; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + + } + } + + private static class WitnessAddress extends VersionedChecksummedBytes { + static final int PROGRAM_LENGTH_PKH = 20; + static final int PROGRAM_LENGTH_SH = 32; + static final int PROGRAM_MIN_LENGTH = 2; + static final int PROGRAM_MAX_LENGTH = 40; + static final String WITNESS_ADDRESS_HRP = "wc"; + + private WitnessAddress(NetworkParameters params, byte[] data) throws AddressFormatException { + super(params.getAddressHeader(), data); + if (data.length < 1) + throw new AddressFormatException("Zero data found"); + final int version = getWitnessVersion(); + if (version < 0 || version > 16) + throw new AddressFormatException("Invalid script version: " + version); + byte[] program = getWitnessProgram(); + if (program.length < PROGRAM_MIN_LENGTH || program.length > PROGRAM_MAX_LENGTH) + throw new AddressFormatException("Invalid length: " + program.length); + if (version == 0 && program.length != PROGRAM_LENGTH_PKH + && program.length != PROGRAM_LENGTH_SH) + throw new AddressFormatException( + "Invalid length for address version 0: " + program.length); + } + + int getWitnessVersion() { + return bytes[0] & 0xff; + } + + byte[] getWitnessProgram() { + return convertBits(bytes, 1, bytes.length - 1, 5, 8, false); + } + + static WitnessAddress fromBech32(@Nullable NetworkParameters params, String bech32) + throws AddressFormatException { + Bech32.Bech32Data bechData = Bech32.decode(bech32); + if (params == null) { + for (NetworkParameters p : Networks.get()) { + if (bechData.hrp.equals(WITNESS_ADDRESS_HRP)) + return new WitnessAddress(p, bechData.data); + } + throw new AddressFormatException("Invalid Prefix: No network found for " + bech32); + } else { + if (bechData.hrp.equals(WITNESS_ADDRESS_HRP)) + return new WitnessAddress(params, bechData.data); + throw new AddressFormatException("Wrong Network: " + bechData.hrp); + } + } + + /** + * Helper + */ + private static byte[] convertBits(final byte[] in, final int inStart, final int inLen, final int fromBits, + final int toBits, final boolean pad) throws AddressFormatException { + int acc = 0; + int bits = 0; + ByteArrayOutputStream out = new ByteArrayOutputStream(64); + final int maxv = (1 << toBits) - 1; + final int max_acc = (1 << (fromBits + toBits - 1)) - 1; + for (int i = 0; i < inLen; i++) { + int value = in[i + inStart] & 0xff; + if ((value >>> fromBits) != 0) { + throw new AddressFormatException( + String.format("Input value '%X' exceeds '%d' bit size", value, fromBits)); + } + acc = ((acc << fromBits) | value) & max_acc; + bits += fromBits; + while (bits >= toBits) { + bits -= toBits; + out.write((acc >>> bits) & maxv); + } + } + if (pad) { + if (bits > 0) + out.write((acc << (toBits - bits)) & maxv); + } else if (bits >= fromBits || ((acc << (toBits - bits)) & maxv) != 0) { + throw new AddressFormatException("Could not convert bits, invalid padding"); + } + return out.toByteArray(); + } + } + + private static class Bech32 { + private static final byte[] CHARSET_REV = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, 10, 17, 21, 20, 26, 30, 7, 5, -1, -1, -1, -1, -1, -1, + -1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, 22, 31, 27, 19, -1, 1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1, + -1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, 22, 31, 27, 19, -1, 1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1 + }; + + static class Bech32Data { + final String hrp; + final byte[] data; + + private Bech32Data(final String hrp, final byte[] data) { + this.hrp = hrp; + this.data = data; + } + } + + private static int polymod(final byte[] values) { + int c = 1; + for (byte v_i : values) { + int c0 = (c >>> 25) & 0xff; + c = ((c & 0x1ffffff) << 5) ^ (v_i & 0xff); + if ((c0 & 1) != 0) c ^= 0x3b6a57b2; + if ((c0 & 2) != 0) c ^= 0x26508e6d; + if ((c0 & 4) != 0) c ^= 0x1ea119fa; + if ((c0 & 8) != 0) c ^= 0x3d4233dd; + if ((c0 & 16) != 0) c ^= 0x2a1462b3; + } + return c; + } + + private static byte[] expandHrp(final String hrp) { + int len = hrp.length(); + byte ret[] = new byte[len * 2 + 1]; + for (int i = 0; i < len; ++i) { + int c = hrp.charAt(i) & 0x7f; + ret[i] = (byte) ((c >>> 5) & 0x07); + ret[i + len + 1] = (byte) (c & 0x1f); + } + ret[len] = 0; + return ret; + } + + private static boolean verifyChecksum(final String hrp, final byte[] values) { + byte[] exp = expandHrp(hrp); + byte[] combined = new byte[exp.length + values.length]; + System.arraycopy(exp, 0, combined, 0, exp.length); + System.arraycopy(values, 0, combined, exp.length, values.length); + return polymod(combined) == 1; + } + + public static Bech32Data decode(final String str) throws AddressFormatException { + boolean lower = false, upper = false; + int len = str.length(); + if (len < 8) + throw new AddressFormatException("Input too short: " + len); + if (len > 90) + throw new AddressFormatException("Input too long: " + len); + for (int i = 0; i < len; ++i) { + char c = str.charAt(i); + if (c < 33 || c > 126) throw new AddressFormatException(invalidChar(c, i)); + if (c >= 'a' && c <= 'z') { + if (upper) + throw new AddressFormatException(invalidChar(c, i)); + lower = true; + } + if (c >= 'A' && c <= 'Z') { + if (lower) + throw new AddressFormatException(invalidChar(c, i)); + upper = true; + } + } + final int pos = str.lastIndexOf('1'); + if (pos < 1) throw new AddressFormatException("Invalid Prefix: Missing human-readable part"); + final int dataLen = len - 1 - pos; + if (dataLen < 6) throw new AddressFormatException("Data part too short: " + dataLen); + byte[] values = new byte[dataLen]; + for (int i = 0; i < dataLen; ++i) { + char c = str.charAt(i + pos + 1); + if (CHARSET_REV[c] == -1) throw new AddressFormatException(invalidChar(c, i + pos + 1)); + values[i] = CHARSET_REV[c]; + } + String hrp = str.substring(0, pos).toLowerCase(Locale.ROOT); + if (!verifyChecksum(hrp, values)) throw new AddressFormatException("Invalid Checksum"); + return new Bech32Data(hrp, Arrays.copyOfRange(values, 0, values.length - 6)); + } + + private static String invalidChar(char c, int i) { + return "Invalid character '" + Character.toString(c) + "' at position " + i; + } + + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index daac5933..d2f297fd 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -137,9 +137,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("UNO", "Unobtanium")); result.add(new CryptoCurrency("XZC", "Zcoin")); - // Added 0.6.6 - result.add(new CryptoCurrency("WMCC", "WorldMobileCoin")); - // Added 0.7.0 result.add(new CryptoCurrency("RTO", "Arto")); result.add(new CryptoCurrency("KOTO", "Koto")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 8a506357..fef00ce0 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -21,9 +21,7 @@ import bisq.core.btc.BaseCurrencyNetwork; import bisq.core.locale.Res; import bisq.core.payment.validation.altcoins.KOTOAddressValidator; -import bisq.core.payment.validation.altcoins.WMCCAddressValidator; import bisq.core.payment.validation.params.PhoreParams; -import bisq.core.payment.validation.params.WMCCParams; import bisq.core.util.validation.InputValidator; import bisq.asset.AddressValidationResult; @@ -87,8 +85,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "WMCC": - return WMCCAddressValidator.ValidateAddress(WMCCParams.get(), input); case "RTO": if (!input.matches("^[A][0-9A-Za-z]{94}$")) return regexTestFailed; diff --git a/src/main/java/bisq/core/payment/validation/altcoins/WMCCAddressValidator.java b/src/main/java/bisq/core/payment/validation/altcoins/WMCCAddressValidator.java deleted file mode 100644 index eadf653b..00000000 --- a/src/main/java/bisq/core/payment/validation/altcoins/WMCCAddressValidator.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with bisq. If not, see . - */ - -package bisq.core.payment.validation.altcoins; - -import bisq.core.util.validation.InputValidator.ValidationResult; - -import org.bitcoinj.core.Address; -import org.bitcoinj.core.AddressFormatException; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.VersionedChecksummedBytes; -import org.bitcoinj.params.Networks; - -import java.io.ByteArrayOutputStream; - -import java.util.Arrays; -import java.util.Locale; - -import javax.annotation.Nullable; - -public class WMCCAddressValidator { - public static ValidationResult ValidateAddress(NetworkParameters params, String address) { - if (!isLowerCase(address)) { - try { - Address.fromBase58(params, address); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, "Invalid Base58 Addr: " + e.getMessage()); - } - } - - try { - WitnessAddress.fromBech32(params, address); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, "Invalid Bech32 Addr: " + e.getMessage()); - } - } - - private static boolean isLowerCase(String str) { - char ch; - for (int i = 0; i < str.length(); i++) { - ch = str.charAt(i); - if (Character.isDigit(ch)) - continue; - if (!Character.isLowerCase(ch)) - return false; - } - return true; - } -} - -/* Add to support bech32 address*/ -class WitnessAddress extends VersionedChecksummedBytes { - public static final int PROGRAM_LENGTH_PKH = 20; - public static final int PROGRAM_LENGTH_SH = 32; - public static final int PROGRAM_MIN_LENGTH = 2; - public static final int PROGRAM_MAX_LENGTH = 40; - public static final String WITNESS_ADDRESS_HRP = "wc"; - - private WitnessAddress(NetworkParameters params, byte[] data) throws AddressFormatException { - super(params.getAddressHeader(), data); - if (data.length < 1) - throw new AddressFormatException("Zero data found"); - final int version = getWitnessVersion(); - if (version < 0 || version > 16) - throw new AddressFormatException("Invalid script version: " + version); - byte[] program = getWitnessProgram(); - if (program.length < PROGRAM_MIN_LENGTH || program.length > PROGRAM_MAX_LENGTH) - throw new AddressFormatException("Invalid length: " + program.length); - if (version == 0 && program.length != PROGRAM_LENGTH_PKH - && program.length != PROGRAM_LENGTH_SH) - throw new AddressFormatException( - "Invalid length for address version 0: " + program.length); - } - - public int getWitnessVersion() { - return bytes[0] & 0xff; - } - - public byte[] getWitnessProgram() { - return convertBits(bytes, 1, bytes.length - 1, 5, 8, false); - } - - public static WitnessAddress fromBech32(@Nullable NetworkParameters params, String bech32) - throws AddressFormatException { - Bech32.Bech32Data bechData = Bech32.decode(bech32); - if (params == null) { - for (NetworkParameters p : Networks.get()) { - if (bechData.hrp.equals(WITNESS_ADDRESS_HRP)) - return new WitnessAddress(p, bechData.data); - } - throw new AddressFormatException("Invalid Prefix: No network found for " + bech32); - } else { - if (bechData.hrp.equals(WITNESS_ADDRESS_HRP)) - return new WitnessAddress(params, bechData.data); - throw new AddressFormatException("Wrong Network: " + bechData.hrp); - } - } - - /** - * Helper - */ - private static byte[] convertBits(final byte[] in, final int inStart, final int inLen, final int fromBits, - final int toBits, final boolean pad) throws AddressFormatException { - int acc = 0; - int bits = 0; - ByteArrayOutputStream out = new ByteArrayOutputStream(64); - final int maxv = (1 << toBits) - 1; - final int max_acc = (1 << (fromBits + toBits - 1)) - 1; - for (int i = 0; i < inLen; i++) { - int value = in[i + inStart] & 0xff; - if ((value >>> fromBits) != 0) { - throw new AddressFormatException( - String.format("Input value '%X' exceeds '%d' bit size", value, fromBits)); - } - acc = ((acc << fromBits) | value) & max_acc; - bits += fromBits; - while (bits >= toBits) { - bits -= toBits; - out.write((acc >>> bits) & maxv); - } - } - if (pad) { - if (bits > 0) - out.write((acc << (toBits - bits)) & maxv); - } else if (bits >= fromBits || ((acc << (toBits - bits)) & maxv) != 0) { - throw new AddressFormatException("Could not convert bits, invalid padding"); - } - return out.toByteArray(); - } -} - -/* Bech32 decoder */ -class Bech32 { - private static final byte[] CHARSET_REV = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, 10, 17, 21, 20, 26, 30, 7, 5, -1, -1, -1, -1, -1, -1, - -1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, 22, 31, 27, 19, -1, 1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1, - -1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, 22, 31, 27, 19, -1, 1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1 - }; - - public static class Bech32Data { - final String hrp; - final byte[] data; - - private Bech32Data(final String hrp, final byte[] data) { - this.hrp = hrp; - this.data = data; - } - } - - private static int polymod(final byte[] values) { - int c = 1; - for (byte v_i : values) { - int c0 = (c >>> 25) & 0xff; - c = ((c & 0x1ffffff) << 5) ^ (v_i & 0xff); - if ((c0 & 1) != 0) c ^= 0x3b6a57b2; - if ((c0 & 2) != 0) c ^= 0x26508e6d; - if ((c0 & 4) != 0) c ^= 0x1ea119fa; - if ((c0 & 8) != 0) c ^= 0x3d4233dd; - if ((c0 & 16) != 0) c ^= 0x2a1462b3; - } - return c; - } - - private static byte[] expandHrp(final String hrp) { - int len = hrp.length(); - byte ret[] = new byte[len * 2 + 1]; - for (int i = 0; i < len; ++i) { - int c = hrp.charAt(i) & 0x7f; - ret[i] = (byte) ((c >>> 5) & 0x07); - ret[i + len + 1] = (byte) (c & 0x1f); - } - ret[len] = 0; - return ret; - } - - private static boolean verifyChecksum(final String hrp, final byte[] values) { - byte[] exp = expandHrp(hrp); - byte[] combined = new byte[exp.length + values.length]; - System.arraycopy(exp, 0, combined, 0, exp.length); - System.arraycopy(values, 0, combined, exp.length, values.length); - return polymod(combined) == 1; - } - - public static Bech32Data decode(final String str) throws AddressFormatException { - boolean lower = false, upper = false; - int len = str.length(); - if (len < 8) - throw new AddressFormatException("Input too short: " + len); - if (len > 90) - throw new AddressFormatException("Input too long: " + len); - for (int i = 0; i < len; ++i) { - char c = str.charAt(i); - if (c < 33 || c > 126) throw new AddressFormatException(invalidChar(c, i)); - if (c >= 'a' && c <= 'z') { - if (upper) - throw new AddressFormatException(invalidChar(c, i)); - lower = true; - } - if (c >= 'A' && c <= 'Z') { - if (lower) - throw new AddressFormatException(invalidChar(c, i)); - upper = true; - } - } - final int pos = str.lastIndexOf('1'); - if (pos < 1) throw new AddressFormatException("Invalid Prefix: Missing human-readable part"); - final int dataLen = len - 1 - pos; - if (dataLen < 6) throw new AddressFormatException("Data part too short: " + dataLen); - byte[] values = new byte[dataLen]; - for (int i = 0; i < dataLen; ++i) { - char c = str.charAt(i + pos + 1); - if (CHARSET_REV[c] == -1) throw new AddressFormatException(invalidChar(c, i + pos + 1)); - values[i] = CHARSET_REV[c]; - } - String hrp = str.substring(0, pos).toLowerCase(Locale.ROOT); - if (!verifyChecksum(hrp, values)) throw new AddressFormatException("Invalid Checksum"); - return new Bech32Data(hrp, Arrays.copyOfRange(values, 0, values.length - 6)); - } - - private static String invalidChar(char c, int i) { - return "Invalid character '" + Character.toString(c) + "' at position " + i; - } - - ; -} diff --git a/src/main/java/bisq/core/payment/validation/params/WMCCParams.java b/src/main/java/bisq/core/payment/validation/params/WMCCParams.java deleted file mode 100644 index 0f28ae12..00000000 --- a/src/main/java/bisq/core/payment/validation/params/WMCCParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class WMCCParams extends NetworkParameters { - - private static WMCCParams instance; - - public static synchronized WMCCParams get() { - if (instance == null) { - instance = new WMCCParams(); - } - return instance; - } - - // We only use the properties needed for address validation - public WMCCParams() { - super(); - addressHeader = 0x49; - p2shHeader = 0x4b; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - // default dummy implementations, not used... - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 8ed1bb0d..2210d230 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -45,6 +45,7 @@ bisq.asset.coins.Strayacoin bisq.asset.coins.Terracoin bisq.asset.coins.VDinar bisq.asset.coins.Wacoin +bisq.asset.coins.WorldMobileCoin bisq.asset.coins.Yenten bisq.asset.coins.Zcash bisq.asset.coins.ZenCash diff --git a/src/test/java/bisq/asset/coins/WorldMobileCoinTest.java b/src/test/java/bisq/asset/coins/WorldMobileCoinTest.java new file mode 100644 index 00000000..7bb059d5 --- /dev/null +++ b/src/test/java/bisq/asset/coins/WorldMobileCoinTest.java @@ -0,0 +1,47 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class WorldMobileCoinTest extends AbstractAssetTest { + + public WorldMobileCoinTest() { + super(new WorldMobileCoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("wc1qke2es507uz0dcfx7eyvlfuemwys8xem48vp5rw"); + assertValidAddress("wc1qlwsfmqswjnnv20quv203lnksjrgsww3mjhd349"); + assertValidAddress("Wmpfed6ykt9YsFxhGri5KJvKc3r7BC1rVQ"); + assertValidAddress("WSSqzNJvc4X4xWW6WDyUk1oWEeLx45vyRh"); + assertValidAddress("XWJk3GEuNFEn3dGFCi7vTzVuydeGQA9Fnq"); + assertValidAddress("XG1Mc7XvvpR1wQvjeikZwHAjwLvCWQD35u"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("wc1qke2es507uz0dcfx7eyvlfuemwys8xem48vp5rx"); + assertInvalidAddress("Wmpfed6ykt9YsFxhGri5KJvKc3r7BC1rvq"); + assertInvalidAddress("XWJk3GEuNFEn3dGFCi7vTzVuydeGQA9FNQ"); + assertInvalidAddress("0123456789Abcdefghijklmnopqrstuvwxyz"); + } +} From 80375e0c0efcb4ea5871f79961b428ff65485a37 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 09:35:40 +0200 Subject: [PATCH 056/106] Extract Arto --- src/main/java/bisq/asset/coins/Arto.java | 29 +++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 --- .../META-INF/services/bisq.asset.Asset | 1 + src/test/java/bisq/asset/coins/ArtoTest.java | 42 +++++++++++++++++++ 5 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Arto.java create mode 100644 src/test/java/bisq/asset/coins/ArtoTest.java diff --git a/src/main/java/bisq/asset/coins/Arto.java b/src/main/java/bisq/asset/coins/Arto.java new file mode 100644 index 00000000..98ce1416 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Arto.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.RegexAddressValidator; + +public class Arto extends Coin { + + public Arto() { + super("Arto", "RTO", new RegexAddressValidator("^[A][0-9A-Za-z]{94}$")); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index d2f297fd..b4b35e82 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.7.0 - result.add(new CryptoCurrency("RTO", "Arto")); result.add(new CryptoCurrency("KOTO", "Koto")); result.add(new CryptoCurrency("UBQ", "Ubiq")); result.add(new CryptoCurrency("QWARK", "Qwark", true)); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index fef00ce0..52f0e831 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -85,11 +85,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "RTO": - if (!input.matches("^[A][0-9A-Za-z]{94}$")) - return regexTestFailed; - else - return new ValidationResult(true); case "KOTO": return KOTOAddressValidator.ValidateAddress(input); case "UBQ": diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 2210d230..c704f917 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -1,5 +1,6 @@ bisq.asset.coins.Achievecoin bisq.asset.coins.Angelcoin +bisq.asset.coins.Arto bisq.asset.coins.BSQ$Mainnet bisq.asset.coins.BSQ$Regtest bisq.asset.coins.BSQ$Testnet diff --git a/src/test/java/bisq/asset/coins/ArtoTest.java b/src/test/java/bisq/asset/coins/ArtoTest.java new file mode 100644 index 00000000..bbd74cbb --- /dev/null +++ b/src/test/java/bisq/asset/coins/ArtoTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class ArtoTest extends AbstractAssetTest { + + public ArtoTest() { + super(new Arto()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("AHT1tiauD1GKvLnSL2RVuug1arn3cvFYw7PX5cUmCkM9MHuBn8yrGoHGHXP8ZV9FUR5Y5ntvhanwCMp8FK5bmLrqKxq7BRj"); + assertValidAddress("AKQqctWaaX3gdtQ54kUZAFhGimquK83i2VEKPituFyZiJnwB5RqRrvtSK24yN8AizhhDvHX8CvkJkRrZtUAYScgRJsDE1jH"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("AHT1tiauD1GKvLnSL2RVuug1arn3cvFYw7PX5cUmCkM9MHuBn8yrGoHGHXP8ZV9FUR5Y5ntvhanwCMp8FK5bmLrqKxq7BR"); + assertInvalidAddress("BKQqctWaaX3gdtQ54kUZAFhGimquK83i2VEKPituFyZiJnwB5RqRrvtSK24yN8AizhhDvHX8CvkJkRrZtUAYScgRJsDE1jH"); + assertInvalidAddress("AHT1tiauD1GKvLnSL2RVuug1arn3cvFYw7PX5cUmCkM9MHuBn8yrGoHGHXP8ZV9FUR5Y5ntvhanwCMp8FK5bmLrqKxq7BRjy"); + } +} From 0fc1a38588bc57fe5bd393ae2531b31b634cdd96 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 09:53:29 +0200 Subject: [PATCH 057/106] Extract Koto --- src/main/java/bisq/asset/coins/Koto.java | 91 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 3 - .../altcoins/KOTOAddressValidator.java | 80 ---------------- .../META-INF/services/bisq.asset.Asset | 1 + src/test/java/bisq/asset/coins/KotoTest.java | 45 +++++++++ 6 files changed, 137 insertions(+), 84 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Koto.java delete mode 100644 src/main/java/bisq/core/payment/validation/altcoins/KOTOAddressValidator.java create mode 100644 src/test/java/bisq/asset/coins/KotoTest.java diff --git a/src/main/java/bisq/asset/coins/Koto.java b/src/main/java/bisq/asset/coins/Koto.java new file mode 100644 index 00000000..7a8dd574 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Koto.java @@ -0,0 +1,91 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.AddressValidator; +import bisq.asset.Coin; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import java.util.Arrays; + +public class Koto extends Coin { + + public Koto() { + super("Koto", "KOTO", new KotoAddressValidator()); + } + + + public static class KotoAddressValidator implements AddressValidator { + private final static String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; + + @Override + public AddressValidationResult validate(String address) { + if (address.startsWith("z")) + return AddressValidationResult.invalidAddress("KOTO_Addr_Invalid: z Address not supported!"); + if (address.length() != 35) + return AddressValidationResult.invalidAddress("KOTO_Addr_Invalid: Length must be 35!"); + if (!address.startsWith("k1") && !address.startsWith("jz")) + return AddressValidationResult.invalidAddress("KOTO_Addr_Invalid: must start with 'k1' or 'jz'!"); + byte[] decoded = decodeBase58(address, 58, 26); + if (decoded == null) + return AddressValidationResult.invalidAddress("KOTO_Addr_Invalid: Base58 decoder error!"); + + byte[] hash = getSha256(decoded, 0, 22, 2); + if (hash == null || !Arrays.equals(Arrays.copyOfRange(hash, 0, 4), Arrays.copyOfRange(decoded, 22, 26))) + return AddressValidationResult.invalidAddress("KOTO_Addr_Invalid: Checksum error!"); + + return AddressValidationResult.validAddress(); + + } + + private static byte[] decodeBase58(String input, int base, int len) { + byte[] output = new byte[len]; + for (int i = 0; i < input.length(); i++) { + char t = input.charAt(i); + + int p = ALPHABET.indexOf(t); + if (p == -1) + return null; + for (int j = len - 1; j >= 0; j--, p /= 256) { + p += base * (output[j] & 0xFF); + output[j] = (byte) (p % 256); + } + if (p != 0) + return null; + } + + return output; + } + + private static byte[] getSha256(byte[] data, int start, int len, int recursion) { + if (recursion == 0) + return data; + + try { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + md.update(Arrays.copyOfRange(data, start, start + len)); + return getSha256(md.digest(), 0, 32, recursion - 1); + } catch (NoSuchAlgorithmException e) { + return null; + } + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index b4b35e82..90235a9f 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.7.0 - result.add(new CryptoCurrency("KOTO", "Koto")); result.add(new CryptoCurrency("UBQ", "Ubiq")); result.add(new CryptoCurrency("QWARK", "Qwark", true)); result.add(new CryptoCurrency("GEO", "GeoCoin", true)); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 52f0e831..1058f572 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -20,7 +20,6 @@ import bisq.core.app.BisqEnvironment; import bisq.core.btc.BaseCurrencyNetwork; import bisq.core.locale.Res; -import bisq.core.payment.validation.altcoins.KOTOAddressValidator; import bisq.core.payment.validation.params.PhoreParams; import bisq.core.util.validation.InputValidator; @@ -85,8 +84,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "KOTO": - return KOTOAddressValidator.ValidateAddress(input); case "UBQ": if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) return regexTestFailed; diff --git a/src/main/java/bisq/core/payment/validation/altcoins/KOTOAddressValidator.java b/src/main/java/bisq/core/payment/validation/altcoins/KOTOAddressValidator.java deleted file mode 100644 index a5ac3b35..00000000 --- a/src/main/java/bisq/core/payment/validation/altcoins/KOTOAddressValidator.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with bisq. If not, see . - */ - -package bisq.core.payment.validation.altcoins; - - -import bisq.core.util.validation.InputValidator.ValidationResult; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import java.util.Arrays; - -public class KOTOAddressValidator { - private final static String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; - - public static ValidationResult ValidateAddress(String addr) { - if (addr.startsWith("z")) - return new ValidationResult(false, "KOTO_Addr_Invalid: z Address not supported!"); - if (addr.length() != 35) - return new ValidationResult(false, "KOTO_Addr_Invalid: Length must be 35!"); - if (!addr.startsWith("k1") && !addr.startsWith("jz")) - return new ValidationResult(false, "KOTO_Addr_Invalid: must start with 'k1' or 'jz'!"); - byte[] decoded = decodeBase58(addr, 58, 26); - if (decoded == null) - return new ValidationResult(false, "KOTO_Addr_Invalid: Base58 decoder error!"); - - byte[] hash = getSha256(decoded, 0, 22, 2); - if (hash == null || !Arrays.equals(Arrays.copyOfRange(hash, 0, 4), Arrays.copyOfRange(decoded, 22, 26))) - return new ValidationResult(false, "KOTO_Addr_Invalid: Checksum error!"); - - return new ValidationResult(true); - } - - private static byte[] decodeBase58(String input, int base, int len) { - byte[] output = new byte[len]; - for (int i = 0; i < input.length(); i++) { - char t = input.charAt(i); - - int p = ALPHABET.indexOf(t); - if (p == -1) - return null; - for (int j = len - 1; j >= 0; j--, p /= 256) { - p += base * (output[j] & 0xFF); - output[j] = (byte) (p % 256); - } - if (p != 0) - return null; - } - - return output; - } - - private static byte[] getSha256(byte[] data, int start, int len, int recursion) { - if (recursion == 0) - return data; - - try { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - md.update(Arrays.copyOfRange(data, start, start + len)); - return getSha256(md.digest(), 0, 32, recursion - 1); - } catch (NoSuchAlgorithmException e) { - return null; - } - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index c704f917..23854ab5 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -28,6 +28,7 @@ bisq.asset.coins.Ether bisq.asset.coins.InfinityEconomics bisq.asset.coins.Instacash bisq.asset.coins.InternetOfPeople +bisq.asset.coins.Koto bisq.asset.coins.Litecoin$Mainnet bisq.asset.coins.Litecoin$Regtest bisq.asset.coins.Litecoin$Testnet diff --git a/src/test/java/bisq/asset/coins/KotoTest.java b/src/test/java/bisq/asset/coins/KotoTest.java new file mode 100644 index 00000000..af6efae4 --- /dev/null +++ b/src/test/java/bisq/asset/coins/KotoTest.java @@ -0,0 +1,45 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class KotoTest extends AbstractAssetTest { + + public KotoTest() { + super(new Koto()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("k13dNgJJjf1SCU2Xv2jLnuUb5Q7zZx7P9vW"); + assertValidAddress("k1BGB7dreqk9yCVEjC5sqjStfRxMUHiVtTg"); + assertValidAddress("jzz6Cgk8wYy7MXZH5TCSxHbe6exCKmhXk8N"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("K1JqGEiRi3pApex3rButyuFN8HVEji9dygo"); + assertInvalidAddress("k2De32yyMZ8xdDFBJXjVseiN99S9eJpvty5"); + assertInvalidAddress("jyzCuxaXN38djCzdkb8nQs7v1joHWtkC4v8"); + assertInvalidAddress("JzyNxmc9iDaGokmMrkmMCncfMQvw5vbHBKv"); + assertInvalidAddress("zkPRkLZKf4BuzBsC6r9Ls5suw1ZV9tCwiBTF5vcz2NZLUDsoXGp5rAFUjKnb7DdkFbLp7aSpejCcC4FTxsVvDxq9YKSprzf"); + } +} From 97584a79a431813278aa531f992bd0fcb2ca9906 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 10:05:20 +0200 Subject: [PATCH 058/106] Extract Ubiq --- src/main/java/bisq/asset/coins/Ubiq.java | 29 +++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 --- .../META-INF/services/bisq.asset.Asset | 1 + src/test/java/bisq/asset/coins/UbiqTest.java | 42 +++++++++++++++++++ 5 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Ubiq.java create mode 100644 src/test/java/bisq/asset/coins/UbiqTest.java diff --git a/src/main/java/bisq/asset/coins/Ubiq.java b/src/main/java/bisq/asset/coins/Ubiq.java new file mode 100644 index 00000000..fb4655af --- /dev/null +++ b/src/main/java/bisq/asset/coins/Ubiq.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.RegexAddressValidator; + +public class Ubiq extends Coin { + + public Ubiq() { + super("Ubiq", "UBQ", new RegexAddressValidator("^(0x)?[0-9a-fA-F]{40}$")); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 90235a9f..8e4b5ce0 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.7.0 - result.add(new CryptoCurrency("UBQ", "Ubiq")); result.add(new CryptoCurrency("QWARK", "Qwark", true)); result.add(new CryptoCurrency("GEO", "GeoCoin", true)); result.add(new CryptoCurrency("GRANS", "10grans", true)); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 1058f572..3f699127 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -84,11 +84,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "UBQ": - if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) - return regexTestFailed; - else - return new ValidationResult(true); case "QWARK": if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) return regexTestFailed; diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 23854ab5..5b18d9df 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -45,6 +45,7 @@ bisq.asset.coins.SpeedCash bisq.asset.coins.Stellite bisq.asset.coins.Strayacoin bisq.asset.coins.Terracoin +bisq.asset.coins.Ubiq bisq.asset.coins.VDinar bisq.asset.coins.Wacoin bisq.asset.coins.WorldMobileCoin diff --git a/src/test/java/bisq/asset/coins/UbiqTest.java b/src/test/java/bisq/asset/coins/UbiqTest.java new file mode 100644 index 00000000..01389132 --- /dev/null +++ b/src/test/java/bisq/asset/coins/UbiqTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class UbiqTest extends AbstractAssetTest { + + public UbiqTest() { + super(new Ubiq()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("0x2a65Aca4D5fC5B5C859090a6c34d164135398226"); + assertValidAddress("2a65Aca4D5fC5B5C859090a6c34d164135398226"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d1641353982266"); + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + assertInvalidAddress("2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + } +} From 686d134678a001badd164361af297fe1ffa6d966 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 10:14:11 +0200 Subject: [PATCH 059/106] Extract Qwark --- src/main/java/bisq/asset/tokens/Qwark.java | 28 +++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 --- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/tokens/QwarkTest.java | 42 +++++++++++++++++++ 5 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/tokens/Qwark.java create mode 100644 src/test/java/bisq/asset/tokens/QwarkTest.java diff --git a/src/main/java/bisq/asset/tokens/Qwark.java b/src/main/java/bisq/asset/tokens/Qwark.java new file mode 100644 index 00000000..e63f9c6a --- /dev/null +++ b/src/main/java/bisq/asset/tokens/Qwark.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.Erc20Token; + +public class Qwark extends Erc20Token { + + public Qwark() { + super("Qwark", "QWARK"); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 8e4b5ce0..aa722f30 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.7.0 - result.add(new CryptoCurrency("QWARK", "Qwark", true)); result.add(new CryptoCurrency("GEO", "GeoCoin", true)); result.add(new CryptoCurrency("GRANS", "10grans", true)); result.add(new CryptoCurrency("PHR", "Phore")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 3f699127..10ee1614 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -84,11 +84,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "QWARK": - if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) - return regexTestFailed; - else - return new ValidationResult(true); case "GEO": if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) return regexTestFailed; diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 5b18d9df..2546418a 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -57,6 +57,7 @@ bisq.asset.tokens.DaiStablecoin bisq.asset.tokens.Ellaism bisq.asset.tokens.Internext bisq.asset.tokens.Movement +bisq.asset.tokens.Qwark bisq.asset.tokens.RefToken bisq.asset.tokens.SosCoin bisq.asset.tokens.Verify diff --git a/src/test/java/bisq/asset/tokens/QwarkTest.java b/src/test/java/bisq/asset/tokens/QwarkTest.java new file mode 100644 index 00000000..fbf81e64 --- /dev/null +++ b/src/test/java/bisq/asset/tokens/QwarkTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class QwarkTest extends AbstractAssetTest { + + public QwarkTest() { + super(new Qwark()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("0x2a65Aca4D5fC5B5C859090a6c34d164135398226"); + assertValidAddress("2a65Aca4D5fC5B5C859090a6c34d164135398226"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d1641353982266"); + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + assertInvalidAddress("2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + } +} From 3c1032a019c4257ef6e161d2cc086ad141c4bc44 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 10:21:39 +0200 Subject: [PATCH 060/106] Extract GeoCoin --- src/main/java/bisq/asset/tokens/GeoCoin.java | 10 +++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 --- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/tokens/GeoCoinTest.java | 42 +++++++++++++++++++ 5 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/tokens/GeoCoin.java create mode 100644 src/test/java/bisq/asset/tokens/GeoCoinTest.java diff --git a/src/main/java/bisq/asset/tokens/GeoCoin.java b/src/main/java/bisq/asset/tokens/GeoCoin.java new file mode 100644 index 00000000..9bb19e2e --- /dev/null +++ b/src/main/java/bisq/asset/tokens/GeoCoin.java @@ -0,0 +1,10 @@ +package bisq.asset.tokens; + +import bisq.asset.Erc20Token; + +public class GeoCoin extends Erc20Token { + + public GeoCoin() { + super("GeoCoin", "GEO"); + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index aa722f30..ce149772 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.7.0 - result.add(new CryptoCurrency("GEO", "GeoCoin", true)); result.add(new CryptoCurrency("GRANS", "10grans", true)); result.add(new CryptoCurrency("PHR", "Phore")); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 10ee1614..257d5d80 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -84,11 +84,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "GEO": - if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) - return regexTestFailed; - else - return new ValidationResult(true); case "GRANS": if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) return regexTestFailed; diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 2546418a..36c10368 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -55,6 +55,7 @@ bisq.asset.coins.ZenCash bisq.asset.tokens.BetterBetting bisq.asset.tokens.DaiStablecoin bisq.asset.tokens.Ellaism +bisq.asset.tokens.GeoCoin bisq.asset.tokens.Internext bisq.asset.tokens.Movement bisq.asset.tokens.Qwark diff --git a/src/test/java/bisq/asset/tokens/GeoCoinTest.java b/src/test/java/bisq/asset/tokens/GeoCoinTest.java new file mode 100644 index 00000000..61254211 --- /dev/null +++ b/src/test/java/bisq/asset/tokens/GeoCoinTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class GeoCoinTest extends AbstractAssetTest { + + public GeoCoinTest() { + super(new GeoCoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("0x2a65Aca4D5fC5B5C859090a6c34d164135398226"); + assertValidAddress("2a65Aca4D5fC5B5C859090a6c34d164135398226"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d1641353982266"); + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + assertInvalidAddress("2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + } +} From d2ee3ec67fc3b3c680586b5ee0ec6fd200aba60a Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 10:31:29 +0200 Subject: [PATCH 061/106] Extract 10grans --- src/main/java/bisq/asset/tokens/Grans.java | 10 +++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../validation/AltCoinAddressValidator.java | 5 --- .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/tokens/GransTest.java | 42 +++++++++++++++++++ 5 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 src/main/java/bisq/asset/tokens/Grans.java create mode 100644 src/test/java/bisq/asset/tokens/GransTest.java diff --git a/src/main/java/bisq/asset/tokens/Grans.java b/src/main/java/bisq/asset/tokens/Grans.java new file mode 100644 index 00000000..48dab550 --- /dev/null +++ b/src/main/java/bisq/asset/tokens/Grans.java @@ -0,0 +1,10 @@ +package bisq.asset.tokens; + +import bisq.asset.Erc20Token; + +public class Grans extends Erc20Token { + + public Grans() { + super("10grans", "GRANS"); + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index ce149772..f07a6686 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -138,7 +138,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("XZC", "Zcoin")); // Added 0.7.0 - result.add(new CryptoCurrency("GRANS", "10grans", true)); result.add(new CryptoCurrency("PHR", "Phore")); result.sort(TradeCurrency::compareTo); diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 257d5d80..c38e6f32 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -84,11 +84,6 @@ public ValidationResult validate(String input) { } switch (currencyCode) { - case "GRANS": - if (!input.matches("^(0x)?[0-9a-fA-F]{40}$")) - return regexTestFailed; - else - return new ValidationResult(true); case "PHR": if (input.matches("^[P][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { //noinspection ConstantConditions diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 36c10368..8badfb42 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -56,6 +56,7 @@ bisq.asset.tokens.BetterBetting bisq.asset.tokens.DaiStablecoin bisq.asset.tokens.Ellaism bisq.asset.tokens.GeoCoin +bisq.asset.tokens.Grans bisq.asset.tokens.Internext bisq.asset.tokens.Movement bisq.asset.tokens.Qwark diff --git a/src/test/java/bisq/asset/tokens/GransTest.java b/src/test/java/bisq/asset/tokens/GransTest.java new file mode 100644 index 00000000..28943e86 --- /dev/null +++ b/src/test/java/bisq/asset/tokens/GransTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class GransTest extends AbstractAssetTest { + + public GransTest() { + super(new Grans()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("0x2a65Aca4D5fC5B5C859090a6c34d164135398226"); + assertValidAddress("2a65Aca4D5fC5B5C859090a6c34d164135398226"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d1641353982266"); + assertInvalidAddress("0x2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + assertInvalidAddress("2a65Aca4D5fC5B5C859090a6c34d16413539822g"); + } +} From 03ed04e35d88a3d4aa7829c5e5258fd4e8ab4368 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 10:39:46 +0200 Subject: [PATCH 062/106] Extract Phore --- src/main/java/bisq/asset/coins/Phore.java | 55 +++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 3 - .../validation/AltCoinAddressValidator.java | 23 +---- .../validation/params/PhoreParams.java | 93 ------------------- .../META-INF/services/bisq.asset.Asset | 1 + src/test/java/bisq/asset/coins/PhoreTest.java | 47 ++++++++++ 6 files changed, 105 insertions(+), 117 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Phore.java delete mode 100644 src/main/java/bisq/core/payment/validation/params/PhoreParams.java create mode 100644 src/test/java/bisq/asset/coins/PhoreTest.java diff --git a/src/main/java/bisq/asset/coins/Phore.java b/src/main/java/bisq/asset/coins/Phore.java new file mode 100644 index 00000000..0b02e822 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Phore.java @@ -0,0 +1,55 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AddressValidationResult; +import bisq.asset.Base58BitcoinAddressValidator; +import bisq.asset.Coin; +import bisq.asset.NetworkParametersAdapter; + +public class Phore extends Coin { + + public Phore() { + super("Phore", "PHR", new PhoreAddressValidator()); + } + + + public static class PhoreAddressValidator extends Base58BitcoinAddressValidator { + + public PhoreAddressValidator() { + super(new PhoreParams()); + } + + @Override + public AddressValidationResult validate(String address) { + if (!address.matches("^[P][a-km-zA-HJ-NP-Z1-9]{25,34}$")) + return AddressValidationResult.invalidStructure(); + + return super.validate(address); + } + } + + public static class PhoreParams extends NetworkParametersAdapter { + + public PhoreParams() { + addressHeader = 55; + p2shHeader = 13; + acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; + } + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index f07a6686..4c92d327 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -137,9 +137,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("UNO", "Unobtanium")); result.add(new CryptoCurrency("XZC", "Zcoin")); - // Added 0.7.0 - result.add(new CryptoCurrency("PHR", "Phore")); - result.sort(TradeCurrency::compareTo); // Util for printing all altcoins for adding to FAQ page diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index c38e6f32..0fd2f892 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -20,7 +20,6 @@ import bisq.core.app.BisqEnvironment; import bisq.core.btc.BaseCurrencyNetwork; import bisq.core.locale.Res; -import bisq.core.payment.validation.params.PhoreParams; import bisq.core.util.validation.InputValidator; import bisq.asset.AddressValidationResult; @@ -28,7 +27,6 @@ import bisq.asset.AssetRegistry; import bisq.asset.Coin; -import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; import com.google.inject.Inject; @@ -83,25 +81,8 @@ public ValidationResult validate(String input) { return new ValidationResult(false, Res.get(addressValidationResult.getI18nKey(), asset.get().getTickerSymbol(), addressValidationResult.getMessage())); } - switch (currencyCode) { - case "PHR": - if (input.matches("^[P][a-km-zA-HJ-NP-Z1-9]{25,34}$")) { - //noinspection ConstantConditions - try { - Address.fromBase58(PhoreParams.get(), input); - return new ValidationResult(true); - } catch (AddressFormatException e) { - return new ValidationResult(false, getErrorMessage(e)); - } - } else { - return regexTestFailed; - } - - // Add new coins at the end... - default: - log.debug("Validation for AltCoinAddress not implemented yet. currencyCode: " + currencyCode); - return validationResult; - } + log.debug("Validation for AltCoinAddress not implemented yet. currencyCode: " + currencyCode); + return validationResult; } } diff --git a/src/main/java/bisq/core/payment/validation/params/PhoreParams.java b/src/main/java/bisq/core/payment/validation/params/PhoreParams.java deleted file mode 100644 index 87cfbbb6..00000000 --- a/src/main/java/bisq/core/payment/validation/params/PhoreParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.core.payment.validation.params; - -import org.bitcoinj.core.BitcoinSerializer; -import org.bitcoinj.core.Block; -import org.bitcoinj.core.Coin; -import org.bitcoinj.core.NetworkParameters; -import org.bitcoinj.core.StoredBlock; -import org.bitcoinj.core.VerificationException; -import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; -import org.bitcoinj.utils.MonetaryFormat; - -public class PhoreParams extends NetworkParameters { - - private static PhoreParams instance; - - public static synchronized PhoreParams get() { - if (instance == null) { - instance = new PhoreParams(); - } - return instance; - } - - // We only use the properties needed for address validation - public PhoreParams() { - super(); - addressHeader = 55; - p2shHeader = 13; - acceptableAddressCodes = new int[]{addressHeader, p2shHeader}; - } - - // default dummy implementations, not used... - @Override - public String getPaymentProtocolId() { - return PAYMENT_PROTOCOL_ID_MAINNET; - } - - @Override - public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { - } - - @Override - public Coin getMaxMoney() { - return null; - } - - @Override - public Coin getMinNonDustOutput() { - return null; - } - - @Override - public MonetaryFormat getMonetaryFormat() { - return null; - } - - @Override - public String getUriScheme() { - return null; - } - - @Override - public boolean hasMaxMoney() { - return false; - } - - @Override - public BitcoinSerializer getSerializer(boolean parseRetain) { - return null; - } - - @Override - public int getProtocolVersionNum(ProtocolVersion version) { - return 0; - } -} diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 8badfb42..3544e675 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -37,6 +37,7 @@ bisq.asset.coins.Nxt bisq.asset.coins.Obsidian bisq.asset.coins.Octocoin bisq.asset.coins.Particl +bisq.asset.coins.Phore bisq.asset.coins.Pranacoin bisq.asset.coins.PIVX bisq.asset.coins.Roicoin diff --git a/src/test/java/bisq/asset/coins/PhoreTest.java b/src/test/java/bisq/asset/coins/PhoreTest.java new file mode 100644 index 00000000..2f7ee49c --- /dev/null +++ b/src/test/java/bisq/asset/coins/PhoreTest.java @@ -0,0 +1,47 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class PhoreTest extends AbstractAssetTest { + + public PhoreTest() { + super(new Phore()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("PJCKDPyvfbf1yV7mYNeJ8Zb47hKRwVPYDj"); + assertValidAddress("PJPmiib7JzMDiMQBBFCz92erB8iUvJqBqt"); + assertValidAddress("PS6yeJnJUD2pe9fpDQvtm4KkLDwCWpa8ub"); + assertValidAddress("PKfuRcjwzKFq3dbqE9gq8Ztxn922W4GZhm"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("pGXsgFjSMzh1dSqggRvHjPvE3cnwvuXC7s"); + assertInvalidAddress("PKfRRcjwzKFq3dbqE9gq8Ztxn922W4GZhm"); + assertInvalidAddress("PXP75NnwDryYswQb9RaPFBchqLRSvBmDP"); + assertInvalidAddress("PKr3vQ7SkqLELsYGM6qeRumyfPx3366uyU9"); + assertInvalidAddress("PKr3vQ7S"); + assertInvalidAddress("P0r3vQ7SkqLELsYGM6qeRumyfPx3366uyU9"); + } +} From 81f403d912eceb18ed113054302fbfb565819184 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 10:49:29 +0200 Subject: [PATCH 063/106] Extract Octocoin --- src/main/java/bisq/core/locale/CurrencyUtil.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 4c92d327..9d911ac4 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -123,7 +123,6 @@ private static List createAllSortedCryptoCurrenciesList() { result.add(new CryptoCurrency("NAV", "Nav Coin")); result.add(new CryptoCurrency("NMC", "Namecoin")); result.add(new CryptoCurrency("NBT", "NuBits")); - result.add(new CryptoCurrency("888", "OctoCoin")); result.add(new CryptoCurrency("PASC", "Pascal Coin", true)); result.add(new CryptoCurrency("PEPECASH", "Pepe Cash")); result.add(new CryptoCurrency("POST", "PostCoin")); From f0d0ab54f3b44bc3d2fbbc730e3242f0d29ccdcc Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 11:36:05 +0200 Subject: [PATCH 064/106] Extract Burstcoin --- .../bisq/asset/DefaultAddressValidator.java | 29 +++++++++++++ src/main/java/bisq/asset/coins/Burstcoin.java | 29 +++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/AbstractAssetTest.java | 13 ++++++ ...AbstractAssetWithDefaultValidatorTest.java | 43 +++++++++++++++++++ .../java/bisq/asset/coins/BurstcoinTest.java | 28 ++++++++++++ .../AltCoinAddressValidatorTest.java | 18 ++++++++ 8 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/DefaultAddressValidator.java create mode 100644 src/main/java/bisq/asset/coins/Burstcoin.java create mode 100644 src/test/java/bisq/asset/AbstractAssetWithDefaultValidatorTest.java create mode 100644 src/test/java/bisq/asset/coins/BurstcoinTest.java diff --git a/src/main/java/bisq/asset/DefaultAddressValidator.java b/src/main/java/bisq/asset/DefaultAddressValidator.java new file mode 100644 index 00000000..a762765f --- /dev/null +++ b/src/main/java/bisq/asset/DefaultAddressValidator.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset; + +@Deprecated +public class DefaultAddressValidator implements AddressValidator { + + @Override + public AddressValidationResult validate(String address) { + if (address == null || address.length() == 0) + return AddressValidationResult.invalidAddress("Address may not be empty"); + return AddressValidationResult.validAddress(); + } +} diff --git a/src/main/java/bisq/asset/coins/Burstcoin.java b/src/main/java/bisq/asset/coins/Burstcoin.java new file mode 100644 index 00000000..a6da1999 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Burstcoin.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class Burstcoin extends Coin { + + public Burstcoin() { + super("Burstcoin", "BURST", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 9d911ac4..d44651a9 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("BURST", "Burstcoin")); result.add(new CryptoCurrency("XCP", "Counterparty")); result.add(new CryptoCurrency("DNET", "DarkNet")); result.add(new CryptoCurrency("DCR", "Decred")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 3544e675..00035936 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -11,6 +11,7 @@ bisq.asset.coins.BitcoinCash bisq.asset.coins.BitcoinClashic bisq.asset.coins.BitcoinGold bisq.asset.coins.BitDaric +bisq.asset.coins.Burstcoin bisq.asset.coins.Byteball bisq.asset.coins.Cagecoin bisq.asset.coins.CassubianDetk diff --git a/src/test/java/bisq/asset/AbstractAssetTest.java b/src/test/java/bisq/asset/AbstractAssetTest.java index 94eae9df..8ecff45a 100644 --- a/src/test/java/bisq/asset/AbstractAssetTest.java +++ b/src/test/java/bisq/asset/AbstractAssetTest.java @@ -20,11 +20,14 @@ import bisq.core.btc.BaseCurrencyNetwork; import bisq.core.locale.Res; +import java.util.Optional; + import org.junit.Before; import org.junit.Test; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; public abstract class AbstractAssetTest { @@ -41,6 +44,12 @@ public void setup() { Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName()); } + @Test + public void testPresenceInAssetRegistry() { + final Optional optional = new AssetRegistry().stream().filter(this::hasSameTickerSymbol).findFirst(); + assertTrue(optional.isPresent()); + } + @Test public void testBlank() { assertInvalidAddress(""); @@ -60,4 +69,8 @@ protected void assertValidAddress(String address) { protected void assertInvalidAddress(String address) { assertThat(asset.validateAddress(address).isValid(), is(false)); } + + private boolean hasSameTickerSymbol(Asset asset) { + return this.asset.getTickerSymbol().equals(asset.getTickerSymbol()); + } } diff --git a/src/test/java/bisq/asset/AbstractAssetWithDefaultValidatorTest.java b/src/test/java/bisq/asset/AbstractAssetWithDefaultValidatorTest.java new file mode 100644 index 00000000..486a1636 --- /dev/null +++ b/src/test/java/bisq/asset/AbstractAssetWithDefaultValidatorTest.java @@ -0,0 +1,43 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset; + +import org.junit.Test; + +public abstract class AbstractAssetWithDefaultValidatorTest extends AbstractAssetTest { + + public AbstractAssetWithDefaultValidatorTest(Asset asset) { + super(asset); + } + + @Test + public void testValidAddresses() { + assertValidAddress(" "); + assertValidAddress("1"); + assertValidAddress("AQJTNtWcP7opxuR52Lf5vmoQTC8EHQ6GxV"); + assertValidAddress("ALEK7jttmqtx2ZhXHg69Zr426qKBnzYA9E"); + assertValidAddress("AP1egWUthPoYvZL57aBk4RPqUgjG1fJGn6"); + assertValidAddress("AST3zfvPdZ35npxAVC8ABgVCxxDLwTmAHU"); + } + + @Test + public void testInvalidAddresses() { + testBlank(); + } + +} diff --git a/src/test/java/bisq/asset/coins/BurstcoinTest.java b/src/test/java/bisq/asset/coins/BurstcoinTest.java new file mode 100644 index 00000000..8a1da8ca --- /dev/null +++ b/src/test/java/bisq/asset/coins/BurstcoinTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class BurstcoinTest extends AbstractAssetWithDefaultValidatorTest { + + public BurstcoinTest() { + super(new Burstcoin()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index aebf6e39..ccb759cd 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -40,6 +40,11 @@ public void testBTC() { assertFalse(validator.validate("").isValid); } + @Test + public void testBURST() { + testDefaultValidator("BURST"); + } + @Test @Ignore public void testBSQ() { @@ -850,4 +855,17 @@ public void testPHR() { assertFalse(validator.validate("P0r3vQ7SkqLELsYGM6qeRumyfPx3366uyU9").isValid); assertFalse(validator.validate("").isValid); } + + private void testDefaultValidator(String currencyCode) { + validator.setCurrencyCode(currencyCode); + + assertTrue(validator.validate("AQJTNtWcP7opxuR52Lf5vmoQTC8EHQ6GxV").isValid); + assertTrue(validator.validate("ALEK7jttmqtx2ZhXHg69Zr426qKBnzYA9E").isValid); + assertTrue(validator.validate("AP1egWUthPoYvZL57aBk4RPqUgjG1fJGn6").isValid); + assertTrue(validator.validate("AST3zfvPdZ35npxAVC8ABgVCxxDLwTmAHU").isValid); + assertTrue(validator.validate("1").isValid); + assertTrue(validator.validate(" ").isValid); + + assertFalse(validator.validate("").isValid); + } } From ecd66324c702ebc3f3b1a5879e2053eaf86c7ada Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 11:39:46 +0200 Subject: [PATCH 065/106] Extract Counterparty --- .../java/bisq/asset/coins/Counterparty.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../bisq/asset/coins/CounterpartyTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/Counterparty.java create mode 100644 src/test/java/bisq/asset/coins/CounterpartyTest.java diff --git a/src/main/java/bisq/asset/coins/Counterparty.java b/src/main/java/bisq/asset/coins/Counterparty.java new file mode 100644 index 00000000..104f6162 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Counterparty.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class Counterparty extends Coin { + + public Counterparty() { + super("Counterparty", "XCP", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index d44651a9..9004fd1b 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("XCP", "Counterparty")); result.add(new CryptoCurrency("DNET", "DarkNet")); result.add(new CryptoCurrency("DCR", "Decred")); result.add(new CryptoCurrency("DMC", "DynamicCoin")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 00035936..83ca96b0 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -15,6 +15,7 @@ bisq.asset.coins.Burstcoin bisq.asset.coins.Byteball bisq.asset.coins.Cagecoin bisq.asset.coins.CassubianDetk +bisq.asset.coins.Counterparty bisq.asset.coins.Creativecoin bisq.asset.coins.Cryptonite bisq.asset.coins.Dash$Mainnet diff --git a/src/test/java/bisq/asset/coins/CounterpartyTest.java b/src/test/java/bisq/asset/coins/CounterpartyTest.java new file mode 100644 index 00000000..3e24b4e5 --- /dev/null +++ b/src/test/java/bisq/asset/coins/CounterpartyTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class CounterpartyTest extends AbstractAssetWithDefaultValidatorTest { + + public CounterpartyTest() { + super(new Counterparty()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index ccb759cd..af918d21 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -45,6 +45,11 @@ public void testBURST() { testDefaultValidator("BURST"); } + @Test + public void testXCP() { + testDefaultValidator("XCP"); + } + @Test @Ignore public void testBSQ() { From af23a18979fc5a460cc35e9060eb3f6e41c24d05 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 11:41:25 +0200 Subject: [PATCH 066/106] Extract DarkNet --- src/main/java/bisq/asset/coins/DarkNet.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/DarkNetTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/DarkNet.java create mode 100644 src/test/java/bisq/asset/coins/DarkNetTest.java diff --git a/src/main/java/bisq/asset/coins/DarkNet.java b/src/main/java/bisq/asset/coins/DarkNet.java new file mode 100644 index 00000000..c1a90efe --- /dev/null +++ b/src/main/java/bisq/asset/coins/DarkNet.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class DarkNet extends Coin { + + public DarkNet() { + super("DarkNet", "DNET", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 9004fd1b..8d7f6375 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("DNET", "DarkNet")); result.add(new CryptoCurrency("DCR", "Decred")); result.add(new CryptoCurrency("DMC", "DynamicCoin")); result.add(new CryptoCurrency("ESP", "Espers")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 83ca96b0..beb2d4ed 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -18,6 +18,7 @@ bisq.asset.coins.CassubianDetk bisq.asset.coins.Counterparty bisq.asset.coins.Creativecoin bisq.asset.coins.Cryptonite +bisq.asset.coins.DarkNet bisq.asset.coins.Dash$Mainnet bisq.asset.coins.Dash$Regtest bisq.asset.coins.Dash$Testnet diff --git a/src/test/java/bisq/asset/coins/DarkNetTest.java b/src/test/java/bisq/asset/coins/DarkNetTest.java new file mode 100644 index 00000000..fec613df --- /dev/null +++ b/src/test/java/bisq/asset/coins/DarkNetTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class DarkNetTest extends AbstractAssetWithDefaultValidatorTest { + + public DarkNetTest() { + super(new DarkNet()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index af918d21..d0a49668 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -50,6 +50,11 @@ public void testXCP() { testDefaultValidator("XCP"); } + @Test + public void testDNET() { + testDefaultValidator("DNET"); + } + @Test @Ignore public void testBSQ() { From ee2b77b36084ddc69d76075c6fb65be683485d4d Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 12:00:41 +0200 Subject: [PATCH 067/106] Extract Decred --- src/main/java/bisq/asset/coins/Decred.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/DecredTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/Decred.java create mode 100644 src/test/java/bisq/asset/coins/DecredTest.java diff --git a/src/main/java/bisq/asset/coins/Decred.java b/src/main/java/bisq/asset/coins/Decred.java new file mode 100644 index 00000000..6f0cc8c3 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Decred.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class Decred extends Coin { + + public Decred() { + super("Decred", "DCR", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 8d7f6375..6c242e14 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("DCR", "Decred")); result.add(new CryptoCurrency("DMC", "DynamicCoin")); result.add(new CryptoCurrency("ESP", "Espers")); result.add(new CryptoCurrency("ETC", "Ether Classic")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index beb2d4ed..421066f0 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -23,6 +23,7 @@ bisq.asset.coins.Dash$Mainnet bisq.asset.coins.Dash$Regtest bisq.asset.coins.Dash$Testnet bisq.asset.coins.Decent +bisq.asset.coins.Decred bisq.asset.coins.DeepOnion bisq.asset.coins.DigiMoney bisq.asset.coins.Dinero diff --git a/src/test/java/bisq/asset/coins/DecredTest.java b/src/test/java/bisq/asset/coins/DecredTest.java new file mode 100644 index 00000000..84192d1a --- /dev/null +++ b/src/test/java/bisq/asset/coins/DecredTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class DecredTest extends AbstractAssetWithDefaultValidatorTest { + + public DecredTest() { + super(new Decred()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index d0a49668..8e7a9022 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -55,6 +55,11 @@ public void testDNET() { testDefaultValidator("DNET"); } + @Test + public void testDCR() { + testDefaultValidator("DCR"); + } + @Test @Ignore public void testBSQ() { From 53931a7362bc5e2e0b8d99bb0fed366713868171 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 12:02:39 +0200 Subject: [PATCH 068/106] Extract DynamicCoin --- .../java/bisq/asset/coins/DynamicCoin.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../bisq/asset/coins/DynamicCoinTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/DynamicCoin.java create mode 100644 src/test/java/bisq/asset/coins/DynamicCoinTest.java diff --git a/src/main/java/bisq/asset/coins/DynamicCoin.java b/src/main/java/bisq/asset/coins/DynamicCoin.java new file mode 100644 index 00000000..9e346b89 --- /dev/null +++ b/src/main/java/bisq/asset/coins/DynamicCoin.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class DynamicCoin extends Coin { + + public DynamicCoin() { + super("DynamicCoin", "DMC", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 6c242e14..011df0c9 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("DMC", "DynamicCoin")); result.add(new CryptoCurrency("ESP", "Espers")); result.add(new CryptoCurrency("ETC", "Ether Classic")); result.add(new CryptoCurrency("GRC", "Gridcoin")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 421066f0..b890798d 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -28,6 +28,7 @@ bisq.asset.coins.DeepOnion bisq.asset.coins.DigiMoney bisq.asset.coins.Dinero bisq.asset.coins.Dogecoin +bisq.asset.coins.DynamicCoin bisq.asset.coins.Ether bisq.asset.coins.InfinityEconomics bisq.asset.coins.Instacash diff --git a/src/test/java/bisq/asset/coins/DynamicCoinTest.java b/src/test/java/bisq/asset/coins/DynamicCoinTest.java new file mode 100644 index 00000000..7a967d45 --- /dev/null +++ b/src/test/java/bisq/asset/coins/DynamicCoinTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class DynamicCoinTest extends AbstractAssetWithDefaultValidatorTest { + + public DynamicCoinTest() { + super(new DynamicCoin()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 8e7a9022..9dab4d9e 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -60,6 +60,11 @@ public void testDCR() { testDefaultValidator("DCR"); } + @Test + public void testDMC() { + testDefaultValidator("DMC"); + } + @Test @Ignore public void testBSQ() { From 1433c45f1e57966761ce5ad934c5a986d815efcb Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 12:04:30 +0200 Subject: [PATCH 069/106] Extract Espers --- src/main/java/bisq/asset/coins/Espers.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/EspersTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/Espers.java create mode 100644 src/test/java/bisq/asset/coins/EspersTest.java diff --git a/src/main/java/bisq/asset/coins/Espers.java b/src/main/java/bisq/asset/coins/Espers.java new file mode 100644 index 00000000..ee062b1e --- /dev/null +++ b/src/main/java/bisq/asset/coins/Espers.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class Espers extends Coin { + + public Espers() { + super("Espers", "ESP", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 011df0c9..78084220 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("ESP", "Espers")); result.add(new CryptoCurrency("ETC", "Ether Classic")); result.add(new CryptoCurrency("GRC", "Gridcoin")); result.add(new CryptoCurrency("LBC", "LBRY Credits")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index b890798d..a5e5fe9d 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -29,6 +29,7 @@ bisq.asset.coins.DigiMoney bisq.asset.coins.Dinero bisq.asset.coins.Dogecoin bisq.asset.coins.DynamicCoin +bisq.asset.coins.Espers bisq.asset.coins.Ether bisq.asset.coins.InfinityEconomics bisq.asset.coins.Instacash diff --git a/src/test/java/bisq/asset/coins/EspersTest.java b/src/test/java/bisq/asset/coins/EspersTest.java new file mode 100644 index 00000000..63b8c434 --- /dev/null +++ b/src/test/java/bisq/asset/coins/EspersTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class EspersTest extends AbstractAssetWithDefaultValidatorTest { + + public EspersTest() { + super(new Espers()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 9dab4d9e..59f4feed 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -65,6 +65,11 @@ public void testDMC() { testDefaultValidator("DMC"); } + @Test + public void testESP() { + testDefaultValidator("ESP"); + } + @Test @Ignore public void testBSQ() { From b100c100f82fd83750c957029d7e7bc983487aa2 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 12:07:56 +0200 Subject: [PATCH 070/106] Extract EtherClassic --- .../java/bisq/asset/coins/EtherClassic.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../bisq/asset/coins/EtherClassicTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/EtherClassic.java create mode 100644 src/test/java/bisq/asset/coins/EtherClassicTest.java diff --git a/src/main/java/bisq/asset/coins/EtherClassic.java b/src/main/java/bisq/asset/coins/EtherClassic.java new file mode 100644 index 00000000..4d673eba --- /dev/null +++ b/src/main/java/bisq/asset/coins/EtherClassic.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class EtherClassic extends Coin { + + public EtherClassic() { + super("Ether Classic", "ETC", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 78084220..ee650984 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("ETC", "Ether Classic")); result.add(new CryptoCurrency("GRC", "Gridcoin")); result.add(new CryptoCurrency("LBC", "LBRY Credits")); result.add(new CryptoCurrency("LSK", "Lisk")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index a5e5fe9d..1e3510da 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -31,6 +31,7 @@ bisq.asset.coins.Dogecoin bisq.asset.coins.DynamicCoin bisq.asset.coins.Espers bisq.asset.coins.Ether +bisq.asset.coins.EtherClassic bisq.asset.coins.InfinityEconomics bisq.asset.coins.Instacash bisq.asset.coins.InternetOfPeople diff --git a/src/test/java/bisq/asset/coins/EtherClassicTest.java b/src/test/java/bisq/asset/coins/EtherClassicTest.java new file mode 100644 index 00000000..237b44c8 --- /dev/null +++ b/src/test/java/bisq/asset/coins/EtherClassicTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class EtherClassicTest extends AbstractAssetWithDefaultValidatorTest { + + public EtherClassicTest() { + super(new EtherClassic()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 59f4feed..7314690f 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -70,6 +70,11 @@ public void testESP() { testDefaultValidator("ESP"); } + @Test + public void testETC() { + testDefaultValidator("ETC"); + } + @Test @Ignore public void testBSQ() { From a7e2fdcc910345484a643abedfcbcb6e22db016e Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 12:09:45 +0200 Subject: [PATCH 071/106] Extract Gridcoin --- src/main/java/bisq/asset/coins/Gridcoin.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/GridcoinTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/Gridcoin.java create mode 100644 src/test/java/bisq/asset/coins/GridcoinTest.java diff --git a/src/main/java/bisq/asset/coins/Gridcoin.java b/src/main/java/bisq/asset/coins/Gridcoin.java new file mode 100644 index 00000000..66acfca9 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Gridcoin.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class Gridcoin extends Coin { + + public Gridcoin() { + super("Gridcoin", "GRC", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index ee650984..4fdf686c 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("GRC", "Gridcoin")); result.add(new CryptoCurrency("LBC", "LBRY Credits")); result.add(new CryptoCurrency("LSK", "Lisk")); result.add(new CryptoCurrency("MAID", "MaidSafeCoin")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 1e3510da..3275483b 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -32,6 +32,7 @@ bisq.asset.coins.DynamicCoin bisq.asset.coins.Espers bisq.asset.coins.Ether bisq.asset.coins.EtherClassic +bisq.asset.coins.Gridcoin bisq.asset.coins.InfinityEconomics bisq.asset.coins.Instacash bisq.asset.coins.InternetOfPeople diff --git a/src/test/java/bisq/asset/coins/GridcoinTest.java b/src/test/java/bisq/asset/coins/GridcoinTest.java new file mode 100644 index 00000000..207fc8cd --- /dev/null +++ b/src/test/java/bisq/asset/coins/GridcoinTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class GridcoinTest extends AbstractAssetWithDefaultValidatorTest { + + public GridcoinTest() { + super(new Gridcoin()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 7314690f..2c88f3ec 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -75,6 +75,11 @@ public void testETC() { testDefaultValidator("ETC"); } + @Test + public void testGRC() { + testDefaultValidator("GRC"); + } + @Test @Ignore public void testBSQ() { From 04c2e3529d26168ee0273a31ec8946acd0a9a589 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 12:15:05 +0200 Subject: [PATCH 072/106] Extract LBRY --- src/main/java/bisq/asset/coins/LBRY.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + src/test/java/bisq/asset/coins/LBRYTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/LBRY.java create mode 100644 src/test/java/bisq/asset/coins/LBRYTest.java diff --git a/src/main/java/bisq/asset/coins/LBRY.java b/src/main/java/bisq/asset/coins/LBRY.java new file mode 100644 index 00000000..3e694aab --- /dev/null +++ b/src/main/java/bisq/asset/coins/LBRY.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class LBRY extends Coin { + + public LBRY() { + super("LBRY Credits", "LBC", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 4fdf686c..81dc405c 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("LBC", "LBRY Credits")); result.add(new CryptoCurrency("LSK", "Lisk")); result.add(new CryptoCurrency("MAID", "MaidSafeCoin")); result.add(new CryptoCurrency("XMR", "Monero")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 3275483b..b1fc5b70 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -37,6 +37,7 @@ bisq.asset.coins.InfinityEconomics bisq.asset.coins.Instacash bisq.asset.coins.InternetOfPeople bisq.asset.coins.Koto +bisq.asset.coins.LBRY bisq.asset.coins.Litecoin$Mainnet bisq.asset.coins.Litecoin$Regtest bisq.asset.coins.Litecoin$Testnet diff --git a/src/test/java/bisq/asset/coins/LBRYTest.java b/src/test/java/bisq/asset/coins/LBRYTest.java new file mode 100644 index 00000000..9a22dd51 --- /dev/null +++ b/src/test/java/bisq/asset/coins/LBRYTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class LBRYTest extends AbstractAssetWithDefaultValidatorTest { + + public LBRYTest() { + super(new LBRY()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 2c88f3ec..373debeb 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -80,6 +80,11 @@ public void testGRC() { testDefaultValidator("GRC"); } + @Test + public void testLBC() { + testDefaultValidator("LBC"); + } + @Test @Ignore public void testBSQ() { From d84bf70ca2711bc7e338dc9207e55a952151992b Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 12:16:15 +0200 Subject: [PATCH 073/106] Extract Lisk --- src/main/java/bisq/asset/coins/Lisk.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + src/test/java/bisq/asset/coins/LiskTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/Lisk.java create mode 100644 src/test/java/bisq/asset/coins/LiskTest.java diff --git a/src/main/java/bisq/asset/coins/Lisk.java b/src/main/java/bisq/asset/coins/Lisk.java new file mode 100644 index 00000000..138aece4 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Lisk.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class Lisk extends Coin { + + public Lisk() { + super("Lisk", "LSK", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 81dc405c..32e773c6 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("LSK", "Lisk")); result.add(new CryptoCurrency("MAID", "MaidSafeCoin")); result.add(new CryptoCurrency("XMR", "Monero")); result.add(new CryptoCurrency("MT", "Mycelium Token", true)); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index b1fc5b70..3ac2587f 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -38,6 +38,7 @@ bisq.asset.coins.Instacash bisq.asset.coins.InternetOfPeople bisq.asset.coins.Koto bisq.asset.coins.LBRY +bisq.asset.coins.Lisk bisq.asset.coins.Litecoin$Mainnet bisq.asset.coins.Litecoin$Regtest bisq.asset.coins.Litecoin$Testnet diff --git a/src/test/java/bisq/asset/coins/LiskTest.java b/src/test/java/bisq/asset/coins/LiskTest.java new file mode 100644 index 00000000..7606cb6e --- /dev/null +++ b/src/test/java/bisq/asset/coins/LiskTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class LiskTest extends AbstractAssetWithDefaultValidatorTest { + + public LiskTest() { + super(new Lisk()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 373debeb..57fef470 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -85,6 +85,11 @@ public void testLBC() { testDefaultValidator("LBC"); } + @Test + public void testLSK() { + testDefaultValidator("LSK"); + } + @Test @Ignore public void testBSQ() { From eba45524f0179d5d3f51648de6f7f3303cedbeec Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 12:28:14 +0200 Subject: [PATCH 074/106] Extract MaidSafeCoin --- .../java/bisq/asset/coins/MaidSafeCoin.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../bisq/asset/coins/MaidSafeCoinTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/MaidSafeCoin.java create mode 100644 src/test/java/bisq/asset/coins/MaidSafeCoinTest.java diff --git a/src/main/java/bisq/asset/coins/MaidSafeCoin.java b/src/main/java/bisq/asset/coins/MaidSafeCoin.java new file mode 100644 index 00000000..39938b4d --- /dev/null +++ b/src/main/java/bisq/asset/coins/MaidSafeCoin.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class MaidSafeCoin extends Coin { + + public MaidSafeCoin() { + super("MaidSafeCoin", "MAID", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 32e773c6..6e8c307f 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("MAID", "MaidSafeCoin")); result.add(new CryptoCurrency("XMR", "Monero")); result.add(new CryptoCurrency("MT", "Mycelium Token", true)); result.add(new CryptoCurrency("NAV", "Nav Coin")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 3ac2587f..59a6c5aa 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -43,6 +43,7 @@ bisq.asset.coins.Litecoin$Mainnet bisq.asset.coins.Litecoin$Regtest bisq.asset.coins.Litecoin$Testnet bisq.asset.coins.Madcoin +bisq.asset.coins.MaidSafeCoin bisq.asset.coins.Nxt bisq.asset.coins.Obsidian bisq.asset.coins.Octocoin diff --git a/src/test/java/bisq/asset/coins/MaidSafeCoinTest.java b/src/test/java/bisq/asset/coins/MaidSafeCoinTest.java new file mode 100644 index 00000000..5b487e09 --- /dev/null +++ b/src/test/java/bisq/asset/coins/MaidSafeCoinTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class MaidSafeCoinTest extends AbstractAssetWithDefaultValidatorTest { + + public MaidSafeCoinTest() { + super(new MaidSafeCoin()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 57fef470..40f9a5b0 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -90,6 +90,11 @@ public void testLSK() { testDefaultValidator("LSK"); } + @Test + public void testMAID() { + testDefaultValidator("MAID"); + } + @Test @Ignore public void testBSQ() { From d114c587698bb517f9904fd5302e85e90971106c Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 12:41:33 +0200 Subject: [PATCH 075/106] Extract Monero --- src/main/java/bisq/asset/coins/Monero.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/MoneroTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/Monero.java create mode 100644 src/test/java/bisq/asset/coins/MoneroTest.java diff --git a/src/main/java/bisq/asset/coins/Monero.java b/src/main/java/bisq/asset/coins/Monero.java new file mode 100644 index 00000000..95dcc011 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Monero.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class Monero extends Coin { + + public Monero() { + super("Monero", "XMR", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 6e8c307f..a03af4a7 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("XMR", "Monero")); result.add(new CryptoCurrency("MT", "Mycelium Token", true)); result.add(new CryptoCurrency("NAV", "Nav Coin")); result.add(new CryptoCurrency("NMC", "Namecoin")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 59a6c5aa..4dbe3e54 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -44,6 +44,7 @@ bisq.asset.coins.Litecoin$Regtest bisq.asset.coins.Litecoin$Testnet bisq.asset.coins.Madcoin bisq.asset.coins.MaidSafeCoin +bisq.asset.coins.Monero bisq.asset.coins.Nxt bisq.asset.coins.Obsidian bisq.asset.coins.Octocoin diff --git a/src/test/java/bisq/asset/coins/MoneroTest.java b/src/test/java/bisq/asset/coins/MoneroTest.java new file mode 100644 index 00000000..4f77a54d --- /dev/null +++ b/src/test/java/bisq/asset/coins/MoneroTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class MoneroTest extends AbstractAssetWithDefaultValidatorTest { + + public MoneroTest() { + super(new Monero()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 40f9a5b0..dee38909 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -95,6 +95,11 @@ public void testMAID() { testDefaultValidator("MAID"); } + @Test + public void testXMR() { + testDefaultValidator("XMR"); + } + @Test @Ignore public void testBSQ() { From 90e8043f9e6608443ae0688e1098a8b4d76c1b46 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 12:53:55 +0200 Subject: [PATCH 076/106] Extract MyceliumToken --- .../java/bisq/asset/tokens/MyceliumToken.java | 10 +++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../bisq/asset/tokens/MyceliumTokenTest.java | 42 +++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 28 +++++++++---- 5 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 src/main/java/bisq/asset/tokens/MyceliumToken.java create mode 100644 src/test/java/bisq/asset/tokens/MyceliumTokenTest.java diff --git a/src/main/java/bisq/asset/tokens/MyceliumToken.java b/src/main/java/bisq/asset/tokens/MyceliumToken.java new file mode 100644 index 00000000..323fb0fc --- /dev/null +++ b/src/main/java/bisq/asset/tokens/MyceliumToken.java @@ -0,0 +1,10 @@ +package bisq.asset.tokens; + +import bisq.asset.Erc20Token; + +public class MyceliumToken extends Erc20Token { + + public MyceliumToken() { + super("Mycelium Token", "MT"); + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index a03af4a7..4f3098c0 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("MT", "Mycelium Token", true)); result.add(new CryptoCurrency("NAV", "Nav Coin")); result.add(new CryptoCurrency("NMC", "Namecoin")); result.add(new CryptoCurrency("NBT", "NuBits")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 4dbe3e54..a919e6cc 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -72,6 +72,7 @@ bisq.asset.tokens.GeoCoin bisq.asset.tokens.Grans bisq.asset.tokens.Internext bisq.asset.tokens.Movement +bisq.asset.tokens.MyceliumToken bisq.asset.tokens.Qwark bisq.asset.tokens.RefToken bisq.asset.tokens.SosCoin diff --git a/src/test/java/bisq/asset/tokens/MyceliumTokenTest.java b/src/test/java/bisq/asset/tokens/MyceliumTokenTest.java new file mode 100644 index 00000000..4e268a26 --- /dev/null +++ b/src/test/java/bisq/asset/tokens/MyceliumTokenTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class MyceliumTokenTest extends AbstractAssetTest { + + public MyceliumTokenTest() { + super(new MyceliumToken()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("0x65767ec6d4d3d18a200842352485cdc37cbf3a21"); + assertValidAddress("65767ec6d4d3d18a200842352485cdc37cbf3a21"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("0x65767ec6d4d3d18a200842352485cdc37cbf3a216"); + assertInvalidAddress("0x65767ec6d4d3d18a200842352485cdc37cbf3a2g"); + assertInvalidAddress("65767ec6d4d3d18a200842352485cdc37cbf3a2g"); + } +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index dee38909..1d6256b7 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -100,6 +100,12 @@ public void testXMR() { testDefaultValidator("XMR"); } + + @Test + public void testMT() { + testErc20Address("MT"); + } + @Test @Ignore public void testBSQ() { @@ -160,15 +166,7 @@ public void testDASH() { @Test public void testETH() { - validator.setCurrencyCode("ETH"); - - 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); + testErc20Address("ETH"); } @Test @@ -923,4 +921,16 @@ private void testDefaultValidator(String currencyCode) { assertFalse(validator.validate("").isValid); } + + private void testErc20Address(String currencyCode) { + validator.setCurrencyCode(currencyCode); + + 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); + } } From c22021e3f0bc96acb2a18f4dff3fa0c0b084e449 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 13:17:49 +0200 Subject: [PATCH 077/106] Extract NavCoin --- src/main/java/bisq/asset/coins/NavCoin.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/NavCoinTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 6 ++++ 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/NavCoin.java create mode 100644 src/test/java/bisq/asset/coins/NavCoinTest.java diff --git a/src/main/java/bisq/asset/coins/NavCoin.java b/src/main/java/bisq/asset/coins/NavCoin.java new file mode 100644 index 00000000..3c3d9642 --- /dev/null +++ b/src/main/java/bisq/asset/coins/NavCoin.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class NavCoin extends Coin { + + public NavCoin() { + super("Nav Coin", "NAV", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 4f3098c0..2f807dcf 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("NAV", "Nav Coin")); result.add(new CryptoCurrency("NMC", "Namecoin")); result.add(new CryptoCurrency("NBT", "NuBits")); result.add(new CryptoCurrency("PASC", "Pascal Coin", true)); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index a919e6cc..32d6ab5b 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -45,6 +45,7 @@ bisq.asset.coins.Litecoin$Testnet bisq.asset.coins.Madcoin bisq.asset.coins.MaidSafeCoin bisq.asset.coins.Monero +bisq.asset.coins.NavCoin bisq.asset.coins.Nxt bisq.asset.coins.Obsidian bisq.asset.coins.Octocoin diff --git a/src/test/java/bisq/asset/coins/NavCoinTest.java b/src/test/java/bisq/asset/coins/NavCoinTest.java new file mode 100644 index 00000000..c421012b --- /dev/null +++ b/src/test/java/bisq/asset/coins/NavCoinTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class NavCoinTest extends AbstractAssetWithDefaultValidatorTest { + + public NavCoinTest() { + super(new NavCoin()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 1d6256b7..5a9b4ba4 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -106,6 +106,12 @@ public void testMT() { testErc20Address("MT"); } + + @Test + public void testNAV() { + testDefaultValidator("NAV"); + } + @Test @Ignore public void testBSQ() { From ca8d34841dae6052d6ddfde3a7924b78a3b0db7b Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 13:19:13 +0200 Subject: [PATCH 078/106] Extract Namecoin --- src/main/java/bisq/asset/coins/Namecoin.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/NamecoinTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 6 ++++ 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/Namecoin.java create mode 100644 src/test/java/bisq/asset/coins/NamecoinTest.java diff --git a/src/main/java/bisq/asset/coins/Namecoin.java b/src/main/java/bisq/asset/coins/Namecoin.java new file mode 100644 index 00000000..64750a03 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Namecoin.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class Namecoin extends Coin { + + public Namecoin() { + super("Namecoin", "NMC", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 2f807dcf..a8043a52 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("NMC", "Namecoin")); result.add(new CryptoCurrency("NBT", "NuBits")); result.add(new CryptoCurrency("PASC", "Pascal Coin", true)); result.add(new CryptoCurrency("PEPECASH", "Pepe Cash")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 32d6ab5b..50601db1 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -45,6 +45,7 @@ bisq.asset.coins.Litecoin$Testnet bisq.asset.coins.Madcoin bisq.asset.coins.MaidSafeCoin bisq.asset.coins.Monero +bisq.asset.coins.Namecoin bisq.asset.coins.NavCoin bisq.asset.coins.Nxt bisq.asset.coins.Obsidian diff --git a/src/test/java/bisq/asset/coins/NamecoinTest.java b/src/test/java/bisq/asset/coins/NamecoinTest.java new file mode 100644 index 00000000..054ceafa --- /dev/null +++ b/src/test/java/bisq/asset/coins/NamecoinTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class NamecoinTest extends AbstractAssetWithDefaultValidatorTest { + + public NamecoinTest() { + super(new Namecoin()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 5a9b4ba4..a11fbcf7 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -112,6 +112,12 @@ public void testNAV() { testDefaultValidator("NAV"); } + + @Test + public void testNMC() { + testDefaultValidator("NMC"); + } + @Test @Ignore public void testBSQ() { From 0cecac625ee39c5452ced61897c06cf1baaa33e2 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 13:21:47 +0200 Subject: [PATCH 079/106] Extract NuBits --- src/main/java/bisq/asset/coins/NuBits.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/NuBitsTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 6 ++++ 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/NuBits.java create mode 100644 src/test/java/bisq/asset/coins/NuBitsTest.java diff --git a/src/main/java/bisq/asset/coins/NuBits.java b/src/main/java/bisq/asset/coins/NuBits.java new file mode 100644 index 00000000..82f63fb2 --- /dev/null +++ b/src/main/java/bisq/asset/coins/NuBits.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class NuBits extends Coin { + + public NuBits() { + super("NuBits", "NBT", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index a8043a52..102f6993 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("NBT", "NuBits")); result.add(new CryptoCurrency("PASC", "Pascal Coin", true)); result.add(new CryptoCurrency("PEPECASH", "Pepe Cash")); result.add(new CryptoCurrency("POST", "PostCoin")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 50601db1..b355c2fb 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -47,6 +47,7 @@ bisq.asset.coins.MaidSafeCoin bisq.asset.coins.Monero bisq.asset.coins.Namecoin bisq.asset.coins.NavCoin +bisq.asset.coins.NuBits bisq.asset.coins.Nxt bisq.asset.coins.Obsidian bisq.asset.coins.Octocoin diff --git a/src/test/java/bisq/asset/coins/NuBitsTest.java b/src/test/java/bisq/asset/coins/NuBitsTest.java new file mode 100644 index 00000000..efb39915 --- /dev/null +++ b/src/test/java/bisq/asset/coins/NuBitsTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class NuBitsTest extends AbstractAssetWithDefaultValidatorTest { + + public NuBitsTest() { + super(new NuBits()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index a11fbcf7..38e18a48 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -118,6 +118,12 @@ public void testNMC() { testDefaultValidator("NMC"); } + + @Test + public void testNBT() { + testDefaultValidator("NBT"); + } + @Test @Ignore public void testBSQ() { From 9b70137e286df65ecf932ef7d444d9e0af288cb4 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 13:26:02 +0200 Subject: [PATCH 080/106] Extract PascalCoin --- .../java/bisq/asset/tokens/PascalCoin.java | 10 +++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../bisq/asset/tokens/PascalCoinTest.java | 42 +++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 6 +++ 5 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/tokens/PascalCoin.java create mode 100644 src/test/java/bisq/asset/tokens/PascalCoinTest.java diff --git a/src/main/java/bisq/asset/tokens/PascalCoin.java b/src/main/java/bisq/asset/tokens/PascalCoin.java new file mode 100644 index 00000000..aee419f9 --- /dev/null +++ b/src/main/java/bisq/asset/tokens/PascalCoin.java @@ -0,0 +1,10 @@ +package bisq.asset.tokens; + +import bisq.asset.Erc20Token; + +public class PascalCoin extends Erc20Token { + + public PascalCoin() { + super("Pascal Coin", "PASC"); + } +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 102f6993..3ff4ccbd 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("PASC", "Pascal Coin", true)); result.add(new CryptoCurrency("PEPECASH", "Pepe Cash")); result.add(new CryptoCurrency("POST", "PostCoin")); result.add(new CryptoCurrency("RDD", "ReddCoin")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index b355c2fb..5ab2c823 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -76,6 +76,7 @@ bisq.asset.tokens.Grans bisq.asset.tokens.Internext bisq.asset.tokens.Movement bisq.asset.tokens.MyceliumToken +bisq.asset.tokens.PascalCoin bisq.asset.tokens.Qwark bisq.asset.tokens.RefToken bisq.asset.tokens.SosCoin diff --git a/src/test/java/bisq/asset/tokens/PascalCoinTest.java b/src/test/java/bisq/asset/tokens/PascalCoinTest.java new file mode 100644 index 00000000..d7ce0f05 --- /dev/null +++ b/src/test/java/bisq/asset/tokens/PascalCoinTest.java @@ -0,0 +1,42 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.tokens; + +import bisq.asset.AbstractAssetTest; + +import org.junit.Test; + +public class PascalCoinTest extends AbstractAssetTest { + + public PascalCoinTest() { + super(new PascalCoin()); + } + + @Test + public void testValidAddresses() { + assertValidAddress("0x65767ec6d4d3d18a200842352485cdc37cbf3a21"); + assertValidAddress("65767ec6d4d3d18a200842352485cdc37cbf3a21"); + } + + @Test + public void testInvalidAddresses() { + assertInvalidAddress("0x65767ec6d4d3d18a200842352485cdc37cbf3a216"); + assertInvalidAddress("0x65767ec6d4d3d18a200842352485cdc37cbf3a2g"); + assertInvalidAddress("65767ec6d4d3d18a200842352485cdc37cbf3a2g"); + } +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 38e18a48..2d65a7c4 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -124,6 +124,12 @@ public void testNBT() { testDefaultValidator("NBT"); } + + @Test + public void testPASC() { + testErc20Address("PASC"); + } + @Test @Ignore public void testBSQ() { From 07497746e5a41d1a188512a78b5b37b3b8681df5 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 13:28:16 +0200 Subject: [PATCH 081/106] Extract PepeCash --- src/main/java/bisq/asset/coins/PepeCash.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/PepeCashTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/PepeCash.java create mode 100644 src/test/java/bisq/asset/coins/PepeCashTest.java diff --git a/src/main/java/bisq/asset/coins/PepeCash.java b/src/main/java/bisq/asset/coins/PepeCash.java new file mode 100644 index 00000000..112805ec --- /dev/null +++ b/src/main/java/bisq/asset/coins/PepeCash.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class PepeCash extends Coin { + + public PepeCash() { + super("Pepe Cash", "PEPECASH", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 3ff4ccbd..59114130 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("PEPECASH", "Pepe Cash")); result.add(new CryptoCurrency("POST", "PostCoin")); result.add(new CryptoCurrency("RDD", "ReddCoin")); result.add(new CryptoCurrency("SFSC", "Safe FileSystem Coin")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 5ab2c823..5ca6f979 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -52,6 +52,7 @@ bisq.asset.coins.Nxt bisq.asset.coins.Obsidian bisq.asset.coins.Octocoin bisq.asset.coins.Particl +bisq.asset.coins.PepeCash bisq.asset.coins.Phore bisq.asset.coins.Pranacoin bisq.asset.coins.PIVX diff --git a/src/test/java/bisq/asset/coins/PepeCashTest.java b/src/test/java/bisq/asset/coins/PepeCashTest.java new file mode 100644 index 00000000..9a5e048b --- /dev/null +++ b/src/test/java/bisq/asset/coins/PepeCashTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class PepeCashTest extends AbstractAssetWithDefaultValidatorTest { + + public PepeCashTest() { + super(new PepeCash()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 2d65a7c4..69a8e616 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -130,6 +130,11 @@ public void testPASC() { testErc20Address("PASC"); } + @Test + public void testPEPECASH() { + testDefaultValidator("PEPECASH"); + } + @Test @Ignore public void testBSQ() { From 7998747bfb9c15a26ffd4cc5eb82139faaf35833 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 13:30:25 +0200 Subject: [PATCH 082/106] Extract PostCoin --- src/main/java/bisq/asset/coins/PostCoin.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/PostCoinTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/PostCoin.java create mode 100644 src/test/java/bisq/asset/coins/PostCoinTest.java diff --git a/src/main/java/bisq/asset/coins/PostCoin.java b/src/main/java/bisq/asset/coins/PostCoin.java new file mode 100644 index 00000000..1e4e706b --- /dev/null +++ b/src/main/java/bisq/asset/coins/PostCoin.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class PostCoin extends Coin { + + public PostCoin() { + super("PostCoin", "POST", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 59114130..c5af07d2 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("POST", "PostCoin")); result.add(new CryptoCurrency("RDD", "ReddCoin")); result.add(new CryptoCurrency("SFSC", "Safe FileSystem Coin")); result.add(new CryptoCurrency("SC", "Siacoin")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 5ca6f979..b8021a34 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -54,6 +54,7 @@ bisq.asset.coins.Octocoin bisq.asset.coins.Particl bisq.asset.coins.PepeCash bisq.asset.coins.Phore +bisq.asset.coins.PostCoin bisq.asset.coins.Pranacoin bisq.asset.coins.PIVX bisq.asset.coins.Roicoin diff --git a/src/test/java/bisq/asset/coins/PostCoinTest.java b/src/test/java/bisq/asset/coins/PostCoinTest.java new file mode 100644 index 00000000..e1e1d31d --- /dev/null +++ b/src/test/java/bisq/asset/coins/PostCoinTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class PostCoinTest extends AbstractAssetWithDefaultValidatorTest { + + public PostCoinTest() { + super(new PostCoin()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 69a8e616..b9c6abcb 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -135,6 +135,11 @@ public void testPEPECASH() { testDefaultValidator("PEPECASH"); } + @Test + public void testPOST() { + testDefaultValidator("POST"); + } + @Test @Ignore public void testBSQ() { From 375a2f0ab31d592925849020e98c34047f1c7b54 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 13:34:07 +0200 Subject: [PATCH 083/106] Extract ReddCoin --- src/main/java/bisq/asset/coins/ReddCoin.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/ReddCoinTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/ReddCoin.java create mode 100644 src/test/java/bisq/asset/coins/ReddCoinTest.java diff --git a/src/main/java/bisq/asset/coins/ReddCoin.java b/src/main/java/bisq/asset/coins/ReddCoin.java new file mode 100644 index 00000000..417f75e3 --- /dev/null +++ b/src/main/java/bisq/asset/coins/ReddCoin.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class ReddCoin extends Coin { + + public ReddCoin() { + super("ReddCoin", "RDD", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index c5af07d2..5cad016f 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("RDD", "ReddCoin")); result.add(new CryptoCurrency("SFSC", "Safe FileSystem Coin")); result.add(new CryptoCurrency("SC", "Siacoin")); result.add(new CryptoCurrency("SF", "Siafund")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index b8021a34..ed196eb2 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -57,6 +57,7 @@ bisq.asset.coins.Phore bisq.asset.coins.PostCoin bisq.asset.coins.Pranacoin bisq.asset.coins.PIVX +bisq.asset.coins.ReddCoin bisq.asset.coins.Roicoin bisq.asset.coins.Spectrecoin bisq.asset.coins.SpeedCash diff --git a/src/test/java/bisq/asset/coins/ReddCoinTest.java b/src/test/java/bisq/asset/coins/ReddCoinTest.java new file mode 100644 index 00000000..315d9fe2 --- /dev/null +++ b/src/test/java/bisq/asset/coins/ReddCoinTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class ReddCoinTest extends AbstractAssetWithDefaultValidatorTest { + + public ReddCoinTest() { + super(new ReddCoin()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index b9c6abcb..fe229e52 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -140,6 +140,11 @@ public void testPOST() { testDefaultValidator("POST"); } + @Test + public void testRDD() { + testDefaultValidator("RDD"); + } + @Test @Ignore public void testBSQ() { From fa1e3b33cdfb45306e457e77d28adea707390f07 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 13:38:07 +0200 Subject: [PATCH 084/106] Extract SafeFileSystemCoin --- .../bisq/asset/coins/SafeFileSystemCoin.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../asset/coins/SafeFileSystemCoinTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/SafeFileSystemCoin.java create mode 100644 src/test/java/bisq/asset/coins/SafeFileSystemCoinTest.java diff --git a/src/main/java/bisq/asset/coins/SafeFileSystemCoin.java b/src/main/java/bisq/asset/coins/SafeFileSystemCoin.java new file mode 100644 index 00000000..52ed43da --- /dev/null +++ b/src/main/java/bisq/asset/coins/SafeFileSystemCoin.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class SafeFileSystemCoin extends Coin { + + public SafeFileSystemCoin() { + super("Safe FileSystem Coin", "SFSC", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 5cad016f..355acdf8 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("SFSC", "Safe FileSystem Coin")); result.add(new CryptoCurrency("SC", "Siacoin")); result.add(new CryptoCurrency("SF", "Siafund")); result.add(new CryptoCurrency("SIB", "Sibcoin")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index ed196eb2..ca71c473 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -59,6 +59,7 @@ bisq.asset.coins.Pranacoin bisq.asset.coins.PIVX bisq.asset.coins.ReddCoin bisq.asset.coins.Roicoin +bisq.asset.coins.SafeFileSystemCoin bisq.asset.coins.Spectrecoin bisq.asset.coins.SpeedCash bisq.asset.coins.Stellite diff --git a/src/test/java/bisq/asset/coins/SafeFileSystemCoinTest.java b/src/test/java/bisq/asset/coins/SafeFileSystemCoinTest.java new file mode 100644 index 00000000..d049e89a --- /dev/null +++ b/src/test/java/bisq/asset/coins/SafeFileSystemCoinTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class SafeFileSystemCoinTest extends AbstractAssetWithDefaultValidatorTest { + + public SafeFileSystemCoinTest() { + super(new SafeFileSystemCoin()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index fe229e52..e50ca7da 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -145,6 +145,11 @@ public void testRDD() { testDefaultValidator("RDD"); } + @Test + public void testSFSC() { + testDefaultValidator("SFSC"); + } + @Test @Ignore public void testBSQ() { From 3bae6ec54e043e45d93301b4c8caa1294b8fe537 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 13:39:44 +0200 Subject: [PATCH 085/106] Extract Siacoin --- src/main/java/bisq/asset/coins/Siacoin.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/SiacoinTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/Siacoin.java create mode 100644 src/test/java/bisq/asset/coins/SiacoinTest.java diff --git a/src/main/java/bisq/asset/coins/Siacoin.java b/src/main/java/bisq/asset/coins/Siacoin.java new file mode 100644 index 00000000..a185bdc3 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Siacoin.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class Siacoin extends Coin { + + public Siacoin() { + super("Siacoin", "SC", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 355acdf8..02be298c 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("SC", "Siacoin")); result.add(new CryptoCurrency("SF", "Siafund")); result.add(new CryptoCurrency("SIB", "Sibcoin")); result.add(new CryptoCurrency("STEEM", "STEEM")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index ca71c473..66a44f68 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -60,6 +60,7 @@ bisq.asset.coins.PIVX bisq.asset.coins.ReddCoin bisq.asset.coins.Roicoin bisq.asset.coins.SafeFileSystemCoin +bisq.asset.coins.Siacoin bisq.asset.coins.Spectrecoin bisq.asset.coins.SpeedCash bisq.asset.coins.Stellite diff --git a/src/test/java/bisq/asset/coins/SiacoinTest.java b/src/test/java/bisq/asset/coins/SiacoinTest.java new file mode 100644 index 00000000..39ea6737 --- /dev/null +++ b/src/test/java/bisq/asset/coins/SiacoinTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class SiacoinTest extends AbstractAssetWithDefaultValidatorTest { + + public SiacoinTest() { + super(new Siacoin()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index e50ca7da..0ee166be 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -150,6 +150,11 @@ public void testSFSC() { testDefaultValidator("SFSC"); } + @Test + public void testSC() { + testDefaultValidator("SC"); + } + @Test @Ignore public void testBSQ() { From 239ce5a235630d4dc94e8e4982e26bf9160bc665 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 13:41:58 +0200 Subject: [PATCH 086/106] Extract Siafund --- src/main/java/bisq/asset/coins/Siafund.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/SiafundTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/Siafund.java create mode 100644 src/test/java/bisq/asset/coins/SiafundTest.java diff --git a/src/main/java/bisq/asset/coins/Siafund.java b/src/main/java/bisq/asset/coins/Siafund.java new file mode 100644 index 00000000..e19da83f --- /dev/null +++ b/src/main/java/bisq/asset/coins/Siafund.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class Siafund extends Coin { + + public Siafund() { + super("Siafund", "SF", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 02be298c..491f8b63 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("SF", "Siafund")); result.add(new CryptoCurrency("SIB", "Sibcoin")); result.add(new CryptoCurrency("STEEM", "STEEM")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 66a44f68..afbe2002 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -61,6 +61,7 @@ bisq.asset.coins.ReddCoin bisq.asset.coins.Roicoin bisq.asset.coins.SafeFileSystemCoin bisq.asset.coins.Siacoin +bisq.asset.coins.Siafund bisq.asset.coins.Spectrecoin bisq.asset.coins.SpeedCash bisq.asset.coins.Stellite diff --git a/src/test/java/bisq/asset/coins/SiafundTest.java b/src/test/java/bisq/asset/coins/SiafundTest.java new file mode 100644 index 00000000..26a9120e --- /dev/null +++ b/src/test/java/bisq/asset/coins/SiafundTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class SiafundTest extends AbstractAssetWithDefaultValidatorTest { + + public SiafundTest() { + super(new Siafund()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 0ee166be..397c326e 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -155,6 +155,11 @@ public void testSC() { testDefaultValidator("SC"); } + @Test + public void testSF() { + testDefaultValidator("SF"); + } + @Test @Ignore public void testBSQ() { From 66f7b5189349146ff2f4dadc524abaa87257fa36 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 13:45:37 +0200 Subject: [PATCH 087/106] Extract Sibcoin --- src/main/java/bisq/asset/coins/Sibcoin.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/SibcoinTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/Sibcoin.java create mode 100644 src/test/java/bisq/asset/coins/SibcoinTest.java diff --git a/src/main/java/bisq/asset/coins/Sibcoin.java b/src/main/java/bisq/asset/coins/Sibcoin.java new file mode 100644 index 00000000..b41f962e --- /dev/null +++ b/src/main/java/bisq/asset/coins/Sibcoin.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class Sibcoin extends Coin { + + public Sibcoin() { + super("Sibcoin", "SIB", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 491f8b63..6ae4d912 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("SIB", "Sibcoin")); result.add(new CryptoCurrency("STEEM", "STEEM")); result.add(new CryptoCurrency("UNO", "Unobtanium")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index afbe2002..5dd52cd3 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -62,6 +62,7 @@ bisq.asset.coins.Roicoin bisq.asset.coins.SafeFileSystemCoin bisq.asset.coins.Siacoin bisq.asset.coins.Siafund +bisq.asset.coins.Sibcoin bisq.asset.coins.Spectrecoin bisq.asset.coins.SpeedCash bisq.asset.coins.Stellite diff --git a/src/test/java/bisq/asset/coins/SibcoinTest.java b/src/test/java/bisq/asset/coins/SibcoinTest.java new file mode 100644 index 00000000..470159c5 --- /dev/null +++ b/src/test/java/bisq/asset/coins/SibcoinTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class SibcoinTest extends AbstractAssetWithDefaultValidatorTest { + + public SibcoinTest() { + super(new Sibcoin()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 397c326e..ebb805ec 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -160,6 +160,11 @@ public void testSF() { testDefaultValidator("SF"); } + @Test + public void testSIB() { + testDefaultValidator("SIB"); + } + @Test @Ignore public void testBSQ() { From e887223a4b3f410f0975e29b255c3d538d974ce3 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 13:48:45 +0200 Subject: [PATCH 088/106] Extract STEEM --- src/main/java/bisq/asset/coins/STEEM.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 2 -- .../META-INF/services/bisq.asset.Asset | 1 + src/test/java/bisq/asset/coins/STEEMTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/STEEM.java create mode 100644 src/test/java/bisq/asset/coins/STEEMTest.java diff --git a/src/main/java/bisq/asset/coins/STEEM.java b/src/main/java/bisq/asset/coins/STEEM.java new file mode 100644 index 00000000..38566f9e --- /dev/null +++ b/src/main/java/bisq/asset/coins/STEEM.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class STEEM extends Coin { + + public STEEM() { + super("STEEM", "STEEM", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 6ae4d912..9d2cba80 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,8 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("STEEM", "STEEM")); - result.add(new CryptoCurrency("UNO", "Unobtanium")); result.add(new CryptoCurrency("XZC", "Zcoin")); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 5dd52cd3..eb493a6d 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -65,6 +65,7 @@ bisq.asset.coins.Siafund bisq.asset.coins.Sibcoin bisq.asset.coins.Spectrecoin bisq.asset.coins.SpeedCash +bisq.asset.coins.STEEM bisq.asset.coins.Stellite bisq.asset.coins.Strayacoin bisq.asset.coins.Terracoin diff --git a/src/test/java/bisq/asset/coins/STEEMTest.java b/src/test/java/bisq/asset/coins/STEEMTest.java new file mode 100644 index 00000000..16e1d5c9 --- /dev/null +++ b/src/test/java/bisq/asset/coins/STEEMTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class STEEMTest extends AbstractAssetWithDefaultValidatorTest { + + public STEEMTest() { + super(new STEEM()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index ebb805ec..b4f3123f 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -165,6 +165,11 @@ public void testSIB() { testDefaultValidator("SIB"); } + @Test + public void testSTEEM() { + testDefaultValidator("STEEM"); + } + @Test @Ignore public void testBSQ() { From 1ca2535f32e1aa2741a099b0ff9b75b5dedf5819 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 13:51:00 +0200 Subject: [PATCH 089/106] Extract Unobtanium --- .../java/bisq/asset/coins/Unobtanium.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 1 - .../META-INF/services/bisq.asset.Asset | 1 + .../java/bisq/asset/coins/UnobtaniumTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/asset/coins/Unobtanium.java create mode 100644 src/test/java/bisq/asset/coins/UnobtaniumTest.java diff --git a/src/main/java/bisq/asset/coins/Unobtanium.java b/src/main/java/bisq/asset/coins/Unobtanium.java new file mode 100644 index 00000000..b33c7553 --- /dev/null +++ b/src/main/java/bisq/asset/coins/Unobtanium.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class Unobtanium extends Coin { + + public Unobtanium() { + super("Unobtanium", "UNO", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 9d2cba80..530604c2 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,7 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("UNO", "Unobtanium")); result.add(new CryptoCurrency("XZC", "Zcoin")); result.sort(TradeCurrency::compareTo); diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index eb493a6d..c358b149 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -70,6 +70,7 @@ bisq.asset.coins.Stellite bisq.asset.coins.Strayacoin bisq.asset.coins.Terracoin bisq.asset.coins.Ubiq +bisq.asset.coins.Unobtanium bisq.asset.coins.VDinar bisq.asset.coins.Wacoin bisq.asset.coins.WorldMobileCoin diff --git a/src/test/java/bisq/asset/coins/UnobtaniumTest.java b/src/test/java/bisq/asset/coins/UnobtaniumTest.java new file mode 100644 index 00000000..23ac22d4 --- /dev/null +++ b/src/test/java/bisq/asset/coins/UnobtaniumTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class UnobtaniumTest extends AbstractAssetWithDefaultValidatorTest { + + public UnobtaniumTest() { + super(new Unobtanium()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index b4f3123f..07890b81 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -170,6 +170,11 @@ public void testSTEEM() { testDefaultValidator("STEEM"); } + @Test + public void testUNO() { + testDefaultValidator("UNO"); + } + @Test @Ignore public void testBSQ() { From 5b061e289f2fd240b9a483556e8232bc13747523 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 13:52:21 +0200 Subject: [PATCH 090/106] Extract Zcoin --- src/main/java/bisq/asset/coins/Zcoin.java | 29 +++++++++++++++++++ .../java/bisq/core/locale/CurrencyUtil.java | 2 -- .../META-INF/services/bisq.asset.Asset | 1 + src/test/java/bisq/asset/coins/ZcoinTest.java | 28 ++++++++++++++++++ .../AltCoinAddressValidatorTest.java | 5 ++++ 5 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 src/main/java/bisq/asset/coins/Zcoin.java create mode 100644 src/test/java/bisq/asset/coins/ZcoinTest.java diff --git a/src/main/java/bisq/asset/coins/Zcoin.java b/src/main/java/bisq/asset/coins/Zcoin.java new file mode 100644 index 00000000..df763ffa --- /dev/null +++ b/src/main/java/bisq/asset/coins/Zcoin.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.Coin; +import bisq.asset.DefaultAddressValidator; + +public class Zcoin extends Coin { + + public Zcoin() { + super("Zcoin", "XZC", new DefaultAddressValidator()); + } + +} diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 530604c2..6b8046a3 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -107,8 +107,6 @@ private static List createAllSortedCryptoCurrenciesList() { .map(CurrencyUtil::assetToCryptoCurrency) .collect(Collectors.toList()); - result.add(new CryptoCurrency("XZC", "Zcoin")); - result.sort(TradeCurrency::compareTo); // Util for printing all altcoins for adding to FAQ page diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index c358b149..cc1388c6 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -76,6 +76,7 @@ bisq.asset.coins.Wacoin bisq.asset.coins.WorldMobileCoin bisq.asset.coins.Yenten bisq.asset.coins.Zcash +bisq.asset.coins.Zcoin bisq.asset.coins.ZenCash bisq.asset.tokens.BetterBetting bisq.asset.tokens.DaiStablecoin diff --git a/src/test/java/bisq/asset/coins/ZcoinTest.java b/src/test/java/bisq/asset/coins/ZcoinTest.java new file mode 100644 index 00000000..8e9bcac9 --- /dev/null +++ b/src/test/java/bisq/asset/coins/ZcoinTest.java @@ -0,0 +1,28 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.asset.coins; + +import bisq.asset.AbstractAssetWithDefaultValidatorTest; + +public class ZcoinTest extends AbstractAssetWithDefaultValidatorTest { + + public ZcoinTest() { + super(new Zcoin()); + } + +} diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index 07890b81..bad37069 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -175,6 +175,11 @@ public void testUNO() { testDefaultValidator("UNO"); } + @Test + public void testXZC() { + testDefaultValidator("XZC"); + } + @Test @Ignore public void testBSQ() { From 393e090447ff295fdfe07dd20be7e1bfed1784a6 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 13:53:36 +0200 Subject: [PATCH 091/106] Fuse sorting into stream for CurrencyUtil. --- src/main/java/bisq/core/locale/CurrencyUtil.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 6b8046a3..0ad6880c 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -105,10 +105,9 @@ private static List createAllSortedCryptoCurrenciesList() { .filter(CurrencyUtil::assetIsNotBaseCurrency) .filter(CurrencyUtil::excludeBsqUnlessDaoTradingIsActive) .map(CurrencyUtil::assetToCryptoCurrency) + .sorted(TradeCurrency::compareTo) .collect(Collectors.toList()); - result.sort(TradeCurrency::compareTo); - // Util for printing all altcoins for adding to FAQ page /* StringBuilder sb = new StringBuilder(); From f49dc8d3bcc667503591ecc99bf2ed69d1ed133a Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 29 Mar 2018 13:56:14 +0200 Subject: [PATCH 092/106] Extract Ellaism --- .../core/payment/validation/AltCoinAddressValidatorTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java index bad37069..1216492b 100644 --- a/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AltCoinAddressValidatorTest.java @@ -180,6 +180,11 @@ public void testXZC() { testDefaultValidator("XZC"); } + @Test + public void testELLA() { + testErc20Address("ELLA"); + } + @Test @Ignore public void testBSQ() { From 0eae155f67f7c0b2b25e406b15271d17651be780 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 3 Apr 2018 10:05:37 +0200 Subject: [PATCH 093/106] Add missing license headers --- src/main/java/bisq/asset/AbstractAsset.java | 17 +++++++++++++++++ src/main/java/bisq/asset/Asset.java | 17 +++++++++++++++++ src/main/java/bisq/asset/coins/BitcoinCash.java | 17 +++++++++++++++++ .../java/bisq/asset/tokens/BetterBetting.java | 17 +++++++++++++++++ .../java/bisq/asset/tokens/DaiStablecoin.java | 17 +++++++++++++++++ src/main/java/bisq/asset/tokens/Ellaism.java | 17 +++++++++++++++++ src/main/java/bisq/asset/tokens/GeoCoin.java | 17 +++++++++++++++++ src/main/java/bisq/asset/tokens/Grans.java | 17 +++++++++++++++++ src/main/java/bisq/asset/tokens/Movement.java | 17 +++++++++++++++++ .../java/bisq/asset/tokens/MyceliumToken.java | 17 +++++++++++++++++ src/main/java/bisq/asset/tokens/PascalCoin.java | 17 +++++++++++++++++ src/main/java/bisq/asset/tokens/RefToken.java | 17 +++++++++++++++++ src/main/java/bisq/asset/tokens/SosCoin.java | 17 +++++++++++++++++ .../AbstractAltcoinAddressValidatorTest.java | 17 +++++++++++++++++ 14 files changed, 238 insertions(+) diff --git a/src/main/java/bisq/asset/AbstractAsset.java b/src/main/java/bisq/asset/AbstractAsset.java index 8050f14b..7da4ba83 100644 --- a/src/main/java/bisq/asset/AbstractAsset.java +++ b/src/main/java/bisq/asset/AbstractAsset.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset; import static org.apache.commons.lang3.Validate.notBlank; diff --git a/src/main/java/bisq/asset/Asset.java b/src/main/java/bisq/asset/Asset.java index d74adb00..2db6300e 100644 --- a/src/main/java/bisq/asset/Asset.java +++ b/src/main/java/bisq/asset/Asset.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset; public interface Asset { diff --git a/src/main/java/bisq/asset/coins/BitcoinCash.java b/src/main/java/bisq/asset/coins/BitcoinCash.java index b5e08305..b8a609ec 100644 --- a/src/main/java/bisq/asset/coins/BitcoinCash.java +++ b/src/main/java/bisq/asset/coins/BitcoinCash.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.coins; import bisq.asset.Base58BitcoinAddressValidator; diff --git a/src/main/java/bisq/asset/tokens/BetterBetting.java b/src/main/java/bisq/asset/tokens/BetterBetting.java index 7feff0a5..88021db8 100644 --- a/src/main/java/bisq/asset/tokens/BetterBetting.java +++ b/src/main/java/bisq/asset/tokens/BetterBetting.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.tokens; import bisq.asset.Erc20Token; diff --git a/src/main/java/bisq/asset/tokens/DaiStablecoin.java b/src/main/java/bisq/asset/tokens/DaiStablecoin.java index 42705fb7..f0f673c5 100644 --- a/src/main/java/bisq/asset/tokens/DaiStablecoin.java +++ b/src/main/java/bisq/asset/tokens/DaiStablecoin.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.tokens; import bisq.asset.Erc20Token; diff --git a/src/main/java/bisq/asset/tokens/Ellaism.java b/src/main/java/bisq/asset/tokens/Ellaism.java index 9d745e9b..95dc40b2 100644 --- a/src/main/java/bisq/asset/tokens/Ellaism.java +++ b/src/main/java/bisq/asset/tokens/Ellaism.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.tokens; import bisq.asset.Erc20Token; diff --git a/src/main/java/bisq/asset/tokens/GeoCoin.java b/src/main/java/bisq/asset/tokens/GeoCoin.java index 9bb19e2e..a3e29529 100644 --- a/src/main/java/bisq/asset/tokens/GeoCoin.java +++ b/src/main/java/bisq/asset/tokens/GeoCoin.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.tokens; import bisq.asset.Erc20Token; diff --git a/src/main/java/bisq/asset/tokens/Grans.java b/src/main/java/bisq/asset/tokens/Grans.java index 48dab550..08f9e8ad 100644 --- a/src/main/java/bisq/asset/tokens/Grans.java +++ b/src/main/java/bisq/asset/tokens/Grans.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.tokens; import bisq.asset.Erc20Token; diff --git a/src/main/java/bisq/asset/tokens/Movement.java b/src/main/java/bisq/asset/tokens/Movement.java index ee0df654..4594b216 100644 --- a/src/main/java/bisq/asset/tokens/Movement.java +++ b/src/main/java/bisq/asset/tokens/Movement.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.tokens; import bisq.asset.Erc20Token; diff --git a/src/main/java/bisq/asset/tokens/MyceliumToken.java b/src/main/java/bisq/asset/tokens/MyceliumToken.java index 323fb0fc..cc6642f4 100644 --- a/src/main/java/bisq/asset/tokens/MyceliumToken.java +++ b/src/main/java/bisq/asset/tokens/MyceliumToken.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.tokens; import bisq.asset.Erc20Token; diff --git a/src/main/java/bisq/asset/tokens/PascalCoin.java b/src/main/java/bisq/asset/tokens/PascalCoin.java index aee419f9..d044112f 100644 --- a/src/main/java/bisq/asset/tokens/PascalCoin.java +++ b/src/main/java/bisq/asset/tokens/PascalCoin.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.tokens; import bisq.asset.Erc20Token; diff --git a/src/main/java/bisq/asset/tokens/RefToken.java b/src/main/java/bisq/asset/tokens/RefToken.java index 0d30cd8e..5bdadeb1 100644 --- a/src/main/java/bisq/asset/tokens/RefToken.java +++ b/src/main/java/bisq/asset/tokens/RefToken.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.tokens; import bisq.asset.Erc20Token; diff --git a/src/main/java/bisq/asset/tokens/SosCoin.java b/src/main/java/bisq/asset/tokens/SosCoin.java index f1072949..44f6ff2c 100644 --- a/src/main/java/bisq/asset/tokens/SosCoin.java +++ b/src/main/java/bisq/asset/tokens/SosCoin.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.asset.tokens; import bisq.asset.Erc20Token; diff --git a/src/test/java/bisq/core/payment/validation/AbstractAltcoinAddressValidatorTest.java b/src/test/java/bisq/core/payment/validation/AbstractAltcoinAddressValidatorTest.java index 83df4e6b..6896deef 100644 --- a/src/test/java/bisq/core/payment/validation/AbstractAltcoinAddressValidatorTest.java +++ b/src/test/java/bisq/core/payment/validation/AbstractAltcoinAddressValidatorTest.java @@ -1,3 +1,20 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + package bisq.core.payment.validation; import bisq.core.app.BisqEnvironment; From f8796f77ac187561b0f782585bc70003a31106db Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 3 Apr 2018 10:08:08 +0200 Subject: [PATCH 094/106] Remove blank lines between closing braces --- src/main/java/bisq/asset/coins/Arto.java | 1 - src/main/java/bisq/asset/coins/BitDaric.java | 1 - src/main/java/bisq/asset/coins/Burstcoin.java | 1 - src/main/java/bisq/asset/coins/CassubianDetk.java | 1 - src/main/java/bisq/asset/coins/Counterparty.java | 1 - src/main/java/bisq/asset/coins/DarkNet.java | 1 - src/main/java/bisq/asset/coins/Decred.java | 1 - src/main/java/bisq/asset/coins/DigiMoney.java | 1 - src/main/java/bisq/asset/coins/Dinero.java | 1 - src/main/java/bisq/asset/coins/DynamicCoin.java | 1 - src/main/java/bisq/asset/coins/Espers.java | 1 - src/main/java/bisq/asset/coins/EtherClassic.java | 1 - src/main/java/bisq/asset/coins/Gridcoin.java | 1 - src/main/java/bisq/asset/coins/InfinityEconomics.java | 1 - src/main/java/bisq/asset/coins/LBRY.java | 1 - src/main/java/bisq/asset/coins/Lisk.java | 1 - src/main/java/bisq/asset/coins/Madcoin.java | 1 - src/main/java/bisq/asset/coins/MaidSafeCoin.java | 1 - src/main/java/bisq/asset/coins/Monero.java | 1 - src/main/java/bisq/asset/coins/Namecoin.java | 1 - src/main/java/bisq/asset/coins/NavCoin.java | 1 - src/main/java/bisq/asset/coins/NuBits.java | 1 - src/main/java/bisq/asset/coins/PepeCash.java | 1 - src/main/java/bisq/asset/coins/PostCoin.java | 1 - src/main/java/bisq/asset/coins/ReddCoin.java | 1 - src/main/java/bisq/asset/coins/Roicoin.java | 1 - src/main/java/bisq/asset/coins/STEEM.java | 1 - src/main/java/bisq/asset/coins/SafeFileSystemCoin.java | 1 - src/main/java/bisq/asset/coins/Siacoin.java | 1 - src/main/java/bisq/asset/coins/Siafund.java | 1 - src/main/java/bisq/asset/coins/Sibcoin.java | 1 - src/main/java/bisq/asset/coins/Stellite.java | 1 - src/main/java/bisq/asset/coins/Ubiq.java | 1 - src/main/java/bisq/asset/coins/Unobtanium.java | 1 - src/main/java/bisq/asset/coins/VDinar.java | 1 - src/main/java/bisq/asset/coins/WorldMobileCoin.java | 1 - src/main/java/bisq/asset/coins/Zcoin.java | 1 - src/main/java/bisq/asset/tokens/Internext.java | 1 - src/main/java/bisq/asset/tokens/Qwark.java | 1 - src/main/java/bisq/asset/tokens/Verify.java | 1 - src/main/java/bisq/asset/tokens/WildToken.java | 1 - .../java/bisq/asset/AbstractAssetWithDefaultValidatorTest.java | 1 - src/test/java/bisq/asset/coins/BurstcoinTest.java | 1 - src/test/java/bisq/asset/coins/CounterpartyTest.java | 1 - src/test/java/bisq/asset/coins/DarkNetTest.java | 1 - src/test/java/bisq/asset/coins/DecredTest.java | 1 - src/test/java/bisq/asset/coins/DynamicCoinTest.java | 1 - src/test/java/bisq/asset/coins/EspersTest.java | 1 - src/test/java/bisq/asset/coins/EtherClassicTest.java | 1 - src/test/java/bisq/asset/coins/GridcoinTest.java | 1 - src/test/java/bisq/asset/coins/LBRYTest.java | 1 - src/test/java/bisq/asset/coins/LiskTest.java | 1 - src/test/java/bisq/asset/coins/MaidSafeCoinTest.java | 1 - src/test/java/bisq/asset/coins/MoneroTest.java | 1 - src/test/java/bisq/asset/coins/NamecoinTest.java | 1 - src/test/java/bisq/asset/coins/NavCoinTest.java | 1 - src/test/java/bisq/asset/coins/NuBitsTest.java | 1 - src/test/java/bisq/asset/coins/PepeCashTest.java | 1 - src/test/java/bisq/asset/coins/PostCoinTest.java | 1 - src/test/java/bisq/asset/coins/ReddCoinTest.java | 1 - src/test/java/bisq/asset/coins/STEEMTest.java | 1 - src/test/java/bisq/asset/coins/SiacoinTest.java | 1 - src/test/java/bisq/asset/coins/SiafundTest.java | 1 - src/test/java/bisq/asset/coins/SibcoinTest.java | 1 - src/test/java/bisq/asset/coins/TerracoinTest.java | 3 ++- src/test/java/bisq/asset/coins/UnobtaniumTest.java | 1 - src/test/java/bisq/asset/coins/WacoinTest.java | 3 ++- src/test/java/bisq/asset/coins/ZcoinTest.java | 1 - 68 files changed, 4 insertions(+), 68 deletions(-) diff --git a/src/main/java/bisq/asset/coins/Arto.java b/src/main/java/bisq/asset/coins/Arto.java index 98ce1416..9e4b75e8 100644 --- a/src/main/java/bisq/asset/coins/Arto.java +++ b/src/main/java/bisq/asset/coins/Arto.java @@ -25,5 +25,4 @@ public class Arto extends Coin { public Arto() { super("Arto", "RTO", new RegexAddressValidator("^[A][0-9A-Za-z]{94}$")); } - } diff --git a/src/main/java/bisq/asset/coins/BitDaric.java b/src/main/java/bisq/asset/coins/BitDaric.java index 6fd6f93f..a035d381 100644 --- a/src/main/java/bisq/asset/coins/BitDaric.java +++ b/src/main/java/bisq/asset/coins/BitDaric.java @@ -25,5 +25,4 @@ public class BitDaric extends Coin { public BitDaric() { super("BitDaric", "DARX", new RegexAddressValidator("^[R][a-km-zA-HJ-NP-Z1-9]{25,34}$")); } - } diff --git a/src/main/java/bisq/asset/coins/Burstcoin.java b/src/main/java/bisq/asset/coins/Burstcoin.java index a6da1999..f3f4bc74 100644 --- a/src/main/java/bisq/asset/coins/Burstcoin.java +++ b/src/main/java/bisq/asset/coins/Burstcoin.java @@ -25,5 +25,4 @@ public class Burstcoin extends Coin { public Burstcoin() { super("Burstcoin", "BURST", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/CassubianDetk.java b/src/main/java/bisq/asset/coins/CassubianDetk.java index 6a396d56..786e66e0 100644 --- a/src/main/java/bisq/asset/coins/CassubianDetk.java +++ b/src/main/java/bisq/asset/coins/CassubianDetk.java @@ -25,5 +25,4 @@ public class CassubianDetk extends Coin { public CassubianDetk() { super("Cassubian Detk", "CDT", new RegexAddressValidator("^D.*")); } - } diff --git a/src/main/java/bisq/asset/coins/Counterparty.java b/src/main/java/bisq/asset/coins/Counterparty.java index 104f6162..d08542fc 100644 --- a/src/main/java/bisq/asset/coins/Counterparty.java +++ b/src/main/java/bisq/asset/coins/Counterparty.java @@ -25,5 +25,4 @@ public class Counterparty extends Coin { public Counterparty() { super("Counterparty", "XCP", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/DarkNet.java b/src/main/java/bisq/asset/coins/DarkNet.java index c1a90efe..807e9f49 100644 --- a/src/main/java/bisq/asset/coins/DarkNet.java +++ b/src/main/java/bisq/asset/coins/DarkNet.java @@ -25,5 +25,4 @@ public class DarkNet extends Coin { public DarkNet() { super("DarkNet", "DNET", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/Decred.java b/src/main/java/bisq/asset/coins/Decred.java index 6f0cc8c3..c3a8bc93 100644 --- a/src/main/java/bisq/asset/coins/Decred.java +++ b/src/main/java/bisq/asset/coins/Decred.java @@ -25,5 +25,4 @@ public class Decred extends Coin { public Decred() { super("Decred", "DCR", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/DigiMoney.java b/src/main/java/bisq/asset/coins/DigiMoney.java index 7ee8b8f6..37957435 100644 --- a/src/main/java/bisq/asset/coins/DigiMoney.java +++ b/src/main/java/bisq/asset/coins/DigiMoney.java @@ -25,5 +25,4 @@ public class DigiMoney extends Coin { public DigiMoney() { super("DigiMoney", "DGM", new RegexAddressValidator("^[D-E][a-zA-Z0-9]{33}$")); } - } diff --git a/src/main/java/bisq/asset/coins/Dinero.java b/src/main/java/bisq/asset/coins/Dinero.java index 78506658..c043ef11 100644 --- a/src/main/java/bisq/asset/coins/Dinero.java +++ b/src/main/java/bisq/asset/coins/Dinero.java @@ -25,5 +25,4 @@ public class Dinero extends Coin { public Dinero() { super("Dinero", "DIN", new RegexAddressValidator("^[D][0-9a-zA-Z]{33}$")); } - } diff --git a/src/main/java/bisq/asset/coins/DynamicCoin.java b/src/main/java/bisq/asset/coins/DynamicCoin.java index 9e346b89..221c720b 100644 --- a/src/main/java/bisq/asset/coins/DynamicCoin.java +++ b/src/main/java/bisq/asset/coins/DynamicCoin.java @@ -25,5 +25,4 @@ public class DynamicCoin extends Coin { public DynamicCoin() { super("DynamicCoin", "DMC", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/Espers.java b/src/main/java/bisq/asset/coins/Espers.java index ee062b1e..be981560 100644 --- a/src/main/java/bisq/asset/coins/Espers.java +++ b/src/main/java/bisq/asset/coins/Espers.java @@ -25,5 +25,4 @@ public class Espers extends Coin { public Espers() { super("Espers", "ESP", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/EtherClassic.java b/src/main/java/bisq/asset/coins/EtherClassic.java index 4d673eba..14bcadc6 100644 --- a/src/main/java/bisq/asset/coins/EtherClassic.java +++ b/src/main/java/bisq/asset/coins/EtherClassic.java @@ -25,5 +25,4 @@ public class EtherClassic extends Coin { public EtherClassic() { super("Ether Classic", "ETC", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/Gridcoin.java b/src/main/java/bisq/asset/coins/Gridcoin.java index 66acfca9..71757361 100644 --- a/src/main/java/bisq/asset/coins/Gridcoin.java +++ b/src/main/java/bisq/asset/coins/Gridcoin.java @@ -25,5 +25,4 @@ public class Gridcoin extends Coin { public Gridcoin() { super("Gridcoin", "GRC", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/InfinityEconomics.java b/src/main/java/bisq/asset/coins/InfinityEconomics.java index f5c55e26..8bb3140a 100644 --- a/src/main/java/bisq/asset/coins/InfinityEconomics.java +++ b/src/main/java/bisq/asset/coins/InfinityEconomics.java @@ -25,5 +25,4 @@ public class InfinityEconomics extends Coin { public InfinityEconomics() { super("Infinity Economics", "XIN", new RegexAddressValidator("^XIN-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{5}$")); } - } diff --git a/src/main/java/bisq/asset/coins/LBRY.java b/src/main/java/bisq/asset/coins/LBRY.java index 3e694aab..00cadeb5 100644 --- a/src/main/java/bisq/asset/coins/LBRY.java +++ b/src/main/java/bisq/asset/coins/LBRY.java @@ -25,5 +25,4 @@ public class LBRY extends Coin { public LBRY() { super("LBRY Credits", "LBC", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/Lisk.java b/src/main/java/bisq/asset/coins/Lisk.java index 138aece4..f9ecf504 100644 --- a/src/main/java/bisq/asset/coins/Lisk.java +++ b/src/main/java/bisq/asset/coins/Lisk.java @@ -25,5 +25,4 @@ public class Lisk extends Coin { public Lisk() { super("Lisk", "LSK", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/Madcoin.java b/src/main/java/bisq/asset/coins/Madcoin.java index 34b1b8b5..92df10ed 100644 --- a/src/main/java/bisq/asset/coins/Madcoin.java +++ b/src/main/java/bisq/asset/coins/Madcoin.java @@ -25,5 +25,4 @@ public class Madcoin extends Coin { public Madcoin() { super("Madcoin", "MDC", new RegexAddressValidator("^m[a-zA-Z0-9]{26,33}$")); } - } diff --git a/src/main/java/bisq/asset/coins/MaidSafeCoin.java b/src/main/java/bisq/asset/coins/MaidSafeCoin.java index 39938b4d..1b9db574 100644 --- a/src/main/java/bisq/asset/coins/MaidSafeCoin.java +++ b/src/main/java/bisq/asset/coins/MaidSafeCoin.java @@ -25,5 +25,4 @@ public class MaidSafeCoin extends Coin { public MaidSafeCoin() { super("MaidSafeCoin", "MAID", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/Monero.java b/src/main/java/bisq/asset/coins/Monero.java index 95dcc011..477dddd0 100644 --- a/src/main/java/bisq/asset/coins/Monero.java +++ b/src/main/java/bisq/asset/coins/Monero.java @@ -25,5 +25,4 @@ public class Monero extends Coin { public Monero() { super("Monero", "XMR", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/Namecoin.java b/src/main/java/bisq/asset/coins/Namecoin.java index 64750a03..3789ff04 100644 --- a/src/main/java/bisq/asset/coins/Namecoin.java +++ b/src/main/java/bisq/asset/coins/Namecoin.java @@ -25,5 +25,4 @@ public class Namecoin extends Coin { public Namecoin() { super("Namecoin", "NMC", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/NavCoin.java b/src/main/java/bisq/asset/coins/NavCoin.java index 3c3d9642..9ca4fc1b 100644 --- a/src/main/java/bisq/asset/coins/NavCoin.java +++ b/src/main/java/bisq/asset/coins/NavCoin.java @@ -25,5 +25,4 @@ public class NavCoin extends Coin { public NavCoin() { super("Nav Coin", "NAV", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/NuBits.java b/src/main/java/bisq/asset/coins/NuBits.java index 82f63fb2..9d258989 100644 --- a/src/main/java/bisq/asset/coins/NuBits.java +++ b/src/main/java/bisq/asset/coins/NuBits.java @@ -25,5 +25,4 @@ public class NuBits extends Coin { public NuBits() { super("NuBits", "NBT", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/PepeCash.java b/src/main/java/bisq/asset/coins/PepeCash.java index 112805ec..5fea385c 100644 --- a/src/main/java/bisq/asset/coins/PepeCash.java +++ b/src/main/java/bisq/asset/coins/PepeCash.java @@ -25,5 +25,4 @@ public class PepeCash extends Coin { public PepeCash() { super("Pepe Cash", "PEPECASH", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/PostCoin.java b/src/main/java/bisq/asset/coins/PostCoin.java index 1e4e706b..76fb341d 100644 --- a/src/main/java/bisq/asset/coins/PostCoin.java +++ b/src/main/java/bisq/asset/coins/PostCoin.java @@ -25,5 +25,4 @@ public class PostCoin extends Coin { public PostCoin() { super("PostCoin", "POST", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/ReddCoin.java b/src/main/java/bisq/asset/coins/ReddCoin.java index 417f75e3..50f029e3 100644 --- a/src/main/java/bisq/asset/coins/ReddCoin.java +++ b/src/main/java/bisq/asset/coins/ReddCoin.java @@ -25,5 +25,4 @@ public class ReddCoin extends Coin { public ReddCoin() { super("ReddCoin", "RDD", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/Roicoin.java b/src/main/java/bisq/asset/coins/Roicoin.java index 519a247c..1b115e45 100644 --- a/src/main/java/bisq/asset/coins/Roicoin.java +++ b/src/main/java/bisq/asset/coins/Roicoin.java @@ -25,5 +25,4 @@ public class Roicoin extends Coin { public Roicoin() { super("ROIcoin", "ROI", new RegexAddressValidator("^[R][0-9a-zA-Z]{33}$")); } - } diff --git a/src/main/java/bisq/asset/coins/STEEM.java b/src/main/java/bisq/asset/coins/STEEM.java index 38566f9e..6d19a5c5 100644 --- a/src/main/java/bisq/asset/coins/STEEM.java +++ b/src/main/java/bisq/asset/coins/STEEM.java @@ -25,5 +25,4 @@ public class STEEM extends Coin { public STEEM() { super("STEEM", "STEEM", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/SafeFileSystemCoin.java b/src/main/java/bisq/asset/coins/SafeFileSystemCoin.java index 52ed43da..9c1de4c4 100644 --- a/src/main/java/bisq/asset/coins/SafeFileSystemCoin.java +++ b/src/main/java/bisq/asset/coins/SafeFileSystemCoin.java @@ -25,5 +25,4 @@ public class SafeFileSystemCoin extends Coin { public SafeFileSystemCoin() { super("Safe FileSystem Coin", "SFSC", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/Siacoin.java b/src/main/java/bisq/asset/coins/Siacoin.java index a185bdc3..8dbf3418 100644 --- a/src/main/java/bisq/asset/coins/Siacoin.java +++ b/src/main/java/bisq/asset/coins/Siacoin.java @@ -25,5 +25,4 @@ public class Siacoin extends Coin { public Siacoin() { super("Siacoin", "SC", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/Siafund.java b/src/main/java/bisq/asset/coins/Siafund.java index e19da83f..f31ade51 100644 --- a/src/main/java/bisq/asset/coins/Siafund.java +++ b/src/main/java/bisq/asset/coins/Siafund.java @@ -25,5 +25,4 @@ public class Siafund extends Coin { public Siafund() { super("Siafund", "SF", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/Sibcoin.java b/src/main/java/bisq/asset/coins/Sibcoin.java index b41f962e..4bda3062 100644 --- a/src/main/java/bisq/asset/coins/Sibcoin.java +++ b/src/main/java/bisq/asset/coins/Sibcoin.java @@ -25,5 +25,4 @@ public class Sibcoin extends Coin { public Sibcoin() { super("Sibcoin", "SIB", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/Stellite.java b/src/main/java/bisq/asset/coins/Stellite.java index 29086fa7..59dd349b 100644 --- a/src/main/java/bisq/asset/coins/Stellite.java +++ b/src/main/java/bisq/asset/coins/Stellite.java @@ -25,5 +25,4 @@ public class Stellite extends Coin { public Stellite() { super("Stellite", "STL", new RegexAddressValidator("^(Se)\\d[0-9A-Za-z]{94}$")); } - } diff --git a/src/main/java/bisq/asset/coins/Ubiq.java b/src/main/java/bisq/asset/coins/Ubiq.java index fb4655af..8c0b87f6 100644 --- a/src/main/java/bisq/asset/coins/Ubiq.java +++ b/src/main/java/bisq/asset/coins/Ubiq.java @@ -25,5 +25,4 @@ public class Ubiq extends Coin { public Ubiq() { super("Ubiq", "UBQ", new RegexAddressValidator("^(0x)?[0-9a-fA-F]{40}$")); } - } diff --git a/src/main/java/bisq/asset/coins/Unobtanium.java b/src/main/java/bisq/asset/coins/Unobtanium.java index b33c7553..079131cb 100644 --- a/src/main/java/bisq/asset/coins/Unobtanium.java +++ b/src/main/java/bisq/asset/coins/Unobtanium.java @@ -25,5 +25,4 @@ public class Unobtanium extends Coin { public Unobtanium() { super("Unobtanium", "UNO", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/coins/VDinar.java b/src/main/java/bisq/asset/coins/VDinar.java index ee4e37ac..5563d30d 100644 --- a/src/main/java/bisq/asset/coins/VDinar.java +++ b/src/main/java/bisq/asset/coins/VDinar.java @@ -25,5 +25,4 @@ public class VDinar extends Coin { public VDinar() { super("vDinar", "VDN", new RegexAddressValidator("^[D][0-9a-zA-Z]{33}$")); } - } diff --git a/src/main/java/bisq/asset/coins/WorldMobileCoin.java b/src/main/java/bisq/asset/coins/WorldMobileCoin.java index 08476ff7..e45650a8 100644 --- a/src/main/java/bisq/asset/coins/WorldMobileCoin.java +++ b/src/main/java/bisq/asset/coins/WorldMobileCoin.java @@ -261,6 +261,5 @@ public static Bech32Data decode(final String str) throws AddressFormatException private static String invalidChar(char c, int i) { return "Invalid character '" + Character.toString(c) + "' at position " + i; } - } } diff --git a/src/main/java/bisq/asset/coins/Zcoin.java b/src/main/java/bisq/asset/coins/Zcoin.java index df763ffa..2c498bfe 100644 --- a/src/main/java/bisq/asset/coins/Zcoin.java +++ b/src/main/java/bisq/asset/coins/Zcoin.java @@ -25,5 +25,4 @@ public class Zcoin extends Coin { public Zcoin() { super("Zcoin", "XZC", new DefaultAddressValidator()); } - } diff --git a/src/main/java/bisq/asset/tokens/Internext.java b/src/main/java/bisq/asset/tokens/Internext.java index 2265948b..71072e5b 100644 --- a/src/main/java/bisq/asset/tokens/Internext.java +++ b/src/main/java/bisq/asset/tokens/Internext.java @@ -24,5 +24,4 @@ public class Internext extends Erc20Token { public Internext() { super("Internext", "INXT"); } - } diff --git a/src/main/java/bisq/asset/tokens/Qwark.java b/src/main/java/bisq/asset/tokens/Qwark.java index e63f9c6a..e09490bb 100644 --- a/src/main/java/bisq/asset/tokens/Qwark.java +++ b/src/main/java/bisq/asset/tokens/Qwark.java @@ -24,5 +24,4 @@ public class Qwark extends Erc20Token { public Qwark() { super("Qwark", "QWARK"); } - } diff --git a/src/main/java/bisq/asset/tokens/Verify.java b/src/main/java/bisq/asset/tokens/Verify.java index cd5e289e..bff0aa62 100644 --- a/src/main/java/bisq/asset/tokens/Verify.java +++ b/src/main/java/bisq/asset/tokens/Verify.java @@ -24,5 +24,4 @@ public class Verify extends Erc20Token { public Verify() { super("Verify", "CRED"); } - } diff --git a/src/main/java/bisq/asset/tokens/WildToken.java b/src/main/java/bisq/asset/tokens/WildToken.java index 4fcc4b71..a289dcad 100644 --- a/src/main/java/bisq/asset/tokens/WildToken.java +++ b/src/main/java/bisq/asset/tokens/WildToken.java @@ -24,5 +24,4 @@ public class WildToken extends Erc20Token { public WildToken() { super("WILD Token", "WILD"); } - } diff --git a/src/test/java/bisq/asset/AbstractAssetWithDefaultValidatorTest.java b/src/test/java/bisq/asset/AbstractAssetWithDefaultValidatorTest.java index 486a1636..db5bb82b 100644 --- a/src/test/java/bisq/asset/AbstractAssetWithDefaultValidatorTest.java +++ b/src/test/java/bisq/asset/AbstractAssetWithDefaultValidatorTest.java @@ -39,5 +39,4 @@ public void testValidAddresses() { public void testInvalidAddresses() { testBlank(); } - } diff --git a/src/test/java/bisq/asset/coins/BurstcoinTest.java b/src/test/java/bisq/asset/coins/BurstcoinTest.java index 8a1da8ca..b1d6a854 100644 --- a/src/test/java/bisq/asset/coins/BurstcoinTest.java +++ b/src/test/java/bisq/asset/coins/BurstcoinTest.java @@ -24,5 +24,4 @@ public class BurstcoinTest extends AbstractAssetWithDefaultValidatorTest { public BurstcoinTest() { super(new Burstcoin()); } - } diff --git a/src/test/java/bisq/asset/coins/CounterpartyTest.java b/src/test/java/bisq/asset/coins/CounterpartyTest.java index 3e24b4e5..0f3fc7d4 100644 --- a/src/test/java/bisq/asset/coins/CounterpartyTest.java +++ b/src/test/java/bisq/asset/coins/CounterpartyTest.java @@ -24,5 +24,4 @@ public class CounterpartyTest extends AbstractAssetWithDefaultValidatorTest { public CounterpartyTest() { super(new Counterparty()); } - } diff --git a/src/test/java/bisq/asset/coins/DarkNetTest.java b/src/test/java/bisq/asset/coins/DarkNetTest.java index fec613df..190854a5 100644 --- a/src/test/java/bisq/asset/coins/DarkNetTest.java +++ b/src/test/java/bisq/asset/coins/DarkNetTest.java @@ -24,5 +24,4 @@ public class DarkNetTest extends AbstractAssetWithDefaultValidatorTest { public DarkNetTest() { super(new DarkNet()); } - } diff --git a/src/test/java/bisq/asset/coins/DecredTest.java b/src/test/java/bisq/asset/coins/DecredTest.java index 84192d1a..20190981 100644 --- a/src/test/java/bisq/asset/coins/DecredTest.java +++ b/src/test/java/bisq/asset/coins/DecredTest.java @@ -24,5 +24,4 @@ public class DecredTest extends AbstractAssetWithDefaultValidatorTest { public DecredTest() { super(new Decred()); } - } diff --git a/src/test/java/bisq/asset/coins/DynamicCoinTest.java b/src/test/java/bisq/asset/coins/DynamicCoinTest.java index 7a967d45..161e8a51 100644 --- a/src/test/java/bisq/asset/coins/DynamicCoinTest.java +++ b/src/test/java/bisq/asset/coins/DynamicCoinTest.java @@ -24,5 +24,4 @@ public class DynamicCoinTest extends AbstractAssetWithDefaultValidatorTest { public DynamicCoinTest() { super(new DynamicCoin()); } - } diff --git a/src/test/java/bisq/asset/coins/EspersTest.java b/src/test/java/bisq/asset/coins/EspersTest.java index 63b8c434..e9eb4cb1 100644 --- a/src/test/java/bisq/asset/coins/EspersTest.java +++ b/src/test/java/bisq/asset/coins/EspersTest.java @@ -24,5 +24,4 @@ public class EspersTest extends AbstractAssetWithDefaultValidatorTest { public EspersTest() { super(new Espers()); } - } diff --git a/src/test/java/bisq/asset/coins/EtherClassicTest.java b/src/test/java/bisq/asset/coins/EtherClassicTest.java index 237b44c8..f8f09cad 100644 --- a/src/test/java/bisq/asset/coins/EtherClassicTest.java +++ b/src/test/java/bisq/asset/coins/EtherClassicTest.java @@ -24,5 +24,4 @@ public class EtherClassicTest extends AbstractAssetWithDefaultValidatorTest { public EtherClassicTest() { super(new EtherClassic()); } - } diff --git a/src/test/java/bisq/asset/coins/GridcoinTest.java b/src/test/java/bisq/asset/coins/GridcoinTest.java index 207fc8cd..62b1241d 100644 --- a/src/test/java/bisq/asset/coins/GridcoinTest.java +++ b/src/test/java/bisq/asset/coins/GridcoinTest.java @@ -24,5 +24,4 @@ public class GridcoinTest extends AbstractAssetWithDefaultValidatorTest { public GridcoinTest() { super(new Gridcoin()); } - } diff --git a/src/test/java/bisq/asset/coins/LBRYTest.java b/src/test/java/bisq/asset/coins/LBRYTest.java index 9a22dd51..d34f1347 100644 --- a/src/test/java/bisq/asset/coins/LBRYTest.java +++ b/src/test/java/bisq/asset/coins/LBRYTest.java @@ -24,5 +24,4 @@ public class LBRYTest extends AbstractAssetWithDefaultValidatorTest { public LBRYTest() { super(new LBRY()); } - } diff --git a/src/test/java/bisq/asset/coins/LiskTest.java b/src/test/java/bisq/asset/coins/LiskTest.java index 7606cb6e..50999491 100644 --- a/src/test/java/bisq/asset/coins/LiskTest.java +++ b/src/test/java/bisq/asset/coins/LiskTest.java @@ -24,5 +24,4 @@ public class LiskTest extends AbstractAssetWithDefaultValidatorTest { public LiskTest() { super(new Lisk()); } - } diff --git a/src/test/java/bisq/asset/coins/MaidSafeCoinTest.java b/src/test/java/bisq/asset/coins/MaidSafeCoinTest.java index 5b487e09..dc6306f1 100644 --- a/src/test/java/bisq/asset/coins/MaidSafeCoinTest.java +++ b/src/test/java/bisq/asset/coins/MaidSafeCoinTest.java @@ -24,5 +24,4 @@ public class MaidSafeCoinTest extends AbstractAssetWithDefaultValidatorTest { public MaidSafeCoinTest() { super(new MaidSafeCoin()); } - } diff --git a/src/test/java/bisq/asset/coins/MoneroTest.java b/src/test/java/bisq/asset/coins/MoneroTest.java index 4f77a54d..0136eeea 100644 --- a/src/test/java/bisq/asset/coins/MoneroTest.java +++ b/src/test/java/bisq/asset/coins/MoneroTest.java @@ -24,5 +24,4 @@ public class MoneroTest extends AbstractAssetWithDefaultValidatorTest { public MoneroTest() { super(new Monero()); } - } diff --git a/src/test/java/bisq/asset/coins/NamecoinTest.java b/src/test/java/bisq/asset/coins/NamecoinTest.java index 054ceafa..8c513ff7 100644 --- a/src/test/java/bisq/asset/coins/NamecoinTest.java +++ b/src/test/java/bisq/asset/coins/NamecoinTest.java @@ -24,5 +24,4 @@ public class NamecoinTest extends AbstractAssetWithDefaultValidatorTest { public NamecoinTest() { super(new Namecoin()); } - } diff --git a/src/test/java/bisq/asset/coins/NavCoinTest.java b/src/test/java/bisq/asset/coins/NavCoinTest.java index c421012b..a03ea2ae 100644 --- a/src/test/java/bisq/asset/coins/NavCoinTest.java +++ b/src/test/java/bisq/asset/coins/NavCoinTest.java @@ -24,5 +24,4 @@ public class NavCoinTest extends AbstractAssetWithDefaultValidatorTest { public NavCoinTest() { super(new NavCoin()); } - } diff --git a/src/test/java/bisq/asset/coins/NuBitsTest.java b/src/test/java/bisq/asset/coins/NuBitsTest.java index efb39915..382ca94c 100644 --- a/src/test/java/bisq/asset/coins/NuBitsTest.java +++ b/src/test/java/bisq/asset/coins/NuBitsTest.java @@ -24,5 +24,4 @@ public class NuBitsTest extends AbstractAssetWithDefaultValidatorTest { public NuBitsTest() { super(new NuBits()); } - } diff --git a/src/test/java/bisq/asset/coins/PepeCashTest.java b/src/test/java/bisq/asset/coins/PepeCashTest.java index 9a5e048b..ac5e7c4f 100644 --- a/src/test/java/bisq/asset/coins/PepeCashTest.java +++ b/src/test/java/bisq/asset/coins/PepeCashTest.java @@ -24,5 +24,4 @@ public class PepeCashTest extends AbstractAssetWithDefaultValidatorTest { public PepeCashTest() { super(new PepeCash()); } - } diff --git a/src/test/java/bisq/asset/coins/PostCoinTest.java b/src/test/java/bisq/asset/coins/PostCoinTest.java index e1e1d31d..5839b215 100644 --- a/src/test/java/bisq/asset/coins/PostCoinTest.java +++ b/src/test/java/bisq/asset/coins/PostCoinTest.java @@ -24,5 +24,4 @@ public class PostCoinTest extends AbstractAssetWithDefaultValidatorTest { public PostCoinTest() { super(new PostCoin()); } - } diff --git a/src/test/java/bisq/asset/coins/ReddCoinTest.java b/src/test/java/bisq/asset/coins/ReddCoinTest.java index 315d9fe2..3df90a1c 100644 --- a/src/test/java/bisq/asset/coins/ReddCoinTest.java +++ b/src/test/java/bisq/asset/coins/ReddCoinTest.java @@ -24,5 +24,4 @@ public class ReddCoinTest extends AbstractAssetWithDefaultValidatorTest { public ReddCoinTest() { super(new ReddCoin()); } - } diff --git a/src/test/java/bisq/asset/coins/STEEMTest.java b/src/test/java/bisq/asset/coins/STEEMTest.java index 16e1d5c9..d0f110ff 100644 --- a/src/test/java/bisq/asset/coins/STEEMTest.java +++ b/src/test/java/bisq/asset/coins/STEEMTest.java @@ -24,5 +24,4 @@ public class STEEMTest extends AbstractAssetWithDefaultValidatorTest { public STEEMTest() { super(new STEEM()); } - } diff --git a/src/test/java/bisq/asset/coins/SiacoinTest.java b/src/test/java/bisq/asset/coins/SiacoinTest.java index 39ea6737..465ba608 100644 --- a/src/test/java/bisq/asset/coins/SiacoinTest.java +++ b/src/test/java/bisq/asset/coins/SiacoinTest.java @@ -24,5 +24,4 @@ public class SiacoinTest extends AbstractAssetWithDefaultValidatorTest { public SiacoinTest() { super(new Siacoin()); } - } diff --git a/src/test/java/bisq/asset/coins/SiafundTest.java b/src/test/java/bisq/asset/coins/SiafundTest.java index 26a9120e..c1ea0f23 100644 --- a/src/test/java/bisq/asset/coins/SiafundTest.java +++ b/src/test/java/bisq/asset/coins/SiafundTest.java @@ -24,5 +24,4 @@ public class SiafundTest extends AbstractAssetWithDefaultValidatorTest { public SiafundTest() { super(new Siafund()); } - } diff --git a/src/test/java/bisq/asset/coins/SibcoinTest.java b/src/test/java/bisq/asset/coins/SibcoinTest.java index 470159c5..aa3acea8 100644 --- a/src/test/java/bisq/asset/coins/SibcoinTest.java +++ b/src/test/java/bisq/asset/coins/SibcoinTest.java @@ -24,5 +24,4 @@ public class SibcoinTest extends AbstractAssetWithDefaultValidatorTest { public SibcoinTest() { super(new Sibcoin()); } - } diff --git a/src/test/java/bisq/asset/coins/TerracoinTest.java b/src/test/java/bisq/asset/coins/TerracoinTest.java index fdde5312..d28a802b 100644 --- a/src/test/java/bisq/asset/coins/TerracoinTest.java +++ b/src/test/java/bisq/asset/coins/TerracoinTest.java @@ -43,4 +43,5 @@ public void testInvalidAddresses() { assertInvalidAddress("18s142HdWDfDQXYBuyMvsU3KHwryLxnCr"); assertInvalidAddress("1asdasd"); assertInvalidAddress("asdasd"); - }} + } +} diff --git a/src/test/java/bisq/asset/coins/UnobtaniumTest.java b/src/test/java/bisq/asset/coins/UnobtaniumTest.java index 23ac22d4..ed90c1e6 100644 --- a/src/test/java/bisq/asset/coins/UnobtaniumTest.java +++ b/src/test/java/bisq/asset/coins/UnobtaniumTest.java @@ -24,5 +24,4 @@ public class UnobtaniumTest extends AbstractAssetWithDefaultValidatorTest { public UnobtaniumTest() { super(new Unobtanium()); } - } diff --git a/src/test/java/bisq/asset/coins/WacoinTest.java b/src/test/java/bisq/asset/coins/WacoinTest.java index 2bab95b3..44768a14 100644 --- a/src/test/java/bisq/asset/coins/WacoinTest.java +++ b/src/test/java/bisq/asset/coins/WacoinTest.java @@ -40,4 +40,5 @@ public void testInvalidAddresses() { assertInvalidAddress("abcde"); assertInvalidAddress("mWvZ7nZAUzpRMFp2Bfjxz27Va47nUfB79E"); assertInvalidAddress("WemK3MgwREsE23fgsadtYLxmMqAX9C2LYQ"); - }} + } +} diff --git a/src/test/java/bisq/asset/coins/ZcoinTest.java b/src/test/java/bisq/asset/coins/ZcoinTest.java index 8e9bcac9..eab34a26 100644 --- a/src/test/java/bisq/asset/coins/ZcoinTest.java +++ b/src/test/java/bisq/asset/coins/ZcoinTest.java @@ -24,5 +24,4 @@ public class ZcoinTest extends AbstractAssetWithDefaultValidatorTest { public ZcoinTest() { super(new Zcoin()); } - } From 0551d2291f82f412b8f02e187c9f7a5278efde44 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 3 Apr 2018 10:09:56 +0200 Subject: [PATCH 095/106] Add blank lines where appropriate --- src/main/java/bisq/asset/DefaultAddressValidator.java | 1 + src/main/java/bisq/asset/coins/BitcoinGold.java | 1 + src/main/java/bisq/asset/coins/Cryptonite.java | 4 +++- src/main/java/bisq/asset/coins/Koto.java | 1 + src/main/java/bisq/asset/coins/Particl.java | 1 + src/main/java/bisq/asset/coins/Yenten.java | 1 + src/main/java/bisq/asset/coins/Zcash.java | 1 + 7 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/bisq/asset/DefaultAddressValidator.java b/src/main/java/bisq/asset/DefaultAddressValidator.java index a762765f..2b45cf1c 100644 --- a/src/main/java/bisq/asset/DefaultAddressValidator.java +++ b/src/main/java/bisq/asset/DefaultAddressValidator.java @@ -24,6 +24,7 @@ public class DefaultAddressValidator implements AddressValidator { public AddressValidationResult validate(String address) { if (address == null || address.length() == 0) return AddressValidationResult.invalidAddress("Address may not be empty"); + return AddressValidationResult.validAddress(); } } diff --git a/src/main/java/bisq/asset/coins/BitcoinGold.java b/src/main/java/bisq/asset/coins/BitcoinGold.java index bd0e7c65..95ad7706 100644 --- a/src/main/java/bisq/asset/coins/BitcoinGold.java +++ b/src/main/java/bisq/asset/coins/BitcoinGold.java @@ -29,6 +29,7 @@ public BitcoinGold() { super("Bitcoin Gold", "BTG", new Base58BitcoinAddressValidator(new BitcoinGoldParams())); } + private static class BitcoinGoldParams extends NetworkParametersAdapter { public BitcoinGoldParams() { diff --git a/src/main/java/bisq/asset/coins/Cryptonite.java b/src/main/java/bisq/asset/coins/Cryptonite.java index 7537765b..33560f1b 100644 --- a/src/main/java/bisq/asset/coins/Cryptonite.java +++ b/src/main/java/bisq/asset/coins/Cryptonite.java @@ -42,8 +42,10 @@ public AddressValidationResult validate(String address) { // https://bitcointalk.org/index.php?topic=1801595 if (address.length() != 34) return AddressValidationResult.invalidAddress("XCN_Addr_Invalid: Length must be 34!"); + if (!address.startsWith("C")) return AddressValidationResult.invalidAddress("XCN_Addr_Invalid: must start with 'C'!"); + byte[] decoded = decodeBase58(address); if (decoded == null) return AddressValidationResult.invalidAddress("XCN_Addr_Invalid: Base58 decoder error!"); @@ -51,8 +53,8 @@ public AddressValidationResult validate(String address) { byte[] hash = getSha256(decoded, 21, 2); if (hash == null || !Arrays.equals(Arrays.copyOfRange(hash, 0, 4), Arrays.copyOfRange(decoded, 21, 25))) return AddressValidationResult.invalidAddress("XCN_Addr_Invalid: Checksum error!"); - return AddressValidationResult.validAddress(); + return AddressValidationResult.validAddress(); } private static byte[] decodeBase58(String input) { diff --git a/src/main/java/bisq/asset/coins/Koto.java b/src/main/java/bisq/asset/coins/Koto.java index 7a8dd574..f060c473 100644 --- a/src/main/java/bisq/asset/coins/Koto.java +++ b/src/main/java/bisq/asset/coins/Koto.java @@ -34,6 +34,7 @@ public Koto() { public static class KotoAddressValidator implements AddressValidator { + private final static String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; @Override diff --git a/src/main/java/bisq/asset/coins/Particl.java b/src/main/java/bisq/asset/coins/Particl.java index c4fdcc2a..edf26fd5 100644 --- a/src/main/java/bisq/asset/coins/Particl.java +++ b/src/main/java/bisq/asset/coins/Particl.java @@ -39,6 +39,7 @@ public ParticlAddressValidator() { public AddressValidationResult validate(String address) { if (!address.matches("^[RP][a-km-zA-HJ-NP-Z1-9]{25,34}$")) return AddressValidationResult.invalidStructure(); + return super.validate(address); } } diff --git a/src/main/java/bisq/asset/coins/Yenten.java b/src/main/java/bisq/asset/coins/Yenten.java index cb93cd2a..7a8a7fb2 100644 --- a/src/main/java/bisq/asset/coins/Yenten.java +++ b/src/main/java/bisq/asset/coins/Yenten.java @@ -34,6 +34,7 @@ public Yenten() { public static class YentenAddressValidator implements AddressValidator { + private final static String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; public AddressValidationResult validate(String addr) { diff --git a/src/main/java/bisq/asset/coins/Zcash.java b/src/main/java/bisq/asset/coins/Zcash.java index 243adad1..0f790b46 100644 --- a/src/main/java/bisq/asset/coins/Zcash.java +++ b/src/main/java/bisq/asset/coins/Zcash.java @@ -35,6 +35,7 @@ public AddressValidationResult validate(String address) { // We only support t addresses (transparent transactions) if (!address.startsWith("t")) return AddressValidationResult.invalidAddress("", "validation.altcoin.zAddressesNotSupported"); + return AddressValidationResult.validAddress(); } } From c1d5aac7bc1e00b8568374bdcb15e01f5f92897c Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 3 Apr 2018 10:11:02 +0200 Subject: [PATCH 096/106] Wrap code at 120 characters Per bisq-network/style#3 --- src/main/java/bisq/asset/coins/Byteball.java | 4 ++- .../bisq/asset/coins/InfinityEconomics.java | 3 ++- src/main/java/bisq/asset/coins/Nxt.java | 26 ++++++++++++------- .../bisq/asset/coins/WorldMobileCoin.java | 9 ++++--- src/test/java/bisq/asset/coins/KotoTest.java | 3 ++- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/main/java/bisq/asset/coins/Byteball.java b/src/main/java/bisq/asset/coins/Byteball.java index 9932fd9d..54b9cfcc 100644 --- a/src/main/java/bisq/asset/coins/Byteball.java +++ b/src/main/java/bisq/asset/coins/Byteball.java @@ -112,7 +112,9 @@ private static Integer[] calcOffsets(int chash_length) throws Exception { return arrOffsets.toArray(new Integer[0]); } - private static ByteballAddressValidator.SeparatedData separateIntoCleanDataAndChecksum(String bin) throws Exception { + private static ByteballAddressValidator.SeparatedData separateIntoCleanDataAndChecksum(String bin) + throws Exception { + int len = bin.length(); Integer[] arrOffsets; if (len == 160) diff --git a/src/main/java/bisq/asset/coins/InfinityEconomics.java b/src/main/java/bisq/asset/coins/InfinityEconomics.java index 8bb3140a..b58a0e6a 100644 --- a/src/main/java/bisq/asset/coins/InfinityEconomics.java +++ b/src/main/java/bisq/asset/coins/InfinityEconomics.java @@ -23,6 +23,7 @@ public class InfinityEconomics extends Coin { public InfinityEconomics() { - super("Infinity Economics", "XIN", new RegexAddressValidator("^XIN-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{5}$")); + super("Infinity Economics", "XIN", + new RegexAddressValidator("^XIN-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{5}$")); } } diff --git a/src/main/java/bisq/asset/coins/Nxt.java b/src/main/java/bisq/asset/coins/Nxt.java index 9347cb06..6e1850c9 100644 --- a/src/main/java/bisq/asset/coins/Nxt.java +++ b/src/main/java/bisq/asset/coins/Nxt.java @@ -32,26 +32,30 @@ public static class NxtAddressValidator implements AddressValidator { @Override public AddressValidationResult validate(String address) { - if (!address.startsWith("NXT-") || !address.equals(address.toUpperCase())) { + if (!address.startsWith("NXT-") || !address.equals(address.toUpperCase())) return AddressValidationResult.invalidStructure(); - } + try { long accountId = NxtReedSolomonValidator.decode(address.substring(4)); - if (accountId == 0) { + if (accountId == 0) return AddressValidationResult.invalidStructure(); - } - return AddressValidationResult.validAddress(); } catch (NxtReedSolomonValidator.DecodeException e) { return AddressValidationResult.invalidAddress(e); } + + return AddressValidationResult.validAddress(); } } public static final class NxtReedSolomonValidator { private static final int[] initial_codeword = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - private static final int[] gexp = {1, 2, 4, 8, 16, 5, 10, 20, 13, 26, 17, 7, 14, 28, 29, 31, 27, 19, 3, 6, 12, 24, 21, 15, 30, 25, 23, 11, 22, 9, 18, 1}; - private static final int[] glog = {0, 0, 1, 18, 2, 5, 19, 11, 3, 29, 6, 27, 20, 8, 12, 23, 4, 10, 30, 17, 7, 22, 28, 26, 21, 25, 9, 16, 13, 14, 24, 15}; + private static final int[] gexp = { + 1, 2, 4, 8, 16, 5, 10, 20, 13, 26, 17, 7, 14, 28, 29, 31, + 27, 19, 3, 6, 12, 24, 21, 15, 30, 25, 23, 11, 22, 9, 18, 1}; + private static final int[] glog = { + 0, 0, 1, 18, 2, 5, 19, 11, 3, 29, 6, 27, 20, 8, 12, 23, 4, + 10, 30, 17, 7, 22, 28, 26, 21, 25, 9, 16, 13, 14, 24, 15}; private static final int[] codeword_map = {3, 2, 1, 0, 7, 6, 5, 4, 13, 14, 15, 16, 12, 8, 9, 10, 11}; private static final String alphabet = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ"; @@ -98,7 +102,9 @@ public static String encode(long plain) { p[0] = NxtReedSolomonValidator.gmult(17, fb); } - System.arraycopy(p, 0, codeword, NxtReedSolomonValidator.base_32_length, NxtReedSolomonValidator.initial_codeword.length - NxtReedSolomonValidator.base_32_length); + System.arraycopy( + p, 0, codeword, NxtReedSolomonValidator.base_32_length, + NxtReedSolomonValidator.initial_codeword.length - NxtReedSolomonValidator.base_32_length); StringBuilder cypher_string_builder = new StringBuilder(); for (int i = 0; i < 17; i++) { @@ -116,7 +122,9 @@ public static String encode(long plain) { public static long decode(String cypher_string) throws DecodeException { int[] codeword = new int[NxtReedSolomonValidator.initial_codeword.length]; - System.arraycopy(NxtReedSolomonValidator.initial_codeword, 0, codeword, 0, NxtReedSolomonValidator.initial_codeword.length); + System.arraycopy( + NxtReedSolomonValidator.initial_codeword, 0, codeword, 0, + NxtReedSolomonValidator.initial_codeword.length); int codeword_length = 0; for (int i = 0; i < cypher_string.length(); i++) { diff --git a/src/main/java/bisq/asset/coins/WorldMobileCoin.java b/src/main/java/bisq/asset/coins/WorldMobileCoin.java index e45650a8..2a71b14d 100644 --- a/src/main/java/bisq/asset/coins/WorldMobileCoin.java +++ b/src/main/java/bisq/asset/coins/WorldMobileCoin.java @@ -172,10 +172,11 @@ private static byte[] convertBits(final byte[] in, final int inStart, final int private static class Bech32 { private static final byte[] CHARSET_REV = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, 10, 17, 21, 20, 26, 30, 7, 5, -1, -1, -1, -1, -1, -1, - -1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, 22, 31, 27, 19, -1, 1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1, - -1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, 22, 31, 27, 19, -1, 1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, 10, 17, + 21, 20, 26, 30, 7, 5, -1, -1, -1, -1, -1, -1, -1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, 22, 31, 27, 19, + -1, 1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1, -1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, + 22, 31, 27, 19, -1, 1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1 }; static class Bech32Data { diff --git a/src/test/java/bisq/asset/coins/KotoTest.java b/src/test/java/bisq/asset/coins/KotoTest.java index af6efae4..396adbdb 100644 --- a/src/test/java/bisq/asset/coins/KotoTest.java +++ b/src/test/java/bisq/asset/coins/KotoTest.java @@ -40,6 +40,7 @@ public void testInvalidAddresses() { assertInvalidAddress("k2De32yyMZ8xdDFBJXjVseiN99S9eJpvty5"); assertInvalidAddress("jyzCuxaXN38djCzdkb8nQs7v1joHWtkC4v8"); assertInvalidAddress("JzyNxmc9iDaGokmMrkmMCncfMQvw5vbHBKv"); - assertInvalidAddress("zkPRkLZKf4BuzBsC6r9Ls5suw1ZV9tCwiBTF5vcz2NZLUDsoXGp5rAFUjKnb7DdkFbLp7aSpejCcC4FTxsVvDxq9YKSprzf"); + assertInvalidAddress( + "zkPRkLZKf4BuzBsC6r9Ls5suw1ZV9tCwiBTF5vcz2NZLUDsoXGp5rAFUjKnb7DdkFbLp7aSpejCcC4FTxsVvDxq9YKSprzf"); } } From b73fa60a6a61884488b177ce0bbc56370faff028 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 3 Apr 2018 10:12:17 +0200 Subject: [PATCH 097/106] Remove unnecessary else(if) clauses after a return --- src/main/java/bisq/asset/coins/ZenCash.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/bisq/asset/coins/ZenCash.java b/src/main/java/bisq/asset/coins/ZenCash.java index 15db3ac4..1f588c21 100644 --- a/src/main/java/bisq/asset/coins/ZenCash.java +++ b/src/main/java/bisq/asset/coins/ZenCash.java @@ -50,16 +50,18 @@ public AddressValidationResult validate(String address) { // and multisig ("zs" (0x20,0x96), "t3" (0x1C,0xBD)) addresses // Fail for private addresses - if (version0 == 0x16 && version1 == 0x9A) { + if (version0 == 0x16 && version1 == 0x9A) // Address starts with "zc" return AddressValidationResult.invalidAddress("", "validation.altcoin.zAddressesNotSupported"); - } else if (version0 == 0x1C && (version1 == 0xB8 || version1 == 0xBD)) { + + if (version0 == 0x1C && (version1 == 0xB8 || version1 == 0xBD)) // "t1" or "t3" address return AddressValidationResult.validAddress(); - } else if (version0 == 0x20 && (version1 == 0x89 || version1 == 0x96)) { + + if (version0 == 0x20 && (version1 == 0x89 || version1 == 0x96)) // "zn" or "zs" address return AddressValidationResult.validAddress(); - } + // Unknown Type return AddressValidationResult.invalidStructure(); } From 7ad70c3979e277337463c2f41f7ad66acb3aa168 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 3 Apr 2018 10:14:09 +0200 Subject: [PATCH 098/106] Simplify BitcoinClashic --- src/main/java/bisq/asset/coins/BitcoinClashic.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/bisq/asset/coins/BitcoinClashic.java b/src/main/java/bisq/asset/coins/BitcoinClashic.java index 9eced4c5..2517213d 100644 --- a/src/main/java/bisq/asset/coins/BitcoinClashic.java +++ b/src/main/java/bisq/asset/coins/BitcoinClashic.java @@ -20,11 +20,9 @@ import bisq.asset.Base58BitcoinAddressValidator; import bisq.asset.Coin; -import org.bitcoinj.params.MainNetParams; - public class BitcoinClashic extends Coin { public BitcoinClashic() { - super("Bitcoin Clashic", "BCHC", new Base58BitcoinAddressValidator(new MainNetParams())); + super("Bitcoin Clashic", "BCHC", new Base58BitcoinAddressValidator()); } } From cc5edbe97c37186a2b8c115e21417a66d67d0eea Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 3 Apr 2018 10:14:46 +0200 Subject: [PATCH 099/106] Improve AbstractAssetTest#testPresenceInAssetRegistry - Simplify stream operations used to test presence - Print helpful message on failure --- src/main/java/bisq/asset/AbstractAsset.java | 5 +++++ src/test/java/bisq/asset/AbstractAssetTest.java | 9 ++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/bisq/asset/AbstractAsset.java b/src/main/java/bisq/asset/AbstractAsset.java index 7da4ba83..5912c2f3 100644 --- a/src/main/java/bisq/asset/AbstractAsset.java +++ b/src/main/java/bisq/asset/AbstractAsset.java @@ -46,4 +46,9 @@ public final String getTickerSymbol() { public final AddressValidationResult validateAddress(String address) { return addressValidator.validate(address); } + + @Override + public String toString() { + return getClass().getName(); + } } diff --git a/src/test/java/bisq/asset/AbstractAssetTest.java b/src/test/java/bisq/asset/AbstractAssetTest.java index 8ecff45a..a658043d 100644 --- a/src/test/java/bisq/asset/AbstractAssetTest.java +++ b/src/test/java/bisq/asset/AbstractAssetTest.java @@ -20,17 +20,16 @@ import bisq.core.btc.BaseCurrencyNetwork; import bisq.core.locale.Res; -import java.util.Optional; - import org.junit.Before; import org.junit.Test; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; public abstract class AbstractAssetTest { + private final AssetRegistry assetRegistry = new AssetRegistry(); + protected final Asset asset; public AbstractAssetTest(Asset asset) { @@ -46,8 +45,8 @@ public void setup() { @Test public void testPresenceInAssetRegistry() { - final Optional optional = new AssetRegistry().stream().filter(this::hasSameTickerSymbol).findFirst(); - assertTrue(optional.isPresent()); + assertThat(asset + " is not registered in META-INF/services/" + Asset.class.getName(), + assetRegistry.stream().anyMatch(this::hasSameTickerSymbol), is(true)); } @Test From 9c7d19e989002887d02d44ee79ff3c0bb1c78160 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 3 Apr 2018 10:18:21 +0200 Subject: [PATCH 100/106] Sort META-INF/services/bisq.asset.Asset --- src/main/resources/META-INF/services/bisq.asset.Asset | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index cc1388c6..3347b2fe 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -1,9 +1,7 @@ +# sorted by `sort --ignore-case` bisq.asset.coins.Achievecoin bisq.asset.coins.Angelcoin bisq.asset.coins.Arto -bisq.asset.coins.BSQ$Mainnet -bisq.asset.coins.BSQ$Regtest -bisq.asset.coins.BSQ$Testnet bisq.asset.coins.Bitcoin$Mainnet bisq.asset.coins.Bitcoin$Regtest bisq.asset.coins.Bitcoin$Testnet @@ -11,6 +9,9 @@ bisq.asset.coins.BitcoinCash bisq.asset.coins.BitcoinClashic bisq.asset.coins.BitcoinGold bisq.asset.coins.BitDaric +bisq.asset.coins.BSQ$Mainnet +bisq.asset.coins.BSQ$Regtest +bisq.asset.coins.BSQ$Testnet bisq.asset.coins.Burstcoin bisq.asset.coins.Byteball bisq.asset.coins.Cagecoin @@ -54,9 +55,9 @@ bisq.asset.coins.Octocoin bisq.asset.coins.Particl bisq.asset.coins.PepeCash bisq.asset.coins.Phore +bisq.asset.coins.PIVX bisq.asset.coins.PostCoin bisq.asset.coins.Pranacoin -bisq.asset.coins.PIVX bisq.asset.coins.ReddCoin bisq.asset.coins.Roicoin bisq.asset.coins.SafeFileSystemCoin From e47d59fb771d4de16cd36c367cd25d2c3047dbd5 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 3 Apr 2018 13:49:07 +0200 Subject: [PATCH 101/106] Polish Byteball --- src/main/java/bisq/asset/coins/Byteball.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/bisq/asset/coins/Byteball.java b/src/main/java/bisq/asset/coins/Byteball.java index 54b9cfcc..d4baec09 100644 --- a/src/main/java/bisq/asset/coins/Byteball.java +++ b/src/main/java/bisq/asset/coins/Byteball.java @@ -65,7 +65,7 @@ public AddressValidationResult validate(String input) { if (!isValidAddress(input)) { return AddressValidationResult.invalidStructure(); } - return AddressValidationResult.validAddress(); + return AddressValidationResult.validAddress(); } private static boolean isValidAddress(String address) { From 1d040a267d207bb88c14bb6bb5b44e271e69ed28 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 3 Apr 2018 11:51:29 +0200 Subject: [PATCH 102/106] Polish CurrencyUtil --- .../java/bisq/core/locale/CurrencyUtil.java | 74 ++++++++----------- 1 file changed, 31 insertions(+), 43 deletions(-) diff --git a/src/main/java/bisq/core/locale/CurrencyUtil.java b/src/main/java/bisq/core/locale/CurrencyUtil.java index 0ad6880c..a4859d2a 100644 --- a/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -45,12 +45,19 @@ public class CurrencyUtil { private static final AssetRegistry assetRegistry = new AssetRegistry(); private static String baseCurrencyCode = "BTC"; + private static List allSortedFiatCurrencies; + private static List allSortedCryptoCurrencies; public static void setBaseCurrencyCode(String baseCurrencyCode) { CurrencyUtil.baseCurrencyCode = baseCurrencyCode; } - private static List allSortedFiatCurrencies; + public static List getAllSortedFiatCurrencies() { + if (Objects.isNull(allSortedFiatCurrencies)) + allSortedFiatCurrencies = createAllSortedFiatCurrenciesList(); + + return allSortedFiatCurrencies; + } private static List createAllSortedFiatCurrenciesList() { Set set = CountryUtil.getAllCountries().stream() @@ -61,14 +68,6 @@ private static List createAllSortedFiatCurrenciesList() { return list; } - public static List getAllSortedFiatCurrencies() { - if (Objects.isNull(allSortedFiatCurrencies)) { - allSortedFiatCurrencies = createAllSortedFiatCurrenciesList(); - } - return allSortedFiatCurrencies; - } - - public static List getMainFiatCurrencies() { TradeCurrency defaultTradeCurrency = getDefaultTradeCurrency(); List list = new ArrayList<>(); @@ -83,7 +82,8 @@ public static List getMainFiatCurrencies() { list.sort(TradeCurrency::compareTo); - FiatCurrency defaultFiatCurrency = defaultTradeCurrency instanceof FiatCurrency ? (FiatCurrency) defaultTradeCurrency : null; + FiatCurrency defaultFiatCurrency = + defaultTradeCurrency instanceof FiatCurrency ? (FiatCurrency) defaultTradeCurrency : null; if (defaultFiatCurrency != null && list.contains(defaultFiatCurrency)) { //noinspection SuspiciousMethodCalls list.remove(defaultTradeCurrency); @@ -92,8 +92,6 @@ public static List getMainFiatCurrencies() { return list; } - private static List allSortedCryptoCurrencies; - public static List getAllSortedCryptoCurrencies() { if (allSortedCryptoCurrencies == null) allSortedCryptoCurrencies = createAllSortedCryptoCurrenciesList(); @@ -147,16 +145,6 @@ public static List getMainCryptoCurrencies() { return result; } - - /** - * @return Sorted list of SEPA currencies with EUR as first item - */ - private static Set getSortedSEPACurrencyCodes() { - return CountryUtil.getAllSepaCountries().stream() - .map(country -> getCurrencyByCountryCode(country.code)) - .collect(Collectors.toSet()); - } - // At OKPay you can exchange internally those currencies public static List getAllOKPayCurrencies() { ArrayList currencies = new ArrayList<>(Arrays.asList( @@ -253,7 +241,10 @@ public static List getAllRevolutCurrencies() { public static boolean isFiatCurrency(String currencyCode) { try { - return currencyCode != null && !currencyCode.isEmpty() && !isCryptoCurrency(currencyCode) && Currency.getInstance(currencyCode) != null; + return currencyCode != null + && !currencyCode.isEmpty() + && !isCryptoCurrency(currencyCode) + && Currency.getInstance(currencyCode) != null; } catch (Throwable t) { return false; } @@ -274,39 +265,36 @@ public static Optional getCryptoCurrency(String currencyCode) { public static Optional getTradeCurrency(String currencyCode) { Optional fiatCurrencyOptional = getFiatCurrency(currencyCode); - if (isFiatCurrency(currencyCode) && fiatCurrencyOptional.isPresent()) { + if (isFiatCurrency(currencyCode) && fiatCurrencyOptional.isPresent()) return Optional.of(fiatCurrencyOptional.get()); - } else { - Optional cryptoCurrencyOptional = getCryptoCurrency(currencyCode); - if (isCryptoCurrency(currencyCode) && cryptoCurrencyOptional.isPresent()) { - return Optional.of(cryptoCurrencyOptional.get()); - } else { - return Optional.empty(); - } - } - } + Optional cryptoCurrencyOptional = getCryptoCurrency(currencyCode); + if (isCryptoCurrency(currencyCode) && cryptoCurrencyOptional.isPresent()) + return Optional.of(cryptoCurrencyOptional.get()); + + return Optional.empty(); + } public static FiatCurrency getCurrencyByCountryCode(String countryCode) { if (countryCode.equals("XK")) return new FiatCurrency("EUR"); - else - return new FiatCurrency(Currency.getInstance(new Locale(LanguageUtil.getDefaultLanguage(), countryCode)).getCurrencyCode()); + + Currency currency = Currency.getInstance(new Locale(LanguageUtil.getDefaultLanguage(), countryCode)); + return new FiatCurrency(currency.getCurrencyCode()); } public static String getNameByCode(String currencyCode) { if (isCryptoCurrency(currencyCode)) return getCryptoCurrency(currencyCode).get().getName(); - else - try { - return Currency.getInstance(currencyCode).getDisplayName(); - } catch (Throwable t) { - log.debug("No currency name available " + t.getMessage()); - return currencyCode; - } - } + try { + return Currency.getInstance(currencyCode).getDisplayName(); + } catch (Throwable t) { + log.debug("No currency name available " + t.getMessage()); + return currencyCode; + } + } public static String getNameAndCode(String currencyCode) { return getNameByCode(currencyCode) + " (" + currencyCode + ")"; From 9dc5b8d289ac4d47dc9dfb33e96af0d62f534767 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 3 Apr 2018 11:51:45 +0200 Subject: [PATCH 103/106] Polish AltCoinAddressValidator --- .../validation/AltCoinAddressValidator.java | 49 +++++-------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java index 0fd2f892..5a8eb443 100644 --- a/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java +++ b/src/main/java/bisq/core/payment/validation/AltCoinAddressValidator.java @@ -27,15 +27,11 @@ import bisq.asset.AssetRegistry; import bisq.asset.Coin; -import org.bitcoinj.core.AddressFormatException; - import com.google.inject.Inject; -import java.util.Optional; - import lombok.extern.slf4j.Slf4j; -import org.jetbrains.annotations.NotNull; +import static java.lang.String.format; @Slf4j public final class AltCoinAddressValidator extends InputValidator { @@ -48,10 +44,6 @@ public AltCoinAddressValidator(AssetRegistry assetRegistry) { this.assetRegistry = assetRegistry; } - /////////////////////////////////////////////////////////////////////////////////////////// - // Public methods - /////////////////////////////////////////////////////////////////////////////////////////// - public void setCurrencyCode(String currencyCode) { this.currencyCode = currencyCode; } @@ -59,36 +51,22 @@ public void setCurrencyCode(String currencyCode) { @Override public ValidationResult validate(String input) { ValidationResult validationResult = super.validate(input); - if (!validationResult.isValid || currencyCode == null) { + if (!validationResult.isValid || currencyCode == null) return validationResult; - } else { - ValidationResult wrongChecksum = new ValidationResult(false, - Res.get("validation.altcoin.wrongChecksum")); - ValidationResult regexTestFailed = new ValidationResult(false, - Res.get("validation.altcoin.wrongStructure", currencyCode)); - - Optional asset = assetRegistry.stream() - .filter(this::assetMatchesSelectedCurrencyCode) - .filter(this::assetIsNotBaseCurrencyForDifferentNetwork) - .findFirst(); - - if (asset.isPresent()) { - AddressValidationResult addressValidationResult = asset.get().validateAddress(input); - if (addressValidationResult.isValid()) - return new ValidationResult(true); + Asset asset = assetRegistry.stream() + .filter(this::assetMatchesSelectedCurrencyCode) + .filter(this::assetIsNotBaseCurrencyForDifferentNetwork) + .findFirst() + .orElseThrow(() -> + new IllegalArgumentException(format("'%s' is not a registered asset", currencyCode))); - return new ValidationResult(false, Res.get(addressValidationResult.getI18nKey(), asset.get().getTickerSymbol(), addressValidationResult.getMessage())); - } + AddressValidationResult result = asset.validateAddress(input); + if (!result.isValid()) + return new ValidationResult(false, + Res.get(result.getI18nKey(), asset.getTickerSymbol(), result.getMessage())); - log.debug("Validation for AltCoinAddress not implemented yet. currencyCode: " + currencyCode); - return validationResult; - } - } - - @NotNull - private String getErrorMessage(AddressFormatException e) { - return Res.get("validation.altcoin.invalidAddress", currencyCode, e.getMessage()); + return new ValidationResult(true); } private boolean assetMatchesSelectedCurrencyCode(Asset a) { @@ -102,5 +80,4 @@ private boolean assetIsNotBaseCurrencyForDifferentNetwork(Asset asset) { || !asset.getTickerSymbol().equals(baseCurrencyNetwork.getCurrencyCode()) || (((Coin) asset).getNetwork().name().equals(baseCurrencyNetwork.getNetwork())); } - } From d7537ae56f2296a3549dad9def506674f88f666f Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 3 Apr 2018 13:24:58 +0200 Subject: [PATCH 104/106] Polish AddressValidationResult --- .../bisq/asset/AddressValidationResult.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main/java/bisq/asset/AddressValidationResult.java b/src/main/java/bisq/asset/AddressValidationResult.java index 2423e4bf..5adb1e80 100644 --- a/src/main/java/bisq/asset/AddressValidationResult.java +++ b/src/main/java/bisq/asset/AddressValidationResult.java @@ -19,18 +19,14 @@ public class AddressValidationResult { - public static AddressValidationResult VALID = new AddressValidationResult(true); + private static AddressValidationResult VALID_ADDRESS = new AddressValidationResult(true, "", ""); private final boolean isValid; - private String message; - private String i18nKey; - - private AddressValidationResult(boolean isValid) { - this.isValid = isValid; - } + private final String message; + private final String i18nKey; private AddressValidationResult(boolean isValid, String message, String i18nKey) { - this(isValid); + this.isValid = isValid; this.message = message; this.i18nKey = i18nKey; } @@ -48,11 +44,11 @@ public String getMessage() { } public static AddressValidationResult validAddress() { - return VALID; + return VALID_ADDRESS; } - public static AddressValidationResult invalidStructure() { - return invalidAddress("", "validation.altcoin.wrongStructure"); + public static AddressValidationResult invalidAddress(Throwable cause) { + return invalidAddress(cause.getMessage()); } public static AddressValidationResult invalidAddress(String cause) { @@ -63,7 +59,7 @@ public static AddressValidationResult invalidAddress(String cause, String i18nKe return new AddressValidationResult(false, cause, i18nKey); } - public static AddressValidationResult invalidAddress(Throwable cause) { - return invalidAddress(cause.getMessage()); + public static AddressValidationResult invalidStructure() { + return invalidAddress("", "validation.altcoin.wrongStructure"); } } From 990070ff379d46b42f47937b02ac586aa7c531a1 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 3 Apr 2018 13:25:13 +0200 Subject: [PATCH 105/106] Add Javadoc for bisq.asset types --- src/main/java/bisq/asset/AbstractAsset.java | 8 ++++ .../bisq/asset/AddressValidationResult.java | 8 ++++ .../java/bisq/asset/AddressValidator.java | 6 +++ src/main/java/bisq/asset/Asset.java | 19 ++++++++++ src/main/java/bisq/asset/AssetRegistry.java | 8 ++++ .../asset/Base58BitcoinAddressValidator.java | 7 ++++ src/main/java/bisq/asset/Coin.java | 17 +++++++++ .../bisq/asset/DefaultAddressValidator.java | 11 ++++++ src/main/java/bisq/asset/Erc20Token.java | 8 ++++ .../bisq/asset/EtherAddressValidator.java | 12 +++++- .../bisq/asset/NetworkParametersAdapter.java | 11 +++++- .../bisq/asset/RegexAddressValidator.java | 6 +++ src/main/java/bisq/asset/Token.java | 12 ++++++ src/main/java/bisq/asset/package-info.java | 37 +++++++++++++++++++ .../java/bisq/asset/AbstractAssetTest.java | 17 +++++++++ ...AbstractAssetWithDefaultValidatorTest.java | 9 +++++ 16 files changed, 193 insertions(+), 3 deletions(-) create mode 100644 src/main/java/bisq/asset/package-info.java diff --git a/src/main/java/bisq/asset/AbstractAsset.java b/src/main/java/bisq/asset/AbstractAsset.java index 5912c2f3..3cabaa2e 100644 --- a/src/main/java/bisq/asset/AbstractAsset.java +++ b/src/main/java/bisq/asset/AbstractAsset.java @@ -20,6 +20,14 @@ import static org.apache.commons.lang3.Validate.notBlank; import static org.apache.commons.lang3.Validate.notNull; +/** + * Abstract base class for {@link Asset} implementations. Most implementations should not + * extend this class directly, but should rather extend {@link Coin}, {@link Token} or one + * of their subtypes. + * + * @author Chris Beams + * @since 0.7.0 + */ public abstract class AbstractAsset implements Asset { private final String name; diff --git a/src/main/java/bisq/asset/AddressValidationResult.java b/src/main/java/bisq/asset/AddressValidationResult.java index 5adb1e80..04abb184 100644 --- a/src/main/java/bisq/asset/AddressValidationResult.java +++ b/src/main/java/bisq/asset/AddressValidationResult.java @@ -17,6 +17,14 @@ package bisq.asset; +/** + * Value object representing the result of validating an {@link Asset} address. Various + * factory methods are provided for typical use cases. + * + * @author Chris Beams + * @since 0.7.0 + * @see Asset#validateAddress(String) + */ public class AddressValidationResult { private static AddressValidationResult VALID_ADDRESS = new AddressValidationResult(true, "", ""); diff --git a/src/main/java/bisq/asset/AddressValidator.java b/src/main/java/bisq/asset/AddressValidator.java index 0fe72cd2..8cf65608 100644 --- a/src/main/java/bisq/asset/AddressValidator.java +++ b/src/main/java/bisq/asset/AddressValidator.java @@ -17,6 +17,12 @@ package bisq.asset; +/** + * An {@link Asset} address validation function. + * + * @author Chris Beams + * @since 0.7.0 + */ public interface AddressValidator { AddressValidationResult validate(String address); diff --git a/src/main/java/bisq/asset/Asset.java b/src/main/java/bisq/asset/Asset.java index 2db6300e..b67d0376 100644 --- a/src/main/java/bisq/asset/Asset.java +++ b/src/main/java/bisq/asset/Asset.java @@ -17,6 +17,25 @@ package bisq.asset; +/** + * Interface representing a given ("crypto") asset in its most abstract form, having a + * {@link #getName() name}, e.g. "Bitcoin", a {@link #getTickerSymbol() ticker symbol}, + * e.g. "BTC", and an address validation function. Together, these properties represent + * the minimum information and functionality required to register and trade an asset on + * the Bisq network. + *

+ * Implementations typically extend either the {@link Coin} or {@link Token} base + * classes, and must be registered in the {@code META-INF/services/bisq.asset.Asset} file + * in order to be available in the {@link AssetRegistry} at runtime. + * + * @author Chris Beams + * @since 0.7.0 + * @see AbstractAsset + * @see Coin + * @see Token + * @see Erc20Token + * @see AssetRegistry + */ public interface Asset { String getName(); diff --git a/src/main/java/bisq/asset/AssetRegistry.java b/src/main/java/bisq/asset/AssetRegistry.java index eddb0827..c6a0c7b3 100644 --- a/src/main/java/bisq/asset/AssetRegistry.java +++ b/src/main/java/bisq/asset/AssetRegistry.java @@ -22,6 +22,14 @@ import java.util.ServiceLoader; import java.util.stream.Stream; +/** + * Provides {@link Stream}-based access to {@link Asset} implementations registered in + * the {@code META-INF/services/bisq.asset.Asset} provider-configuration file. + * + * @author Chris Beams + * @since 0.7.0 + * @see ServiceLoader + */ public class AssetRegistry { private static final List registeredAssets = new ArrayList<>(); diff --git a/src/main/java/bisq/asset/Base58BitcoinAddressValidator.java b/src/main/java/bisq/asset/Base58BitcoinAddressValidator.java index 616bbbab..9a99385f 100644 --- a/src/main/java/bisq/asset/Base58BitcoinAddressValidator.java +++ b/src/main/java/bisq/asset/Base58BitcoinAddressValidator.java @@ -22,6 +22,13 @@ import org.bitcoinj.core.NetworkParameters; import org.bitcoinj.params.MainNetParams; +/** + * {@link AddressValidator} for Base58-encoded Bitcoin addresses. + * + * @author Chris Beams + * @since 0.7.0 + * @see org.bitcoinj.core.Address#fromBase58(NetworkParameters, String) + */ public class Base58BitcoinAddressValidator implements AddressValidator { private final NetworkParameters networkParameters; diff --git a/src/main/java/bisq/asset/Coin.java b/src/main/java/bisq/asset/Coin.java index 19cf8838..5eb596e4 100644 --- a/src/main/java/bisq/asset/Coin.java +++ b/src/main/java/bisq/asset/Coin.java @@ -17,6 +17,23 @@ package bisq.asset; +/** + * Abstract base class for {@link Asset}s with their own dedicated blockchain, such as + * {@link bisq.asset.coins.Bitcoin} itself or one of its many derivatives, competitors and + * alternatives, often called "altcoins", such as {@link bisq.asset.coins.Litecoin}, + * {@link bisq.asset.coins.Ether}, {@link bisq.asset.coins.Monero} and + * {@link bisq.asset.coins.Zcash}. + *

+ * In addition to the usual {@code Asset} properties, a {@code Coin} maintains information + * about which {@link Network} it may be used on. By default, coins are constructed with + * the assumption they are for use on that coin's "main network", or "main blockchain", + * i.e. that they are "real" coins for use in a production environment. In testing + * scenarios, however, a coin may be constructed for use only on "testnet" or "regtest" + * networks. + * + * @author Chris Beams + * @since 0.7.0 + */ public abstract class Coin extends AbstractAsset { public enum Network { MAINNET, TESTNET, REGTEST } diff --git a/src/main/java/bisq/asset/DefaultAddressValidator.java b/src/main/java/bisq/asset/DefaultAddressValidator.java index 2b45cf1c..17131035 100644 --- a/src/main/java/bisq/asset/DefaultAddressValidator.java +++ b/src/main/java/bisq/asset/DefaultAddressValidator.java @@ -17,6 +17,17 @@ package bisq.asset; +/** + * {@link AddressValidator} for use when no more specific address validation function is + * available. This implementation only checks that a given address is non-null and + * non-empty; it exists for legacy purposes and is deprecated to indicate that new + * {@link Asset} implementations should NOT use it, but should rather provide their own + * {@link AddressValidator} implementation. + * + * @author Chris Beams + * @author Bernard Labno + * @since 0.7.0 + */ @Deprecated public class DefaultAddressValidator implements AddressValidator { diff --git a/src/main/java/bisq/asset/Erc20Token.java b/src/main/java/bisq/asset/Erc20Token.java index 86a33e3c..33213a65 100644 --- a/src/main/java/bisq/asset/Erc20Token.java +++ b/src/main/java/bisq/asset/Erc20Token.java @@ -17,6 +17,14 @@ package bisq.asset; +/** + * Abstract base class for Ethereum-based {@link Token}s that implement the + * ERC-20 Token + * Standard. + * + * @author Chris Beams + * @since 0.7.0 + */ public abstract class Erc20Token extends Token { public Erc20Token(String name, String tickerSymbol) { diff --git a/src/main/java/bisq/asset/EtherAddressValidator.java b/src/main/java/bisq/asset/EtherAddressValidator.java index 10d5003c..f646ed57 100644 --- a/src/main/java/bisq/asset/EtherAddressValidator.java +++ b/src/main/java/bisq/asset/EtherAddressValidator.java @@ -17,10 +17,20 @@ package bisq.asset; +/** + * Validates an Ethereum address using the regular expression on record in the + * + * ethereum/web3.js project. Note that this implementation is widely used, not just + * for actual {@link bisq.asset.coins.Ether} address validation, but also for + * {@link Erc20Token} implementations and other Ethereum-based {@link Asset} + * implementations. + * + * @author Chris Beams + * @since 0.7.0 + */ public class EtherAddressValidator extends RegexAddressValidator { public EtherAddressValidator() { - // https://github.com/ethereum/web3.js/blob/master/lib/utils/utils.js#L403 super("^(0x)?[0-9a-fA-F]{40}$"); } } diff --git a/src/main/java/bisq/asset/NetworkParametersAdapter.java b/src/main/java/bisq/asset/NetworkParametersAdapter.java index 62ed257b..184b7dbf 100644 --- a/src/main/java/bisq/asset/NetworkParametersAdapter.java +++ b/src/main/java/bisq/asset/NetworkParametersAdapter.java @@ -24,9 +24,16 @@ import org.bitcoinj.core.StoredBlock; import org.bitcoinj.core.VerificationException; import org.bitcoinj.store.BlockStore; -import org.bitcoinj.store.BlockStoreException; import org.bitcoinj.utils.MonetaryFormat; +/** + * Convenient abstract {@link NetworkParameters} base class providing no-op + * implementations of all methods that are not required for address validation + * purposes. + * + * @author Chris Beams + * @since 0.7.0 + */ public abstract class NetworkParametersAdapter extends NetworkParameters { @Override @@ -36,7 +43,7 @@ public String getPaymentProtocolId() { @Override public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) - throws VerificationException, BlockStoreException { + throws VerificationException { } @Override diff --git a/src/main/java/bisq/asset/RegexAddressValidator.java b/src/main/java/bisq/asset/RegexAddressValidator.java index 1855b068..38b5f13d 100644 --- a/src/main/java/bisq/asset/RegexAddressValidator.java +++ b/src/main/java/bisq/asset/RegexAddressValidator.java @@ -17,6 +17,12 @@ package bisq.asset; +/** + * Validates an {@link Asset} address against a given regular expression. + * + * @author Chris Beams + * @since 0.7.0 + */ public class RegexAddressValidator implements AddressValidator { private final String regex; diff --git a/src/main/java/bisq/asset/Token.java b/src/main/java/bisq/asset/Token.java index 215c87a3..2c162e52 100644 --- a/src/main/java/bisq/asset/Token.java +++ b/src/main/java/bisq/asset/Token.java @@ -17,6 +17,18 @@ package bisq.asset; +/** + * Abstract base class for {@link Asset}s that do not have their own dedicated blockchain, + * but are rather based on or derived from another blockchain. Contrast with {@link Coin}. + * Note that this is essentially a "marker" base class in the sense that it (currently) + * exposes no additional information or functionality beyond that found in + * {@link AbstractAsset}, but it is nevertheless useful in distinguishing between major + * different {@code Asset} types. + * + * @author Chris Beams + * @since 0.7.0 + * @see Erc20Token + */ public abstract class Token extends AbstractAsset { public Token(String name, String tickerSymbol, AddressValidator addressValidator) { diff --git a/src/main/java/bisq/asset/package-info.java b/src/main/java/bisq/asset/package-info.java new file mode 100644 index 00000000..b466aedf --- /dev/null +++ b/src/main/java/bisq/asset/package-info.java @@ -0,0 +1,37 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +/** + * Bisq's family of abstractions representing different ("crypto") + * {@link bisq.asset.Asset} types such as {@link bisq.asset.Coin}, + * {@link bisq.asset.Token} and {@link bisq.asset.Erc20Token}, as well as concrete + * implementations of each, such as {@link bisq.asset.coins.Bitcoin} itself, altcoins like + * {@link bisq.asset.coins.Litecoin} and {@link bisq.asset.coins.Ether} and tokens like + * {@link bisq.asset.tokens.DaiStablecoin}. + *

+ * The purpose of this package is to provide everything necessary for registering + * ("listing") new assets and managing / accessing those assets within, e.g. the Bisq + * Desktop UI. + *

+ * Note that everything within this package is intentionally designed to be simple and + * low-level with no dependencies on any other Bisq packages or components. + * + * @author Chris Beams + * @since 0.7.0 + */ + +package bisq.asset; diff --git a/src/test/java/bisq/asset/AbstractAssetTest.java b/src/test/java/bisq/asset/AbstractAssetTest.java index a658043d..5965e55f 100644 --- a/src/test/java/bisq/asset/AbstractAssetTest.java +++ b/src/test/java/bisq/asset/AbstractAssetTest.java @@ -26,6 +26,23 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; +/** + * Abstract base class for all {@link Asset} unit tests. Subclasses must implement the + * {@link #testValidAddresses()} and {@link #testInvalidAddresses()} methods, and are + * expected to use the convenient {@link #assertValidAddress(String)} and + * {@link #assertInvalidAddress(String)} assertions when doing so. + *

+ * Blank / empty addresses are tested automatically by this base class and are always + * considered invalid. + *

+ * This base class also serves as a kind of integration test for {@link AssetRegistry}, in + * that all assets tested through subclasses are tested to make sure they are also + * properly registered and available there. + * + * @author Chris Beams + * @author Bernard Labno + * @since 0.7.0 + */ public abstract class AbstractAssetTest { private final AssetRegistry assetRegistry = new AssetRegistry(); diff --git a/src/test/java/bisq/asset/AbstractAssetWithDefaultValidatorTest.java b/src/test/java/bisq/asset/AbstractAssetWithDefaultValidatorTest.java index db5bb82b..9522298d 100644 --- a/src/test/java/bisq/asset/AbstractAssetWithDefaultValidatorTest.java +++ b/src/test/java/bisq/asset/AbstractAssetWithDefaultValidatorTest.java @@ -19,6 +19,15 @@ import org.junit.Test; +/** + * Convenient abstract base class for {@link Asset} implementations still using the + * deprecated {@link DefaultAddressValidator}. + * + * @author Bernard Labno + * @since 0.7.0 + * @see DefaultAddressValidator + */ +@Deprecated public abstract class AbstractAssetWithDefaultValidatorTest extends AbstractAssetTest { public AbstractAssetWithDefaultValidatorTest(Asset asset) { From 2f231d35557330cad004c0f48e2e6ec3f74e6312 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 3 Apr 2018 13:31:19 +0200 Subject: [PATCH 106/106] Document META-INF/services/bisq.asset.Asset --- src/main/resources/META-INF/services/bisq.asset.Asset | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/resources/META-INF/services/bisq.asset.Asset b/src/main/resources/META-INF/services/bisq.asset.Asset index 3347b2fe..0149777e 100644 --- a/src/main/resources/META-INF/services/bisq.asset.Asset +++ b/src/main/resources/META-INF/services/bisq.asset.Asset @@ -1,4 +1,9 @@ -# sorted by `sort --ignore-case` +# +# This file lists all assets available for trading on the Bisq network. +# Contents are sorted according to the output of `sort --ignore-case`. +# See bisq.asset.Asset and bisq.asset.AssetRegistry for further details. +# See https://bisq.network/list-asset for complete instructions. +# bisq.asset.coins.Achievecoin bisq.asset.coins.Angelcoin bisq.asset.coins.Arto