Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/wallets/wallet/impl/firo_transaction_type.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bool isSparkSpendTransaction(Map<String, dynamic> transaction) {
final type = transaction['type'];
return transaction['version'] == 3 && (type == 9 || type == 11);
}
3 changes: 2 additions & 1 deletion lib/wallets/wallet/impl/firo_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -332,7 +333,7 @@ class FiroWallet<T extends ElectrumXCurrencyInterface> extends Bip39HDWallet<T>
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"])
Expand Down
11 changes: 11 additions & 0 deletions test/wallets/firo_transaction_type_test.dart
Original file line number Diff line number Diff line change
@@ -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);
});
}
Loading