feat: prefill rescan height with the saved Monero and Zcash restore height (#3669)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Seth For Privacy
2026-10-02 22:58:28 +02:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 9679f91a8c
commit 0503d54290
5 changed files with 32 additions and 0 deletions
+8
View File
@@ -999,6 +999,14 @@ abstract class ZcashWalletBase
static int zashiAnnouncedBlockHeight = 2419420;
Future<int?> getBirthHeight() async => runWithCoin(
accountId: accountId,
func: (final coin) async => (await zkool_account.listAccounts(c: coin))
.where((final a) => a.id == accountId)
.firstOrNull
?.birth,
);
Future<dynamic> _getAddressesForAccount(final int id) async {
return runWithCoin(
accountId: id,
+10
View File
@@ -25,6 +25,16 @@ class RescanPage extends StatefulWidget {
class _RescanPageState extends State<RescanPage> {
final TextEditingController _heightController = TextEditingController();
@override
void initState() {
super.initState();
widget._rescanViewModel.savedRestoreHeight.then((height) {
if (mounted && (height ?? 0) > 0 && _heightController.text.isEmpty) {
_heightController.text = '$height';
}
});
}
@override
Widget build(BuildContext context) {
Widget child;
+10
View File
@@ -1,4 +1,6 @@
import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cake_wallet/monero/monero.dart';
import 'package:cake_wallet/zcash/zcash.dart';
import 'package:cw_core/wallet_base.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:mobx/mobx.dart';
@@ -32,6 +34,14 @@ abstract class RescanViewModelBase with Store {
@computed
bool get isMwebScan => wallet.type == WalletType.litecoin;
Future<int?> get savedRestoreHeight async => switch (wallet.type) {
WalletType.monero => wallet.walletInfo.restoreHeight != 0
? wallet.walletInfo.restoreHeight
: monero!.getRestoreHeight(wallet),
WalletType.zcash => await zcash!.getBirthHeight(wallet),
_ => null,
};
Future<bool> get isBitcoinMempoolAPIEnabled async =>
wallet.type == WalletType.bitcoin && await bitcoin!.checkIfMempoolAPIIsEnabled(wallet);
+3
View File
@@ -119,6 +119,9 @@ class CWZcash extends Zcash {
return getAddress(wallet);
}
@override
Future<int?> getBirthHeight(Object wallet) => (wallet as ZcashWallet).getBirthHeight();
@override
Map<String, String> getKeys(Object wallet) {
final zcashWallet = wallet as ZcashWallet;
+1
View File
@@ -1778,6 +1778,7 @@ abstract class Zcash {
String getPrivateKey(WalletBase wallet);
String getPublicKey(WalletBase wallet);
Map<String, String> getKeys(Object wallet);
Future<int?> getBirthHeight(Object wallet);
Object createZcashTransactionCredentials(
List<Output> outputs, {