mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-21 22:58:49 +00:00
wrap hashTag in compute
This commit is contained in:
parent
df5988b48e
commit
04a24edaec
2 changed files with 19 additions and 6 deletions
|
@ -3,7 +3,6 @@ import 'dart:convert';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:decimal/decimal.dart';
|
import 'package:decimal/decimal.dart';
|
||||||
import 'package:flutter_libsparkmobile/flutter_libsparkmobile.dart';
|
|
||||||
import 'package:isar/isar.dart';
|
import 'package:isar/isar.dart';
|
||||||
|
|
||||||
import '../../../db/sqlite/firo_cache.dart';
|
import '../../../db/sqlite/firo_cache.dart';
|
||||||
|
@ -429,11 +428,7 @@ class FiroWallet<T extends ElectrumXCurrencyInterface> extends Bip39HDWallet<T>
|
||||||
if (lTags?.isNotEmpty == true) {
|
if (lTags?.isNotEmpty == true) {
|
||||||
final List<SparkCoin> usedCoins = [];
|
final List<SparkCoin> usedCoins = [];
|
||||||
for (final tag in lTags!) {
|
for (final tag in lTags!) {
|
||||||
final components = (tag as String).split(",");
|
final hash = await hashTag(tag as String);
|
||||||
final x = components[0].substring(1);
|
|
||||||
final y = components[1].substring(0, components[1].length - 1);
|
|
||||||
|
|
||||||
final hash = LibSpark.hashTag(x, y);
|
|
||||||
usedCoins.addAll(sparkCoins.where((e) => e.lTagHash == hash));
|
usedCoins.addAll(sparkCoins.where((e) => e.lTagHash == hash));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,16 @@ const OP_SPARKMINT = 0xd1;
|
||||||
const OP_SPARKSMINT = 0xd2;
|
const OP_SPARKSMINT = 0xd2;
|
||||||
const OP_SPARKSPEND = 0xd3;
|
const OP_SPARKSPEND = 0xd3;
|
||||||
|
|
||||||
|
/// top level function for use with [compute]
|
||||||
|
String _hashTag(String tag) {
|
||||||
|
final components = tag.split(",");
|
||||||
|
final x = components[0].substring(1);
|
||||||
|
final y = components[1].substring(0, components[1].length - 1);
|
||||||
|
|
||||||
|
final hash = LibSpark.hashTag(x, y);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
mixin SparkInterface<T extends ElectrumXCurrencyInterface>
|
mixin SparkInterface<T extends ElectrumXCurrencyInterface>
|
||||||
on Bip39HDWallet<T>, ElectrumXInterface<T> {
|
on Bip39HDWallet<T>, ElectrumXInterface<T> {
|
||||||
String? _sparkChangeAddressCached;
|
String? _sparkChangeAddressCached;
|
||||||
|
@ -56,6 +66,14 @@ mixin SparkInterface<T extends ElectrumXCurrencyInterface>
|
||||||
}) =>
|
}) =>
|
||||||
LibSpark.validateAddress(address: address, isTestNet: isTestNet);
|
LibSpark.validateAddress(address: address, isTestNet: isTestNet);
|
||||||
|
|
||||||
|
Future<String> hashTag(String tag) async {
|
||||||
|
try {
|
||||||
|
return await compute(_hashTag, tag);
|
||||||
|
} catch (_) {
|
||||||
|
throw ArgumentError("Invalid tag string format", "tag");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue