CW 1080: fix(cw_monero): call store() directly after commiting tx (#2312)

* fix(cw_monero): call store() directly after commiting tx to make sure that tx key is written to cache
also, store it in TransactionDescription hive box

* Update lib/view_model/send/send_view_model.dart

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
cyan 2025-06-16 16:49:43 +02:00 committed by GitHub
parent fe0c9ecc0e
commit a96b493b60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 31 additions and 15 deletions

View file

@ -5,13 +5,11 @@ class PendingTransactionDescription {
required this.fee,
required this.hash,
required this.hex,
required this.txKey,
required this.pointerAddress});
final int amount;
final int fee;
final String hash;
final String hex;
final String txKey;
final int pointerAddress;
}

View file

@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:ffi';
import 'dart:isolate';
@ -194,14 +195,12 @@ Future<PendingTransactionDescription> createTransactionSync(
final rFee = pendingTx.fee();
final rHash = pendingTx.txid('');
final rHex = pendingTx.hex('');
final rTxKey = rHash;
return PendingTransactionDescription(
amount: rAmt,
fee: rFee,
hash: rHash,
hex: rHex,
txKey: rTxKey,
pointerAddress: pendingTx.ffiAddress(),
);
}
@ -246,7 +245,6 @@ Future<PendingTransactionDescription> createTransactionMultDest(
fee: tx.fee(),
hash: tx.txid(''),
hex: tx.hex(''),
txKey: tx.txid(''),
pointerAddress: tx.ffiAddress(),
);
}
@ -263,6 +261,7 @@ Future<String?> commitTransaction({required Wallet2PendingTransaction tx, requir
filename: '',
overwrite: false,
);
return null;
});
String? error = (() {
@ -285,11 +284,12 @@ Future<String?> commitTransaction({required Wallet2PendingTransaction tx, requir
if (error != null && error != "no tx keys found for this txid") {
throw CreationTransactionException(message: error);
}
if (useUR) {
return Future.value(txCommit as String?);
} else {
return Future.value(null);
}
unawaited(() async {
storeSync(force: true);
await Future.delayed(Duration(seconds: 5));
storeSync(force: true);
}());
return Future.value(txCommit);
}
class Transaction {

View file

@ -31,8 +31,6 @@ class PendingMoneroTransaction with PendingTransaction {
@override
String get hex => pendingTransactionDescription.hex;
String get txKey => pendingTransactionDescription.txKey;
@override
String get amountFormatted => AmountConverter.amountIntToString(
CryptoCurrency.xmr, pendingTransactionDescription.amount);