fix merge errors - deleted files

This commit is contained in:
Mike Rosseel 2017-06-30 16:53:18 +02:00
parent cdc9649dd2
commit ad742403c9
8 changed files with 654 additions and 5 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>io.bisq</groupId>
<version>0.5.0.0</version>
<version>0.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -118,12 +118,10 @@
<groupId>jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
<!--
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</exclusion>
-->
</exclusions>
</dependency>
<dependency>
@ -227,7 +225,7 @@
<dependency>
<groupId>io.bisq</groupId>
<artifactId>core</artifactId>
<version>0.5.0.0</version>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -71,7 +71,7 @@ public class BitsquareProxy {
public CurrencyList getCurrencyList() {
CurrencyList currencyList = new CurrencyList();
CurrencyUtil.getAllSortedCryptoCurrencies().forEach(cryptoCurrency -> currencyList.add(cryptoCurrency.getCode(), cryptoCurrency.getName(), "crypto"));
CurrencyUtil.getAllSortedFiatCurrencies().forEach(cryptoCurrency -> currencyList.add(cryptoCurrency.getSymbol(), cryptoCurrency.getName(), "fiat"));
CurrencyUtil.getAllSortedFiatCurrencies().forEach(fiatCurrency -> currencyList.add(fiatCurrency.getCurrency().getSymbol(), fiatCurrency.getName(), "fiat"));
Collections.sort(currencyList.currencies, (io.bisq.api.api.Currency p1, io.bisq.api.api.Currency p2) -> p1.name.compareTo(p2.name));
return currencyList;
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
package io.bisq.core.payment;
import io.bisq.core.payment.payload.BankAccountPayload;
import io.bisq.core.payment.payload.NationalBankAccountPayload;
import io.bisq.core.payment.payload.PaymentAccountPayload;
import io.bisq.core.payment.payload.PaymentMethod;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
public final class NationalBankAccount extends CountryBasedPaymentAccount implements SameCountryRestrictedBankAccount {
public NationalBankAccount() {
super(PaymentMethod.NATIONAL_BANK);
}
@Override
protected PaymentAccountPayload getPayload() {
return new NationalBankAccountPayload(paymentMethod.getId(), id, paymentMethod.getMaxTradePeriod());
}
@Override
public String getBankId() {
return ((BankAccountPayload) paymentAccountPayload).getBankId();
}
@Override
public String getCountryCode() {
return getCountry() != null ? getCountry().code : "";
}
public void setEmail(String value) {
((BankAccountPayload) paymentAccountPayload).setEmail(value);
}
public String getEmail() {
return ((BankAccountPayload) paymentAccountPayload).getEmail();
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
package io.bisq.core.payment;
import io.bisq.core.payment.payload.BankAccountPayload;
import io.bisq.core.payment.payload.PaymentAccountPayload;
import io.bisq.core.payment.payload.PaymentMethod;
import io.bisq.core.payment.payload.SameBankAccountPayload;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
public final class SameBankAccount extends CountryBasedPaymentAccount implements BankNameRestrictedBankAccount, SameCountryRestrictedBankAccount {
public SameBankAccount() {
super(PaymentMethod.SAME_BANK);
}
@Override
protected PaymentAccountPayload getPayload() {
return new SameBankAccountPayload(paymentMethod.getId(), id, paymentMethod.getMaxTradePeriod());
}
@Override
public String getBankId() {
return ((BankAccountPayload) paymentAccountPayload).getBankId();
}
@Override
public String getCountryCode() {
return getCountry() != null ? getCountry().code : "";
}
public void setEmail(String value) {
((BankAccountPayload) paymentAccountPayload).setEmail(value);
}
public String getEmail() {
return ((BankAccountPayload) paymentAccountPayload).getEmail();
}
}

View File

@ -0,0 +1,60 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package io.bisq.core.payment;
import io.bisq.core.payment.payload.BankAccountPayload;
import io.bisq.core.payment.payload.PaymentAccountPayload;
import io.bisq.core.payment.payload.PaymentMethod;
import io.bisq.core.payment.payload.SpecificBanksAccountPayload;
import lombok.EqualsAndHashCode;
import java.util.ArrayList;
@EqualsAndHashCode(callSuper = true)
public final class SpecificBanksAccount extends CountryBasedPaymentAccount implements BankNameRestrictedBankAccount, SameCountryRestrictedBankAccount {
public SpecificBanksAccount() {
super(PaymentMethod.SPECIFIC_BANKS);
}
@Override
protected PaymentAccountPayload getPayload() {
return new SpecificBanksAccountPayload(paymentMethod.getId(), id, paymentMethod.getMaxTradePeriod());
}
public ArrayList<String> getAcceptedBanks() {
return ((SpecificBanksAccountPayload) paymentAccountPayload).getAcceptedBanks();
}
@Override
public String getBankId() {
return ((SpecificBanksAccountPayload) paymentAccountPayload).getBankId();
}
@Override
public String getCountryCode() {
return getCountry() != null ? getCountry().code : "";
}
public void setEmail(String value) {
((BankAccountPayload) paymentAccountPayload).setEmail(value);
}
public String getEmail() {
return ((BankAccountPayload) paymentAccountPayload).getEmail();
}
}

View File

@ -0,0 +1,142 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package io.bisq.gui.components.paymentmethods;
import io.bisq.common.locale.Res;
import io.bisq.common.locale.TradeCurrency;
import io.bisq.core.payment.FasterPaymentsAccount;
import io.bisq.core.payment.PaymentAccount;
import io.bisq.core.payment.payload.FasterPaymentsAccountPayload;
import io.bisq.core.payment.payload.PaymentAccountPayload;
import io.bisq.gui.components.InputTextField;
import io.bisq.gui.util.BSFormatter;
import io.bisq.gui.util.Layout;
import io.bisq.gui.util.validation.AccountNrValidator;
import io.bisq.gui.util.validation.BranchIdValidator;
import io.bisq.gui.util.validation.EmailValidator;
import io.bisq.gui.util.validation.InputValidator;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static io.bisq.gui.util.FormBuilder.*;
public class FasterPaymentsForm extends PaymentMethodForm {
private static final Logger log = LoggerFactory.getLogger(FasterPaymentsForm.class);
public static int addFormForBuyer(GridPane gridPane, int gridRow,
PaymentAccountPayload paymentAccountPayload) {
// do not translate as it is used in english only
addLabelTextField(gridPane, ++gridRow, "UK sort code:",
((FasterPaymentsAccountPayload) paymentAccountPayload).getSortCode());
addLabelTextField(gridPane, ++gridRow, Res.get("payment.accountNr"),
((FasterPaymentsAccountPayload) paymentAccountPayload).getAccountNr());
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.email"),
((FasterPaymentsAccountPayload) paymentAccountPayload).getEmail());
return gridRow;
}
private final FasterPaymentsAccount fasterPaymentsAccount;
private InputTextField accountNrInputTextField;
private InputTextField sortCodeInputTextField;
private final EmailValidator emailValidator;
public FasterPaymentsForm(PaymentAccount paymentAccount, InputValidator inputValidator, GridPane gridPane,
int gridRow, BSFormatter formatter) {
super(paymentAccount, inputValidator, gridPane, gridRow, formatter);
this.fasterPaymentsAccount = (FasterPaymentsAccount) paymentAccount;
emailValidator = new EmailValidator();
}
@Override
public void addFormForAddAccount() {
gridRowFrom = gridRow + 1;
// do not translate as it is used in english only
sortCodeInputTextField = addLabelInputTextField(gridPane, ++gridRow, "UK sort code:").second;
sortCodeInputTextField.setValidator(inputValidator);
sortCodeInputTextField.setValidator(new BranchIdValidator("GB"));
sortCodeInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
fasterPaymentsAccount.setSortCode(newValue);
updateFromInputs();
});
accountNrInputTextField = addLabelInputTextField(gridPane, ++gridRow, Res.get("payment.accountNr")).second;
accountNrInputTextField.setValidator(new AccountNrValidator("GB"));
accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
fasterPaymentsAccount.setAccountNr(newValue);
updateFromInputs();
});
InputTextField emailTextField = addLabelInputTextField(gridPane,
++gridRow, Res.get("payment.email")).second;
emailTextField.textProperty().addListener((ov, oldValue, newValue) -> {
fasterPaymentsAccount.setEmail(newValue);
updateFromInputs();
});
emailTextField.setValidator(emailValidator);
TradeCurrency singleTradeCurrency = fasterPaymentsAccount.getSingleTradeCurrency();
String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "";
addLabelTextField(gridPane, ++gridRow, Res.getWithCol("shared.currency"),
nameAndCode);
addAllowedPeriod();
addAccountNameTextFieldWithAutoFillCheckBox();
}
@Override
protected void autoFillNameTextField() {
if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) {
String accountNr = accountNrInputTextField.getText();
accountNr = StringUtils.abbreviate(accountNr, 9);
String method = Res.get(paymentAccount.getPaymentMethod().getId());
accountNameTextField.setText(method.concat(": ").concat(accountNr));
}
}
@Override
public void addFormForDisplayAccount() {
gridRowFrom = gridRow;
addLabelTextField(gridPane, gridRow, Res.get("payment.account.name"),
fasterPaymentsAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
addLabelTextField(gridPane, ++gridRow, Res.getWithCol("shared.paymentMethod"),
Res.get(fasterPaymentsAccount.getPaymentMethod().getId()));
// do not translate as it is used in english only
addLabelTextField(gridPane, ++gridRow, "UK sort code:", fasterPaymentsAccount.getSortCode());
TextField field = addLabelTextField(gridPane, ++gridRow, Res.get("payment.accountNr"),
fasterPaymentsAccount.getAccountNr()).second;
field.setMouseTransparent(false);
addLabelTextField(gridPane, ++gridRow, Res.get("payment.email"), fasterPaymentsAccount.getEmail());
TradeCurrency singleTradeCurrency = fasterPaymentsAccount.getSingleTradeCurrency();
String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "";
addLabelTextField(gridPane, ++gridRow, Res.getWithCol("shared.currency"), nameAndCode);
addAllowedPeriod();
}
@Override
public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid()
&& emailValidator.validate(fasterPaymentsAccount.getEmail()).isValid
&& sortCodeInputTextField.getValidator().validate(fasterPaymentsAccount.getSortCode()).isValid
&& accountNrInputTextField.getValidator().validate(fasterPaymentsAccount.getAccountNr()).isValid
&& fasterPaymentsAccount.getTradeCurrencies().size() > 0);
}
}

