diff --git a/core/src/main/java/io/bitsquare/locale/CurrencyUtil.java b/core/src/main/java/io/bitsquare/locale/CurrencyUtil.java
index f05b59e814..5bae7d4eac 100644
--- a/core/src/main/java/io/bitsquare/locale/CurrencyUtil.java
+++ b/core/src/main/java/io/bitsquare/locale/CurrencyUtil.java
@@ -132,6 +132,7 @@ public class CurrencyUtil {
result.add(new CryptoCurrency("HODL", "HOdlcoin"));
result.add(new CryptoCurrency("HNC", "HunCoin"));
result.add(new CryptoCurrency("IOC", "I/O Coin"));
+ result.add(new CryptoCurrency("IOP", "Fermat"));
result.add(new CryptoCurrency("JPYT", "JPY Tether"));
result.add(new CryptoCurrency("JBS", "Jumbucks"));
result.add(new CryptoCurrency("LBC", "LBRY Credits"));
diff --git a/gui/src/main/java/io/bitsquare/gui/util/validation/AltCoinAddressValidator.java b/gui/src/main/java/io/bitsquare/gui/util/validation/AltCoinAddressValidator.java
index 3b76ae98e4..f1f87fc717 100644
--- a/gui/src/main/java/io/bitsquare/gui/util/validation/AltCoinAddressValidator.java
+++ b/gui/src/main/java/io/bitsquare/gui/util/validation/AltCoinAddressValidator.java
@@ -18,6 +18,11 @@
package io.bitsquare.gui.util.validation;
+import io.bitsquare.gui.util.validation.params.IOPParams;
+import org.bitcoinj.core.Address;
+import org.bitcoinj.core.AddressFormatException;
+import org.bitcoinj.params.MainNetParams;
+import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,7 +51,7 @@ public final class AltCoinAddressValidator extends InputValidator {
// 2: If the address contains a checksum, verify the checksum
ValidationResult wrongChecksum = new ValidationResult(false, "Address validation failed because checksum was not correct.");
- ValidationResult wrongStructure = new ValidationResult(false, "Address validation failed because it does not match the structure of a " + currencyCode + " address.");
+ ValidationResult regexTestFailed = new ValidationResult(false, "Address validation failed because it does not match the structure of a " + currencyCode + " address.");
switch (currencyCode) {
// Example for BTC, though for BTC we use the BitcoinJ library address check
@@ -55,11 +60,31 @@ public final class AltCoinAddressValidator extends InputValidator {
// taken form: https://stackoverflow.com/questions/21683680/regex-to-match-bitcoin-addresses
if (input.matches("^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$")) {
if (verifyChecksum(input))
- return new ValidationResult(true);
+ try {
+ new Address(MainNetParams.get(), input);
+ return new ValidationResult(true);
+ } catch (AddressFormatException e) {
+ return new ValidationResult(false, getErrorMessage(e));
+ }
else
- return wrongStructure;
+ return wrongChecksum;
} else {
- return wrongChecksum;
+ return regexTestFailed;
+ }
+ case "IOP":
+ if (input.matches("^[p][a-km-zA-HJ-NP-Z1-9]{25,34}$")) {
+ if (verifyChecksum(input)) {
+ try {
+ new Address(IOPParams.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)
@@ -74,6 +99,11 @@ public final class AltCoinAddressValidator extends InputValidator {
}
}
+ @NotNull
+ private String getErrorMessage(AddressFormatException e) {
+ return "Address is not a valid " + currencyCode + " address! " + e.getMessage();
+ }
+
private boolean verifyChecksum(String input) {
// TODO
return true;
diff --git a/gui/src/main/java/io/bitsquare/gui/util/validation/params/IOPParams.java b/gui/src/main/java/io/bitsquare/gui/util/validation/params/IOPParams.java
new file mode 100644
index 0000000000..46df44373a
--- /dev/null
+++ b/gui/src/main/java/io/bitsquare/gui/util/validation/params/IOPParams.java
@@ -0,0 +1,78 @@
+/*
+ * This file is part of Bitsquare.
+ *
+ * Bitsquare 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.
+ *
+ * Bitsquare 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 Bitsquare. If not, see .
+ */
+
+package io.bitsquare.gui.util.validation.params;
+
+import org.bitcoinj.core.*;
+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;
+ }
+}
diff --git a/gui/src/test/java/io/bitsquare/gui/util/validation/AltCoinAddressValidatorTest.java b/gui/src/test/java/io/bitsquare/gui/util/validation/AltCoinAddressValidatorTest.java
index 2c214ad10e..e2a1d7abf5 100644
--- a/gui/src/test/java/io/bitsquare/gui/util/validation/AltCoinAddressValidatorTest.java
+++ b/gui/src/test/java/io/bitsquare/gui/util/validation/AltCoinAddressValidatorTest.java
@@ -39,4 +39,15 @@ public class AltCoinAddressValidatorTest {
assertFalse(validator.validate("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhek#").isValid);
}
+ @Test
+ public void testIOP() {
+ AltCoinAddressValidator validator = new AltCoinAddressValidator();
+ validator.setCurrencyCode("IOP");
+
+ assertTrue(validator.validate("pKbz7iRUSiUaTgh4UuwQCnc6pWZnyCGWxM").isValid);
+ assertTrue(validator.validate("pAubDQFjUMaR93V4RjHYFh1YW1dzJ9YPW1").isValid);
+
+ assertFalse(validator.validate("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem").isValid);
+ }
+
}
diff --git a/pom.xml b/pom.xml
index 3e556c82e3..1593336acf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,196 +1,196 @@
-
-
- 4.0.0
-
- io.bitsquare
- parent
- pom
- 0.4.9.8
- Bitsquare - The decentralized bitcoin exchange
- https://bitsquare.io
-
-
- bitsquare.io
-
-
-
-
- GNU AFFERO GENERAL PUBLIC LICENSE
- http://www.gnu.org/licenses/agpl-3.0.html
- repo
-
-
-
-
- GitHub
- https://github.com/bitsquare/bitsquare/issues
-
-
-
- scm:git:https://github.com/bitsquare/bitsquare
- scm:git:https://github.com/bitsquare/bitsquare
- scm:git:https://github.com/bitsquare/bitsquare
-
-
-
- UTF-8
-
-
-
- common
- core
- jsocks
- jtorctl
- jtorproxy
- network
- gui
- headless
- seednode
- monitor
- statistics
- pricefeed
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.1
-
- 1.8
- 1.8
-
-
-
-
-
-
-
-
-
-
- sonatype-oss-snapshot
-
- https://oss.sonatype.org/content/repositories/snapshots
-
-
-
-
-
-
- org.bitcoinj
- bitcoinj-core
- 0.13.1.7
-
-
-
-
- com.google.inject
- guice
- 3.0
-
-
-
-
- org.bouncycastle
- bcprov-jdk15on
- 1.53
-
-
-
-
- commons-io
- commons-io
- 2.4
-
-
- org.apache.commons
- commons-lang3
- 3.4
-
-
- com.google.guava
- guava
- 18.0
-
-
- org.fxmisc.easybind
- easybind
- 1.0.3
-
-
- org.reactfx
- reactfx
- 2.0-SNAPSHOT
-
-
- org.jetbrains
- annotations
- 13.0
-
-
- com.google.code.findbugs
- jsr305
- 3.0.1
-
-
-
-
- org.slf4j
- slf4j-api
- 1.7.12
-
-
- ch.qos.logback
- logback-core
- 1.1.3
-
-
- ch.qos.logback
- logback-classic
- 1.1.3
-
-
-
-
- junit
- junit
- 4.11
- test
-
-
- org.mockito
- mockito-core
- 1.10.19
- test
-
-
- org.springframework
- spring-test
- 4.1.1.RELEASE
- test
-
-
-
+
+
+ 4.0.0
+
+ io.bitsquare
+ parent
+ pom
+ 0.4.9.8
+ Bitsquare - The decentralized bitcoin exchange
+ https://bitsquare.io
+
+
+ bitsquare.io
+
+
+
+
+ GNU AFFERO GENERAL PUBLIC LICENSE
+ http://www.gnu.org/licenses/agpl-3.0.html
+ repo
+
+
+
+
+ GitHub
+ https://github.com/bitsquare/bitsquare/issues
+
+
+
+ scm:git:https://github.com/bitsquare/bitsquare
+ scm:git:https://github.com/bitsquare/bitsquare
+ scm:git:https://github.com/bitsquare/bitsquare
+
+
+
+ UTF-8
+
+
+
+ common
+ core
+ jsocks
+ jtorctl
+ jtorproxy
+ network
+ gui
+ headless
+ seednode
+ monitor
+ statistics
+ pricefeed
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.1
+
+ 1.8
+ 1.8
+
+
+
+
+
+
+
+
+
+
+ sonatype-oss-snapshot
+
+ https://oss.sonatype.org/content/repositories/snapshots
+
+
+
+
+
+
+ org.bitcoinj
+ bitcoinj-core
+ 0.13.1.7
+
+
+
+
+ com.google.inject
+ guice
+ 3.0
+
+
+
+
+ org.bouncycastle
+ bcprov-jdk15on
+ 1.53
+
+
+
+
+ commons-io
+ commons-io
+ 2.4
+
+
+ org.apache.commons
+ commons-lang3
+ 3.4
+
+
+ com.google.guava
+ guava
+ 18.0
+
+
+ org.fxmisc.easybind
+ easybind
+ 1.0.3
+
+
+ org.reactfx
+ reactfx
+ 2.0-SNAPSHOT
+
+
+ org.jetbrains
+ annotations
+ 13.0
+
+
+ com.google.code.findbugs
+ jsr305
+ 3.0.1
+
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.12
+
+
+ ch.qos.logback
+ logback-core
+ 1.1.3
+
+
+ ch.qos.logback
+ logback-classic
+ 1.1.3
+
+
+
+
+ junit
+ junit
+ 4.11
+ test
+
+
+ org.mockito
+ mockito-core
+ 1.10.19
+ test
+
+
+ org.springframework
+ spring-test
+ 4.1.1.RELEASE
+ test
+
+
+