From 0e5fb147d54fc13a96a43fb1f56406dca1a94ec9 Mon Sep 17 00:00:00 2001 From: Navid Rahimi Date: Fri, 4 Sep 2026 13:50:27 +0330 Subject: [PATCH] Firo: recognize Spark V2 spend transactions --- lib/wallets/wallet/impl/firo_transaction_type.dart | 4 ++++ lib/wallets/wallet/impl/firo_wallet.dart | 3 ++- test/wallets/firo_transaction_type_test.dart | 11 +++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 lib/wallets/wallet/impl/firo_transaction_type.dart create mode 100644 test/wallets/firo_transaction_type_test.dart diff --git a/lib/wallets/wallet/impl/firo_transaction_type.dart b/lib/wallets/wallet/impl/firo_transaction_type.dart new file mode 100644 index 000000000..501ae0026 --- /dev/null +++ b/lib/wallets/wallet/impl/firo_transaction_type.dart @@ -0,0 +1,4 @@ +bool isSparkSpendTransaction(Map transaction) { + final type = transaction['type']; + return transaction['version'] == 3 && (type == 9 || type == 11); +} diff --git a/lib/wallets/wallet/impl/firo_wallet.dart b/lib/wallets/wallet/impl/firo_wallet.dart index 34c68c2e5..ea2751457 100644 --- a/lib/wallets/wallet/impl/firo_wallet.dart +++ b/lib/wallets/wallet/impl/firo_wallet.dart @@ -30,6 +30,7 @@ import '../wallet_mixin_interfaces/coin_control_interface.dart'; import '../wallet_mixin_interfaces/electrumx_interface.dart'; import '../wallet_mixin_interfaces/extended_keys_interface.dart'; import '../wallet_mixin_interfaces/spark_interface.dart'; +import 'firo_transaction_type.dart'; class MasternodeInfo { final String proTxHash; @@ -332,7 +333,7 @@ class FiroWallet extends Bip39HDWallet bool isMint = false; bool isJMint = false; bool isSparkMint = false; - final bool isSparkSpend = txData["type"] == 9 && txData["version"] == 3; + final bool isSparkSpend = isSparkSpendTransaction(txData); final bool isMySpark = sparkTxids.contains(txData["txid"] as String); final bool isMySpentSpark = missing .where((e) => e.txid == txData["txid"]) diff --git a/test/wallets/firo_transaction_type_test.dart b/test/wallets/firo_transaction_type_test.dart new file mode 100644 index 000000000..89abfa3f0 --- /dev/null +++ b/test/wallets/firo_transaction_type_test.dart @@ -0,0 +1,11 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:paymint/wallets/wallet/impl/firo_transaction_type.dart'; + +void main() { + test('recognizes Spark spend transaction types', () { + expect(isSparkSpendTransaction({'version': 3, 'type': 9}), isTrue); + expect(isSparkSpendTransaction({'version': 3, 'type': 11}), isTrue); + expect(isSparkSpendTransaction({'version': 3, 'type': 10}), isFalse); + expect(isSparkSpendTransaction({'version': 2, 'type': 11}), isFalse); + }); +}