Skip to content

Commit db9a949

Browse files
committed
firo spark coin instantsend isLocked addition to local model
1 parent 1d1d27b commit db9a949

File tree

6 files changed

+119
-52
lines changed

6 files changed

+119
-52
lines changed

lib/electrumx_rpc/electrumx_client.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ class ElectrumXClient {
10361036
}
10371037
}
10381038

1039-
/// Returns the txids of the current transactions found in the mempool
1039+
/// Returns the txids of the current spark transactions found in the mempool
10401040
Future<Set<String>> getMempoolTxids({String? requestID}) async {
10411041
try {
10421042
final start = DateTime.now();
@@ -1089,6 +1089,7 @@ class ElectrumXClient {
10891089
// the space after lTags is required lol
10901090
lTags: List<String>.from(entry.value["lTags "] as List),
10911091
coins: List<String>.from(entry.value["coins"] as List),
1092+
isLocked: entry.value["isLocked"] as bool,
10921093
),
10931094
);
10941095
}

lib/models/electrumx_response/spark_models.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ class SparkMempoolData {
33
final List<String> serialContext;
44
final List<String> lTags;
55
final List<String> coins;
6+
final bool isLocked;
67

78
SparkMempoolData({
89
required this.txid,
910
required this.serialContext,
1011
required this.lTags,
1112
required this.coins,
13+
required this.isLocked,
1214
});
1315

1416
@override
@@ -17,7 +19,8 @@ class SparkMempoolData {
1719
"txid: $txid, "
1820
"serialContext: $serialContext, "
1921
"lTags: $lTags, "
20-
"coins: $coins"
22+
"coins: $coins, "
23+
"isLocked: $isLocked"
2124
"}";
2225
}
2326
}

lib/pages_desktop_specific/spark_coins/spark_coins_view.dart

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ import '../../widgets/desktop/desktop_scaffold.dart';
2626
import '../../widgets/isar_collection_watcher_list.dart';
2727

