CW-826 Fix missing tx keys in monero (#1828)

* CW-826 Fix missing tx keys in monero * force store wallet * don't return error string

cyan committed Nov 26, 2024 at 14:43 UTC 738731d3e51ede6b40ad11ab9893d5e0ee86f664
3 files changed +7 -13
cw_monero/lib/api/transaction_history.dart
+2 -11
@@ -17,7 +17,7 @@ String getTxKey(String txId) {
17 final status = monero.Wallet_status(wptr!);
18 if (status != 0) {
19 final error = monero.Wallet_errorString(wptr!);
20 - return txId+"_"+error;
20 + return "";
21 }
22 return txKey;
23 }
@@ -364,16 +364,7 @@ class Transaction {
364 confirmations = monero.TransactionInfo_confirmations(txInfo),
365 fee = monero.TransactionInfo_fee(txInfo),
366 description = monero.TransactionInfo_description(txInfo),
367 - key = getTxKey(txInfo);
368 -
369 - static String getTxKey(monero.TransactionInfo txInfo) {
370 - final txKey = monero.Wallet_getTxKey(wptr!, txid: monero.TransactionInfo_hash(txInfo));
371 - final status = monero.Wallet_status(wptr!);
372 - if (status != 0) {
373 - return "";
374 - }
375 - return txKey;
376 - }
367 + key = getTxKey(monero.TransactionInfo_hash(txInfo));
368
369 Transaction.dummy({
370 required this.displayLabel,
cw_monero/lib/api/wallet.dart
+3 -2
@@ -150,14 +150,15 @@ final storeMutex = Mutex();
150
151 int lastStorePointer = 0;
152 int lastStoreHeight = 0;
153 -void storeSync() async {
153 +void storeSync({bool force = false}) async {
154 final addr = wptr!.address;
155 final synchronized = await Isolate.run(() {
156 return monero.Wallet_synchronized(Pointer.fromAddress(addr));
157 });
158 if (lastStorePointer == wptr!.address &&
159 lastStoreHeight + 5000 > monero.Wallet_blockChainHeight(wptr!) &&
160 - !synchronized) {
160 + !synchronized &&
161 + !force) {
162 return;
163 }
164 lastStorePointer = wptr!.address;
cw_monero/lib/pending_monero_transaction.dart
+2
@@ -6,6 +6,7 @@ import 'package:cw_core/crypto_currency.dart';
6 import 'package:cw_core/amount_converter.dart';
7
8 import 'package:cw_core/pending_transaction.dart';
9 +import 'package:cw_monero/api/wallet.dart';
10
11 class DoubleSpendException implements Exception {
12 DoubleSpendException();
@@ -53,6 +54,7 @@ class PendingMoneroTransaction with PendingTransaction {
54
55 rethrow;
56 }
57 + storeSync(force: true);
58 }
59
60 @override