mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 17:27:37 +00:00
Merge pull request #13 from cake-tech/CWA-155-BTC-validation
CWA-155 | added btc validation, that include Bech32 address format
This commit is contained in:
commit
28be299edb
4 changed files with 8 additions and 8 deletions
|
@ -45,7 +45,7 @@ abstract class AddressBookStoreBase with Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
|
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
|
||||||
// XMR (95), BTC (34), ETH (42), LTC (34), BCH (42), DASH (34)
|
// XMR (95), BTC (34, 42), ETH (42), LTC (34), BCH (42), DASH (34)
|
||||||
const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$';
|
const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$';
|
||||||
final regExp = RegExp(pattern);
|
final regExp = RegExp(pattern);
|
||||||
isValid = regExp.hasMatch(value);
|
isValid = regExp.hasMatch(value);
|
||||||
|
@ -56,7 +56,7 @@ abstract class AddressBookStoreBase with Store {
|
||||||
isValid = (value.length == 95);
|
isValid = (value.length == 95);
|
||||||
break;
|
break;
|
||||||
case 'BTC':
|
case 'BTC':
|
||||||
isValid = (value.length == 34);
|
isValid = (value.length == 34)||(value.length == 42);
|
||||||
break;
|
break;
|
||||||
case 'ETH':
|
case 'ETH':
|
||||||
isValid = (value.length == 42);
|
isValid = (value.length == 42);
|
||||||
|
|
|
@ -226,7 +226,7 @@ abstract class ExchangeStoreBase with Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
|
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
|
||||||
// XMR (95), BTC (34), ETH (42), LTC (34), BCH (42), DASH (34)
|
// XMR (95), BTC (34, 42), ETH (42), LTC (34), BCH (42), DASH (34)
|
||||||
const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$';
|
const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$';
|
||||||
final regExp = RegExp(pattern);
|
final regExp = RegExp(pattern);
|
||||||
isValid = regExp.hasMatch(value);
|
isValid = regExp.hasMatch(value);
|
||||||
|
@ -237,7 +237,7 @@ abstract class ExchangeStoreBase with Store {
|
||||||
isValid = (value.length == 95);
|
isValid = (value.length == 95);
|
||||||
break;
|
break;
|
||||||
case 'BTC':
|
case 'BTC':
|
||||||
isValid = (value.length == 34);
|
isValid = (value.length == 34)||(value.length == 42);
|
||||||
break;
|
break;
|
||||||
case 'ETH':
|
case 'ETH':
|
||||||
isValid = (value.length == 42);
|
isValid = (value.length == 42);
|
||||||
|
|
|
@ -159,7 +159,7 @@ abstract class SendStoreBase with Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
|
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
|
||||||
// XMR (95), BTC (34), ETH (42), LTC (34), BCH (42), DASH (34)
|
// XMR (95), BTC (34, 42), ETH (42), LTC (34), BCH (42), DASH (34)
|
||||||
const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$';
|
const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$';
|
||||||
final regExp = RegExp(pattern);
|
final regExp = RegExp(pattern);
|
||||||
isValid = value == null ? false : regExp.hasMatch(value);
|
isValid = value == null ? false : regExp.hasMatch(value);
|
||||||
|
@ -170,7 +170,7 @@ abstract class SendStoreBase with Store {
|
||||||
isValid = (value.length == 95);
|
isValid = (value.length == 95);
|
||||||
break;
|
break;
|
||||||
case 'BTC':
|
case 'BTC':
|
||||||
isValid = (value.length == 34);
|
isValid = (value.length == 34)||(value.length == 42);
|
||||||
break;
|
break;
|
||||||
case 'ETH':
|
case 'ETH':
|
||||||
isValid = (value.length == 42);
|
isValid = (value.length == 42);
|
||||||
|
|
|
@ -116,7 +116,7 @@ abstract class WalleRestorationStoreBase with Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
|
void validateAddress(String value, {CryptoCurrency cryptoCurrency}) {
|
||||||
// XMR (95), BTC (34), ETH (42), LTC (34), BCH (42), DASH (34)
|
// XMR (95), BTC (34, 42), ETH (42), LTC (34), BCH (42), DASH (34)
|
||||||
const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$';
|
const pattern = '^[0-9a-zA-Z]{95}\$|^[0-9a-zA-Z]{34}\$|^[0-9a-zA-Z]{42}\$';
|
||||||
final regExp = RegExp(pattern);
|
final regExp = RegExp(pattern);
|
||||||
isValid = regExp.hasMatch(value);
|
isValid = regExp.hasMatch(value);
|
||||||
|
@ -127,7 +127,7 @@ abstract class WalleRestorationStoreBase with Store {
|
||||||
isValid = (value.length == 95);
|
isValid = (value.length == 95);
|
||||||
break;
|
break;
|
||||||
case 'BTC':
|
case 'BTC':
|
||||||
isValid = (value.length == 34);
|
isValid = (value.length == 34)||(value.length == 42);
|
||||||
break;
|
break;
|
||||||
case 'ETH':
|
case 'ETH':
|
||||||
isValid = (value.length == 42);
|
isValid = (value.length == 42);
|
||||||
|
|
Loading…
Reference in a new issue