fix firo getAddressType to account for spark addresses
What changed, and why it matters
This commit fixes how Stack Wallet classifies Firo Spark addresses. Before the fix, the wallet likely treated Spark addresses as a different, possibly unsupported address type because it didn't have a dedicated check. The fix adds a method that first checks if an address is a Spark address and, if so, returns the correct type; otherwise it falls back to the existing logic. This is a correctness fix that could prevent user-facing errors or misrouting of transactions involving Spark addresses.
Review callers of getAddressType to confirm Spark addresses now flow through the correct code paths. Verify that validateSparkAddress correctly distinguishes mainnet/testnet and rejects malformed inputs. Consider adding unit tests for Spark address classification and edge cases (testnet, invalid, non-Spark).
Security signals we found
Address-type misclassification in cryptocurrency wallet
Spark privacy address handling added to dispatch logic
Potential transaction construction or validation error for Spark addresses before fix
Evidence from the diff
The change overrides getAddressType(String address) in lib/wallets/crypto_currency/coins/firo.dart. It now calls validateSparkAddress(address) and returns AddressType.spark when true, otherwise delegates to super.getAddressType(address). The validateSparkAddress helper was also reformatted. This ensures Spark addresses are correctly identified by the wallet’s address-type dispatch logic rather than being misclassified or rejected by the base class implementation.
Changed components
lib/wallets/crypto_currency/coins/firo.dartFiro Spark address validation and address-type resolutionInspect captured patch +12 / −1
diff --git a/lib/wallets/crypto_currency/coins/firo.dart b/lib/wallets/crypto_currency/coins/firo.dart
index ac3ca1c..583dc4b 100644
--- a/lib/wallets/crypto_currency/coins/firo.dart
+++ b/lib/wallets/crypto_currency/coins/firo.dart
@@ -197,7 +197,10 @@ class Firo extends Bip39HDCurrency with ElectrumXCurrencyInterface {
}
bool validateSparkAddress(String address) {
- return SparkInterface.validateSparkAddress(address: address, isTestNet: network.isTestNet);
+ return SparkInterface.validateSparkAddress(
+ address: address,
+ isTestNet: network.isTestNet,
+ );
}
bool isExchangeAddress(String address) {
@@ -295,4 +298,12 @@ class Firo extends Bip39HDCurrency with ElectrumXCurrencyInterface {
@override
BigInt get defaultFeeRate => BigInt.from(1000);
+
+ @override
+ AddressType? getAddressType(String address) {
+ if (validateSparkAddress(address)) {
+ return .spark;
+ }
+ return super.getAddressType(address);
+ }
}
Why this scored 35/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.