add spark address validation

This commit is contained in:
julian 2023-12-19 09:20:50 -06:00
parent a2e36f06de
commit 65e93c7f48
2 changed files with 15 additions and 2 deletions

View file

@ -7,6 +7,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart';
import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart';
class Firo extends Bip39HDCurrency { class Firo extends Bip39HDCurrency {
Firo(super.network) { Firo(super.network) {
@ -132,9 +133,15 @@ class Firo extends Bip39HDCurrency {
coinlib.Address.fromString(address, networkParams); coinlib.Address.fromString(address, networkParams);
return true; return true;
} catch (_) { } catch (_) {
return false; return validateSparkAddress(address);
} }
// TODO: implement validateAddress for spark addresses? }
bool validateSparkAddress(String address) {
return SparkInterface.validateSparkAddress(
address: address,
isTestNet: network == CryptoCurrencyNetwork.test,
);
} }
@override @override

View file

@ -19,6 +19,12 @@ import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_int
const kDefaultSparkIndex = 1; const kDefaultSparkIndex = 1;
mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
static bool validateSparkAddress({
required String address,
required bool isTestNet,
}) =>
LibSpark.validateAddress(address: address, isTestNet: isTestNet);
@override @override
Future<void> init() async { Future<void> init() async {
Address? address = await getCurrentReceivingSparkAddress(); Address? address = await getCurrentReceivingSparkAddress();