View File

@ -0,0 +1,104 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package io.bisq.gui.components.paymentmethods;
import io.bisq.common.locale.BankUtil;
import io.bisq.common.locale.Res;
import io.bisq.common.util.Tuple2;
import io.bisq.core.payment.CountryBasedPaymentAccount;
import io.bisq.core.payment.PaymentAccount;
import io.bisq.core.payment.payload.PaymentAccountPayload;
import io.bisq.gui.components.InputTextField;
import io.bisq.gui.util.BSFormatter;
import io.bisq.gui.util.validation.InputValidator;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static io.bisq.gui.util.FormBuilder.addLabelInputTextField;
import static io.bisq.gui.util.FormBuilder.addLabelTextField;
public class SameBankForm extends BankForm {
private static final Logger log = LoggerFactory.getLogger(SameBankForm.class);
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) {
return BankForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
}
public SameBankForm(PaymentAccount paymentAccount, InputValidator inputValidator,
GridPane gridPane, int gridRow, BSFormatter formatter, Runnable closeHandler) {
super(paymentAccount, inputValidator, gridPane, gridRow, formatter, closeHandler);
}
@Override
protected void addHolderNameAndId() {
Tuple2<Label, InputTextField> tuple = addLabelInputTextField(gridPane, ++gridRow, Res.getWithCol("payment.account.owner"));
holderNameInputTextField = tuple.second;
holderNameInputTextField.setValidator(inputValidator);
holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
bankAccountPayload.setHolderName(newValue);
updateFromInputs();
});
InputTextField emailTextField = addLabelInputTextField(gridPane,
++gridRow, Res.get("payment.email")).second;
emailTextField.textProperty().addListener((ov, oldValue, newValue) -> {
bankAccountPayload.setEmail(newValue);
updateFromInputs();
});
emailTextField.setValidator(emailValidator);
}
@Override
public void updateAllInputsValid() {
boolean result = isAccountNameValid()
&& inputValidator.validate(bankAccountPayload.getHolderName()).isValid
&& emailValidator.validate(bankAccountPayload.getEmail()).isValid
&& paymentAccount.getSingleTradeCurrency() != null
&& ((CountryBasedPaymentAccount) paymentAccount).getCountry() != null;
final String countryCode = bankAccountPayload.getCountryCode();
if (countryCode != null) {
if (BankUtil.isBankNameRequired(countryCode))
result = result && inputValidator.validate(bankAccountPayload.getBankName()).isValid;
if (BankUtil.isBankIdRequired(countryCode))
result = result && inputValidator.validate(bankAccountPayload.getBankId()).isValid;
if (BankUtil.isBranchIdRequired(countryCode))
result = result && inputValidator.validate(bankAccountPayload.getBranchId()).isValid;
if (BankUtil.isAccountNrRequired(countryCode))
result = result && inputValidator.validate(bankAccountPayload.getAccountNr()).isValid;
}
allInputsValid.set(result);
}
@Override
protected void addHolderNameAndIdForDisplayAccount() {
Tuple2<Label, TextField> tuple = addLabelTextField(gridPane, ++gridRow, Res.getWithCol("payment.account.owner"));
TextField holderNameTextField = tuple.second;
holderNameTextField.setMinWidth(300);
holderNameTextField.setText(bankAccountPayload.getHolderName());
addLabelTextField(gridPane, ++gridRow, Res.get("payment.email"), bankAccountPayload.getEmail());
}
}

