CW-826 Fix missing tx keys in monero (#1828)
Some checks are pending
Cache Dependencies / test (push) Waiting to run

* CW-826 Fix missing tx keys in monero

* force store wallet

* don't return error string
This commit is contained in:
cyan 2024-11-26 14:43:56 +01:00 committed by GitHub
parent 09bc186fea
commit 738731d3e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 13 deletions

View file

@ -17,7 +17,7 @@ String getTxKey(String txId) {
final status = monero.Wallet_status(wptr!); final status = monero.Wallet_status(wptr!);
if (status != 0) { if (status != 0) {
final error = monero.Wallet_errorString(wptr!); final error = monero.Wallet_errorString(wptr!);
return txId+"_"+error; return "";
} }
return txKey; return txKey;
} }
@ -364,16 +364,7 @@ class Transaction {
confirmations = monero.TransactionInfo_confirmations(txInfo), confirmations = monero.TransactionInfo_confirmations(txInfo),
fee = monero.TransactionInfo_fee(txInfo), fee = monero.TransactionInfo_fee(txInfo),
description = monero.TransactionInfo_description(txInfo), description = monero.TransactionInfo_description(txInfo),
key = getTxKey(txInfo); key = getTxKey(monero.TransactionInfo_hash(txInfo));
static String getTxKey(monero.TransactionInfo txInfo) {
final txKey = monero.Wallet_getTxKey(wptr!, txid: monero.TransactionInfo_hash(txInfo));
final status = monero.Wallet_status(wptr!);
if (status != 0) {
return "";
}
return txKey;
}
Transaction.dummy({ Transaction.dummy({
required this.displayLabel, required this.displayLabel,

View file

@ -150,14 +150,15 @@ final storeMutex = Mutex();
int lastStorePointer = 0; int lastStorePointer = 0;
int lastStoreHeight = 0; int lastStoreHeight = 0;
void storeSync() async { void storeSync({bool force = false}) async {
final addr = wptr!.address; final addr = wptr!.address;
final synchronized = await Isolate.run(() { final synchronized = await Isolate.run(() {
return monero.Wallet_synchronized(Pointer.fromAddress(addr)); return monero.Wallet_synchronized(Pointer.fromAddress(addr));
}); });
if (lastStorePointer == wptr!.address && if (lastStorePointer == wptr!.address &&
lastStoreHeight + 5000 > monero.Wallet_blockChainHeight(wptr!) && lastStoreHeight + 5000 > monero.Wallet_blockChainHeight(wptr!) &&
!synchronized) { !synchronized &&
!force) {
return; return;
} }
lastStorePointer = wptr!.address; lastStorePointer = wptr!.address;

View file

@ -6,6 +6,7 @@ import 'package:cw_core/crypto_currency.dart';
import 'package:cw_core/amount_converter.dart'; import 'package:cw_core/amount_converter.dart';
import 'package:cw_core/pending_transaction.dart'; import 'package:cw_core/pending_transaction.dart';
import 'package:cw_monero/api/wallet.dart';
class DoubleSpendException implements Exception { class DoubleSpendException implements Exception {
DoubleSpendException(); DoubleSpendException();
@ -53,6 +54,7 @@ class PendingMoneroTransaction with PendingTransaction {
rethrow; rethrow;
} }
storeSync(force: true);
} }
@override @override