2828
class SparkCoinsView extends ConsumerWidget {
29-
const SparkCoinsView({
30-
super.key,
31-
required this.walletId,
32-
});
29+
const SparkCoinsView({super.key, required this.walletId});
3330

3431
static const title = "Spark coins";
3532
static const String routeName = "/sparkCoinsView";
@@ -47,43 +44,35 @@ class SparkCoinsView extends ConsumerWidget {
4744
leading: Expanded(
4845
child: Row(
4946
children: [
50-
const SizedBox(
51-
width: 32,
52-
),
47+
const SizedBox(width: 32),
5348
AppBarIconButton(
5449
size: 32,
55-
color: Theme.of(context)
56-
.extension<StackColors>()!
57-
.textFieldDefaultBG,
50+
color:
51+
Theme.of(
52+
context,
53+
).extension<StackColors>()!.textFieldDefaultBG,
5854
shadows: const [],
5955
icon: SvgPicture.asset(
6056
Assets.svg.arrowLeft,
6157
width: 18,
6258
height: 18,
63-
color: Theme.of(context)
64-
.extension<StackColors>()!
65-
.topNavIconPrimary,
59+
color:
60+
Theme.of(
61+
context,
62+
).extension<StackColors>()!.topNavIconPrimary,
6663
),
6764
onPressed: Navigator.of(context).pop,
6865
),
69-
const SizedBox(
70-
width: 12,
71-
),
72-
Text(
73-
title,
74-
style: STextStyles.desktopH3(context),
75-
),
66+
const SizedBox(width: 12),
67+
Text(title, style: STextStyles.desktopH3(context)),
7668
const Spacer(),
7769
],
7870
),
7971
),
8072
useSpacers: false,
8173
isCompactHeight: true,
8274
),
83-
body: Padding(
84-
padding: const EdgeInsets.all(24),
85-
child: child,
86-
),
75+
body: Padding(padding: const EdgeInsets.all(24), child: child),
8776
);
8877
},
8978
child: ConditionalParent(
@@ -98,26 +87,23 @@ class SparkCoinsView extends ConsumerWidget {
9887
leading: AppBarBackButton(
9988
onPressed: () => Navigator.of(context).pop(),
10089
),
101-
title: Text(
102-
title,
103-
style: STextStyles.navBarTitle(context),
104-
),
105-
),
106-
body: SafeArea(
107-
child: child,
90+
title: Text(title, style: STextStyles.navBarTitle(context)),
10891
),
92+
body: SafeArea(child: child),
10993
),
11094
);
11195
},
11296
child: IsarCollectionWatcherList(
11397
itemName: title,
114-
queryBuilder: () => ref
115-
.read(mainDBProvider)
116-
.isar
117-
.sparkCoins
118-
.where()
119-
.walletIdEqualToAnyLTagHash(walletId)
120-
.sortByHeightDesc(),
98+
queryBuilder:
99+
() =>
100+
ref
101+
.read(mainDBProvider)
102+
.isar
103+
.sparkCoins
104+
.where()
105+
.walletIdEqualToAnyLTagHash(walletId)
106+
.sortByHeightDesc(),
121107
itemBuilder: (SparkCoin? coin) {
122108
return [
123109
("TXID", coin?.txHash ?? "", 9),
@@ -129,6 +115,7 @@ class SparkCoinsView extends ConsumerWidget {
129115
("Group ID", coin?.groupId.toString() ?? "", 2),
130116
("Type", coin?.type.name ?? "", 2),
131117
("Used", coin?.isUsed.toString() ?? "", 2),
118+
("Locked", coin?.isLocked.toString() ?? "", 2),
132119
];
133120
},
134121
),

lib/wallets/isar/models/spark_coin.dart

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,7 @@ enum SparkCoinType {
1717
class SparkCoin {
1818
Id id = Isar.autoIncrement;
1919

20-
@Index(
21-
unique: true,
22-
replace: true,
23-
composite: [
24-
CompositeIndex("lTagHash"),
25-
],
26-
)
20+
@Index(unique: true, replace: true, composite: [CompositeIndex("lTagHash")])
2721
final String walletId;
2822

2923
@enumerated
@@ -55,6 +49,10 @@ class SparkCoin {
5549
final String? serializedCoinB64;
5650
final String? contextB64;
5751

52+
// prefix name with zzz to ensure serialization order remains unchanged
53+
@Name("zzzIsLocked")
54+
final bool? isLocked;
55+
5856
@ignore
5957
BigInt get value => BigInt.parse(valueIntString);
6058

@@ -66,10 +64,7 @@ class SparkCoin {
6664
return max(0, currentChainHeight - (height! - 1));
6765
}
6866

69-
bool isConfirmed(
70-
int currentChainHeight,
71-
int minimumConfirms,
72-
) {
67+
bool isConfirmed(int currentChainHeight, int minimumConfirms) {
7368
final confirmations = getConfirmations(currentChainHeight);
7469
return confirmations >= minimumConfirms;
7570
}
@@ -93,6 +88,7 @@ class SparkCoin {
9388
this.height,
9489
this.serializedCoinB64,
9590
this.contextB64,
91+
this.isLocked,
9692
});
9793

9894
SparkCoin copyWith({
@@ -113,6 +109,7 @@ class SparkCoin {
113109
int? height,
114110
String? serializedCoinB64,
115111
String? contextB64,
112+
bool? isLocked,
116113
}) {
117114
return SparkCoin(
118115
walletId: walletId,
@@ -134,6 +131,7 @@ class SparkCoin {
134131
height: height ?? this.height,
135132
serializedCoinB64: serializedCoinB64 ?? this.serializedCoinB64,
136133
contextB64: contextB64 ?? this.contextB64,
134+
isLocked: isLocked ?? this.isLocked,
137135
);
138136
}
139137

@@ -158,6 +156,7 @@ class SparkCoin {
158156
', height: $height'
159157
', serializedCoinB64: $serializedCoinB64'
160158
', contextB64: $contextB64'
159+
', isLocked: $isLocked'
161160
')';
162161
}
163162
}

lib/wallets/isar/models/spark_coin.g.dart

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,12 @@ mixin SparkInterface<T extends ElectrumXCurrencyInterface>
880880
// add checked txids after identification
881881
_mempoolTxidsChecked.addAll(checkedTxids);
882882

883-
result.addAll(myCoins);
883+
for (final coin in myCoins) {
884+
final match = sparkDataToCheck.firstWhere(
885+
(e) => e.serialContext.contains(coin.contextB64!),
886+
);
887+
result.add(coin.copyWith(isLocked: match.isLocked));
888+
}
884889
}
885890

886891
return result;

0 commit comments

Comments
 (0)