Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/models/isar/models/blockchain_data/utxo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ class UTXO {
int getConfirmations(int currentChainHeight) {
if (blockTime == null || blockHash == null) return 0;
if (blockHeight == null || blockHeight! <= 0) return 0;
return max(0, currentChainHeight - (blockHeight! - 1));
return _isMonero()
? max(0, currentChainHeight - (blockHeight!))
: max(0, currentChainHeight - (blockHeight! - 1));
}

bool isConfirmed(
Expand All @@ -90,6 +92,11 @@ class UTXO {
(isCoinbase ? minimumCoinbaseConfirms : minimumConfirms);
}

// fuzzy
bool _isMonero() {
return keyImage != null;
}

@ignore
String? get keyImage {
if (otherData == null) {
Expand All @@ -98,7 +105,7 @@ class UTXO {

try {
final map = jsonDecode(otherData!) as Map;
return map["keyImage"] as String;
return map[UTXOOtherDataKeys.keyImage] as String;
} catch (_) {
return null;
}
Expand Down Expand Up @@ -169,3 +176,8 @@ class UTXO {
@ignore
int get hashCode => Object.hashAll([walletId, txid, vout]);
}

abstract final class UTXOOtherDataKeys {
static const keyImage = "keyImage";
static const spent = "spent";
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ class TransactionV2 {

int getConfirmations(int currentChainHeight) {
if (height == null || height! <= 0) return 0;
return max(0, currentChainHeight - (height! - 1));
return _isMonero()
? max(0, currentChainHeight - (height!))
: max(0, currentChainHeight - (height! - 1));
}

bool isConfirmed(
Expand Down
4 changes: 2 additions & 2 deletions lib/wallets/wallet/intermediate/lib_monero_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1017,8 +1017,8 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
.findFirst();

final otherDataMap = {
"keyImage": rawUTXO.keyImage,
"spent": rawUTXO.spent,
UTXOOtherDataKeys.keyImage: rawUTXO.keyImage,
UTXOOtherDataKeys.spent: rawUTXO.spent,
};

final utxo = UTXO(
Expand Down
16 changes: 16 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,14 @@ packages:
url: "https://github.com/cypherstack/flutter-devicelocale"
source: git
version: "0.8.1"
digest_auth:
dependency: "direct main"
description:
name: digest_auth
sha256: c8f4a8d65300bd58c4a2ca84ea6bd63cb584e8021e5689c600ee7efae34d73ea
url: "https://pub.dev"
source: hosted
version: "1.0.1"
dio:
dependency: transitive
description:
Expand Down Expand Up @@ -1360,6 +1368,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.0"
monero_rpc:
dependency: "direct main"
description:
name: monero_rpc
sha256: "6052b6812e3e831015d776645d0d880fce5b9632d9df2cacae54b5e10ffe2db5"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
mutex:
dependency: "direct main"
description:
Expand Down
Loading