From 19653afeab11df3f9ffa87662c228db4fe028f1f Mon Sep 17 00:00:00 2001 From: cyan Date: Tue, 11 Aug 2026 03:18:06 +0200 Subject: [PATCH] fix: sorting of transactions (#3494) * fix: zcash address for exchange * fix: honour the restore height the user entered - Make Zcash rescan work in both directions by resetting sync from the new birth height - Keep the entered height when restoring a wallet from keys - Tolerate grouping separators in typed restore heights * fix: sorting of transactions fix: tx fee for outgoing transactions --------- Co-authored-by: Vik Sharma Co-authored-by: Omar Hatem --- cw_zcash/lib/src/zcash_wallet.dart | 5 ++++- cw_zcash/lib/src/zkooltx.dart | 14 ++++++++++---- cw_zcash/pubspec.yaml | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cw_zcash/lib/src/zcash_wallet.dart b/cw_zcash/lib/src/zcash_wallet.dart index 34ae0f1e3..14cdf8f66 100644 --- a/cw_zcash/lib/src/zcash_wallet.dart +++ b/cw_zcash/lib/src/zcash_wallet.dart @@ -622,7 +622,10 @@ abstract class ZcashWalletBase final info = ZcashTransactionInfo( id: tx.txHash, amount: Money(amount, currency), - fee: Money.zero(currency), + fee: Money( + direction == TransactionDirection.outgoing ? tx.fee : BigInt.zero, + currency, + ), direction: direction, isPending: tx.height == 0, date: tx.time, diff --git a/cw_zcash/lib/src/zkooltx.dart b/cw_zcash/lib/src/zkooltx.dart index 6c7c64b3c..c70e8847c 100644 --- a/cw_zcash/lib/src/zkooltx.dart +++ b/cw_zcash/lib/src/zkooltx.dart @@ -33,10 +33,13 @@ class ZkoolTx { DateTime get time { final ts = max(_tx.time, _txAccount.time) * 1000; - if (ts == 0) { - return ZcashHeight.getTimeByBlockHeight(height); + if (ts != 0) { + return DateTime.fromMillisecondsSinceEpoch(ts); } - return DateTime.fromMillisecondsSinceEpoch(ts); + if (height == 0) { + return DateTime.now(); + } + return ZcashHeight.getTimeByBlockHeight(height); } String? get to => _txAccount.outputs.firstOrNull?.address; @@ -96,7 +99,8 @@ class ZkoolTx { BigInt get value => _value.abs(); - BigInt get fee => value - _calcValue; + BigInt get fee => BigInt.from(_tx.fee); + BigInt get _value { if (_tx.value != 0) { @@ -166,6 +170,7 @@ class ZkoolTx { "height": _tx.height, "time": _tx.time, "value": value.toInt(), + "tpe": _tx.tpe, "zsaValue": _tx.zsaValue, "assetDisplay": _tx.assetDisplay, @@ -277,6 +282,7 @@ class ZkoolTx { height: _asInt(txJson["height"]), time: _asInt(txJson["time"]), value: _asInt(txJson["value"]), + fee: _asInt(txJson["fee"]), tpe: txJson["tpe"] == null ? null : _asInt(txJson["tpe"]), zsaValue: _asInt(txJson["zsaValue"]), assetDisplay: txJson["assetDisplay"] as String? ?? "", diff --git a/cw_zcash/pubspec.yaml b/cw_zcash/pubspec.yaml index 3ae75fbd5..067540263 100644 --- a/cw_zcash/pubspec.yaml +++ b/cw_zcash/pubspec.yaml @@ -21,7 +21,7 @@ dependencies: # path: ../../zkool2 git: url: https://github.com/cake-tech/zkool2.git - ref: 16fd3d11575f850939f498c3ea75d391915456d1 + ref: 36e72b530c274c4a54a6127aadb94886e84d67bf path_provider: any sqflite_common_ffi: any