From aa5ea643cc59d75f374954ae57f629f2c3f0e02f Mon Sep 17 00:00:00 2001 From: Oscar Mira Date: Mon, 29 May 2023 02:48:35 +0200 Subject: [PATCH] lib: fix unspent txout crash --- .../src/main/kotlin/im/molly/monero/OwnedTxOut.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/android/src/main/kotlin/im/molly/monero/OwnedTxOut.kt b/lib/android/src/main/kotlin/im/molly/monero/OwnedTxOut.kt index 41f86fd..d762e92 100644 --- a/lib/android/src/main/kotlin/im/molly/monero/OwnedTxOut.kt +++ b/lib/android/src/main/kotlin/im/molly/monero/OwnedTxOut.kt @@ -19,17 +19,17 @@ constructor( val spentInBlockHeight: Long, ) : Parcelable { - init { - require(blockHeight <= spentInBlockHeight) - require(amount >= 0) { "TX amount cannot be negative" } - } - @IgnoredOnParcel val spent: Boolean = spentInBlockHeight != 0L @IgnoredOnParcel val notSpent = !spent + init { + require(notSpent || blockHeight <= spentInBlockHeight) + require(amount >= 0) { "TX amount $amount cannot be negative" } + } + override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false