From c503e8f8d8fb57cb16bc4edbbe7ed80fa2ece820 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 17:26:24 -0600 Subject: [PATCH] confirms bugfix --- lib/models/isar/models/blockchain_data/transaction.dart | 5 ++--- lib/models/isar/models/blockchain_data/utxo.dart | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index 1fbacc784..efeefe85a 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -4,7 +4,6 @@ import 'package:isar/isar.dart'; import 'package:stackwallet/models/isar/models/address/address.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/input.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/output.dart'; -import 'package:stackwallet/models/isar/models/transaction_note.dart'; part 'transaction.g.dart'; @@ -49,8 +48,8 @@ class Transaction { final outputs = IsarLinks(); int getConfirmations(int currentChainHeight) { - if (height == null) return 0; - return max(0, currentChainHeight - height!); + if (height == null || height! <= 0) return 0; + return max(0, currentChainHeight - (height! - 1)); } bool isConfirmed(int currentChainHeight, int minimumConfirms) { diff --git a/lib/models/isar/models/blockchain_data/utxo.dart b/lib/models/isar/models/blockchain_data/utxo.dart index ff5507f39..d17ed23a8 100644 --- a/lib/models/isar/models/blockchain_data/utxo.dart +++ b/lib/models/isar/models/blockchain_data/utxo.dart @@ -32,8 +32,8 @@ class UTXO { int getConfirmations(int currentChainHeight) { if (blockTime == null || blockHash == null) return 0; - if (blockHeight == null) return 0; - return max(0, currentChainHeight - blockHeight!); + if (blockHeight == null || blockHeight! <= 0) return 0; + return max(0, currentChainHeight - (blockHeight! - 1)); } bool isConfirmed(int currentChainHeight, int minimumConfirms) {