From 26a2c978a9d3c46dcd19d1a4f28ead1353e45956 Mon Sep 17 00:00:00 2001 From: poka Date: Wed, 3 Feb 2021 18:45:08 +0100 Subject: [PATCH] Fix transaction amount parding for multi receivers --- lib/models/history.dart | 18 ++++++++++++++---- lib/screens/history.dart | 3 ++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/models/history.dart b/lib/models/history.dart index 59cb126..9442e6b 100644 --- a/lib/models/history.dart +++ b/lib/models/history.dart @@ -63,7 +63,9 @@ class HistoryProvider with ChangeNotifier { return ''; } - List parseHistory(txs) { +// Boris: JE6mkuzSpT3ePciCPRTpuMT9fqPUVVLJz2618d33p7tn + + List parseHistory(txs, _pubkey) { var transBC = []; int i = 0; @@ -73,7 +75,15 @@ class HistoryProvider with ChangeNotifier { for (final trans in txs) { var direction = trans['direction']; final transaction = trans['node']; - var output = transaction['outputs'][0]; + var output; + for (String line in transaction['outputs']) { + if (line.contains(_pubkey)) { + output = line; + } + } + if (output == null) { + continue; + } transBC.add(i); transBC[i] = []; @@ -108,7 +118,7 @@ class HistoryProvider with ChangeNotifier { return transBC; } - FetchMoreOptions checkQueryResult(result, opts) { + FetchMoreOptions checkQueryResult(result, opts, _pubkey) { final List blockchainTX = (result.data['txsHistoryBc']['both']['edges'] as List); @@ -136,7 +146,7 @@ class HistoryProvider with ChangeNotifier { print( "###### DEBUG H Parse blockchainTX list. Cursor: $fetchMoreCursor ######"); if (fetchMoreCursor != null) { - transBC = parseHistory(blockchainTX); + transBC = parseHistory(blockchainTX, _pubkey); isTheEnd = false; } else { print("###### DEBUG H - Début de l'historique"); diff --git a/lib/screens/history.dart b/lib/screens/history.dart index aca33f3..92ad765 100644 --- a/lib/screens/history.dart +++ b/lib/screens/history.dart @@ -126,7 +126,8 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier { final num balance = _historyProvider .removeDecimalZero(result.data['balance']['amount'] / 100); - opts = _historyProvider.checkQueryResult(result, opts); + opts = _historyProvider.checkQueryResult( + result, opts, _outputPubkey.text); // Build history list // _cesiumPlusProvider.cesiumName.text = "NAMEE";