View File

@ -0,0 +1,237 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package io.bisq.gui.util.validation;
import io.bisq.common.locale.Res;
import io.bisq.core.app.BisqEnvironment;
import io.bisq.gui.util.validation.altcoins.ByteballAddressValidator;
import io.bisq.gui.util.validation.altcoins.NxtReedSolomonValidator;
import io.bisq.gui.util.validation.altcoins.OctocoinAddressValidator;
import io.bisq.gui.util.validation.params.IOPParams;
import io.bisq.gui.util.validation.params.OctocoinParams;
import io.bisq.gui.util.validation.params.PivxParams;
import io.bisq.gui.util.validation.params.btc.BtcMainNetParams;
import lombok.extern.slf4j.Slf4j;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.params.MainNetParams;
import org.bitcoinj.params.RegTestParams;
import org.bitcoinj.params.TestNet3Params;
import org.jetbrains.annotations.NotNull;
import org.libdohj.params.*;
@Slf4j
public final class AltCoinAddressValidator extends InputValidator {
private String currencyCode;
///////////////////////////////////////////////////////////////////////////////////////////
// Public methods
///////////////////////////////////////////////////////////////////////////////////////////
public void setCurrencyCode(String currencyCode) {
this.currencyCode = currencyCode;
}
@Override
public ValidationResult validate(String input) {
ValidationResult validationResult = super.validate(input);
if (!validationResult.isValid || currencyCode == null) {
return validationResult;
} else {
// Validation:
// 1: With a regex checking the correct structure of an address
// 2: If the address contains a checksum, verify the checksum
ValidationResult wrongChecksum = new ValidationResult(false,
Res.get("validation.altcoin.wrongChecksum"));
ValidationResult regexTestFailed = new ValidationResult(false,
Res.get("validation.altcoin.wrongStructure", currencyCode));
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 DOGE_MAINNET:
case DOGE_TESTNET:
case DOGE_REGTEST:
Address.fromBase58(BtcMainNetParams.get(), input);
return new ValidationResult(true);
}
return new ValidationResult(true);
} catch (AddressFormatException e) {
return new ValidationResult(false, getErrorMessage(e));
}
case "LTC":
try {
switch (BisqEnvironment.getBaseCurrencyNetwork()) {
case BTC_MAINNET:
case BTC_TESTNET:
case BTC_REGTEST:
case DOGE_MAINNET:
case DOGE_TESTNET:
case DOGE_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 ValidationResult(true);
} catch (AddressFormatException e) {
return new ValidationResult(false, getErrorMessage(e));
}
case "DOGE":
try {
switch (BisqEnvironment.getBaseCurrencyNetwork()) {
case BTC_MAINNET:
case BTC_TESTNET:
case BTC_REGTEST:
case LTC_MAINNET:
case LTC_TESTNET:
case LTC_REGTEST:
case DOGE_MAINNET:
Address.fromBase58(DogecoinMainNetParams.get(), input);
break;
case DOGE_TESTNET:
Address.fromBase58(DogecoinTestNet3Params.get(), input);
break;
case DOGE_REGTEST:
Address.fromBase58(DogecoinRegTestParams.get(), input);
break;
}
return new ValidationResult(true);
} 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);
// Example for BTC, though for BTC we use the BitcoinJ library address check
case "PIVX":
if (input.matches("^[D][a-km-zA-HJ-NP-Z1-9]{25,34}$")) {
//noinspection ConstantConditions
if (verifyChecksum(input)) {
try {
Address.fromBase58(PivxParams.get(), input);
return new ValidationResult(true);
} catch (AddressFormatException e) {
return new ValidationResult(false, getErrorMessage(e));
}
} else {
return wrongChecksum;
}
} else {
return regexTestFailed;
}
case "IOP":
if (input.matches("^[p][a-km-zA-HJ-NP-Z1-9]{25,34}$")) {
//noinspection ConstantConditions
if (verifyChecksum(input)) {
try {
Address.fromBase58(IOPParams.get(), input);
return new ValidationResult(true);
} catch (AddressFormatException e) {
return new ValidationResult(false, getErrorMessage(e));
}
} else {
return wrongChecksum;
}
} else {
return regexTestFailed;
}
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"))
return validationResult;
else
return new ValidationResult(false, Res.get("validation.altcoin.zAddressesNotSupported"));
case "GBYTE":
return ByteballAddressValidator.validate(input);
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;
}
default:
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());
}
@SuppressWarnings({"UnusedParameters", "SameReturnValue"})
private boolean verifyChecksum(String input) {
// TODO
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
}