support bitcoin cash address validation

This commit is contained in:
woodser 2022-08-17 14:19:00 -04:00
parent 69899c8750
commit 46e2b75bc8
2 changed files with 34 additions and 4 deletions

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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);
}
}

View File

@ -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());
}
}