Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions lib/wallets/wallet/impl/xelis_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class XelisWallet extends LibXelisWallet {
@override
Future<List<String>> updateTransactions({
bool isRescan = false,
List<String>? rawTransactions,
List<xelis_sdk.TransactionEntry>? objTransactions,
int? topoheight,
}) async {
checkInitialized();
Expand Down Expand Up @@ -361,16 +361,17 @@ class XelisWallet extends LibXelisWallet {
await libXelisWallet!.rescan(topoheight: BigInt.from(pruningHeight));
}

final txListJson = rawTransactions ?? await libXelisWallet!.allHistory();
final txList = objTransactions ??
(await libXelisWallet!.allHistory())
.map((jsonStr) => xelis_sdk.TransactionEntry.fromJson(
json.decode(jsonStr),
) as xelis_sdk.TransactionEntry)
.toList();

final List<TransactionV2> txns = [];

for (final jsonString in txListJson) {
for (final transactionEntry in txList) {
try {
final transactionEntry = xelis_sdk.TransactionEntry.fromJson(
(json.decode(jsonString) as Map).cast(),
);

// Check for duplicates
final storedTx =
await mainDB.isar.transactionV2s
Expand Down Expand Up @@ -562,7 +563,7 @@ class XelisWallet extends LibXelisWallet {
txns.add(txn);
} catch (e, s) {
Logging.instance.w(
"Error in $runtimeType handling transaction: $jsonString",
"Error in $runtimeType handling transaction: $transactionEntry",
error: e,
stackTrace: s,
);
Expand Down Expand Up @@ -865,10 +866,10 @@ class XelisWallet extends LibXelisWallet {
@override
Future<void> handleNewTransaction(xelis_sdk.TransactionEntry tx) async {
try {
final txListJson = [jsonEncode(tx.toString())];
final txList = [tx];
final newTxIds = await updateTransactions(
isRescan: false,
rawTransactions: txListJson,
objTransactions: txList,
);

await updateBalance();
Expand Down
Loading