From 0a3efdbb6c28879f1524e423376577062c62b23b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Rychnovsk=C3=BD?= Date: Wed, 5 Jul 2023 14:18:49 +0200 Subject: [PATCH] [#1096] Fix null mined height crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This handles the state in which is a transaction after it’s created with mined height null. It then doesn’t try to convert such a height into a BlockHeight object which is doing validation on input height. It rather returns null, similarly as for expiry height. --- .../android/sdk/internal/db/derived/AllTransactionView.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/db/derived/AllTransactionView.kt b/sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/db/derived/AllTransactionView.kt index 371c00df..64221120 100644 --- a/sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/db/derived/AllTransactionView.kt +++ b/sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/db/derived/AllTransactionView.kt @@ -86,11 +86,16 @@ internal class AllTransactionView( val isSent = netValueLong < 0 val expiryHeightLong = cursor.getLong(expiryHeightIndex) + val minedHeightLong = cursor.getLong(minedHeightColumnIndex) DbTransactionOverview( id = cursor.getLong(idColumnIndex), rawId = FirstClassByteArray(cursor.getBlob(rawTransactionIdIndex)), - minedHeight = BlockHeight.new(zcashNetwork, cursor.getLong(minedHeightColumnIndex)), + minedHeight = if (0L == minedHeightLong) { + null + } else { + BlockHeight.new(zcashNetwork, minedHeightLong) + }, expiryHeight = if (0L == expiryHeightLong) { null } else {