From a2a24b1b72b63129849cc5aa19d172c7893a0e62 Mon Sep 17 00:00:00 2001 From: Serhii Date: Tue, 28 Feb 2023 13:26:21 +0200 Subject: [PATCH] fix current height --- cw_haven/lib/haven_transaction_info.dart | 8 +++++--- cw_monero/lib/monero_transaction_info.dart | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cw_haven/lib/haven_transaction_info.dart b/cw_haven/lib/haven_transaction_info.dart index 90048c605..f4f70eca6 100644 --- a/cw_haven/lib/haven_transaction_info.dart +++ b/cw_haven/lib/haven_transaction_info.dart @@ -6,6 +6,7 @@ import 'package:cw_core/transaction_direction.dart'; import 'package:cw_core/format_amount.dart'; import 'package:cw_haven/api/transaction_history.dart'; import 'package:intl/intl.dart'; +import 'package:cw_haven/api/wallet.dart' as haven_wallet; class HavenTransactionInfo extends TransactionInfo { HavenTransactionInfo(this.id, this.height, this.direction, this.date, this.isPending, this.amount, @@ -57,14 +58,15 @@ class HavenTransactionInfo extends TransactionInfo { @override String? unlockTimeFormatted() { - if (direction == TransactionDirection.outgoing || unlockTime < (height + 10)) { + final currentHeight = haven_wallet.getCurrentHeight(); + if (direction == TransactionDirection.outgoing || unlockTime < (currentHeight + 10)) { return null; } if (unlockTime < 500000000) { - return (unlockTime - height) * 2 > 500000 + return (unlockTime - currentHeight) * 2 > 500000 ? '>1 year' - : '~${(unlockTime - height) * 2} minutes'; + : '~${(unlockTime - currentHeight) * 2} minutes'; } try { var locked = DateTime.fromMillisecondsSinceEpoch(unlockTime).compareTo(DateTime.now()); diff --git a/cw_monero/lib/monero_transaction_info.dart b/cw_monero/lib/monero_transaction_info.dart index 9a828ef21..81c51b9dc 100644 --- a/cw_monero/lib/monero_transaction_info.dart +++ b/cw_monero/lib/monero_transaction_info.dart @@ -6,6 +6,7 @@ import 'package:cw_core/transaction_direction.dart'; import 'package:cw_core/format_amount.dart'; import 'package:cw_monero/api/transaction_history.dart'; import 'package:intl/intl.dart'; +import 'package:cw_monero/api/wallet.dart' as monero_wallet; class MoneroTransactionInfo extends TransactionInfo { MoneroTransactionInfo(this.id, this.height, this.direction, this.date, @@ -63,14 +64,15 @@ class MoneroTransactionInfo extends TransactionInfo { @override String? unlockTimeFormatted() { - if (direction == TransactionDirection.outgoing || unlockTime < (height + 10)) { + final currentHeight = monero_wallet.getCurrentHeight(); + if (direction == TransactionDirection.outgoing || unlockTime < (currentHeight + 10)) { return null; } if (unlockTime < 500000000) { - return (unlockTime - height) * 2 > 500000 + return (unlockTime - currentHeight) * 2 > 500000 ? '>1 year' - : '~${(unlockTime - height) * 2} minutes'; + : '~${(unlockTime - currentHeight) * 2} minutes'; } try { var locked = DateTime.fromMillisecondsSinceEpoch(unlockTime).compareTo(DateTime.now());