diff --git a/assets/src/main/java/bisq/asset/BitcoinCashAddressValidator.java b/assets/src/main/java/bisq/asset/BitcoinCashAddressValidator.java new file mode 100644 index 00000000..7af317bf --- /dev/null +++ b/assets/src/main/java/bisq/asset/BitcoinCashAddressValidator.java @@ -0,0 +1,32 @@ +/* + * This file is part of Haveno. + * + * Haveno 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. + * + * Haveno 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 Haveno. If not, see . + */ + +package bisq.asset; + +/** + * Validates a Bitcoin Cash address. + */ +public class BitcoinCashAddressValidator extends RegexAddressValidator { + + public BitcoinCashAddressValidator() { + super("^([13][a-km-zA-HJ-NP-Z1-9]{25,34})|^((bitcoincash:)?(q|p)[a-z0-9]{41})|^((BITCOINCASH:)?(Q|P)[A-Z0-9]{41})$"); + } + + public BitcoinCashAddressValidator(String errorMessageI18nKey) { + super("^([13][a-km-zA-HJ-NP-Z1-9]{25,34})|^((bitcoincash:)?(q|p)[a-z0-9]{41})|^((BITCOINCASH:)?(Q|P)[A-Z0-9]{41})$", errorMessageI18nKey); + } +} diff --git a/assets/src/main/java/bisq/asset/coins/BitcoinCash.java b/assets/src/main/java/bisq/asset/coins/BitcoinCash.java index 487b8c96..e5237f74 100644 --- a/assets/src/main/java/bisq/asset/coins/BitcoinCash.java +++ b/assets/src/main/java/bisq/asset/coins/BitcoinCash.java @@ -17,14 +17,12 @@ package bisq.asset.coins; -import bisq.asset.BitcoinAddressValidator; +import bisq.asset.BitcoinCashAddressValidator; import bisq.asset.Coin; -import org.bitcoinj.params.MainNetParams; - public class BitcoinCash extends Coin { public BitcoinCash() { - super("Bitcoin Cash", "BCH", new BitcoinAddressValidator(MainNetParams.get()), Network.MAINNET); // TODO: BCH address validation + super("Bitcoin Cash", "BCH", new BitcoinCashAddressValidator()); } }