mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-10-31 09:27:40 +00:00
3a391f10a3
* fix: enhance regex, fix multiline * feat: improve scan msg, fix missing txs, use date api * feat: node fixes, enhance send modal, TX list tag & filter, refactors * fix: continuous scanning * fix: missing close * fix: resubscribe tweaks * feat: use mempool api setting toggle * handle any failure of height API and fallback to the old method [skip ci] --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
47 lines
1.3 KiB
Dart
47 lines
1.3 KiB
Dart
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
|
import 'package:cw_core/wallet_base.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
|
|
part 'rescan_view_model.g.dart';
|
|
|
|
class RescanViewModel = RescanViewModelBase with _$RescanViewModel;
|
|
|
|
enum RescanWalletState { rescaning, none }
|
|
|
|
abstract class RescanViewModelBase with Store {
|
|
RescanViewModelBase(this.wallet)
|
|
: state = RescanWalletState.none,
|
|
isButtonEnabled = false,
|
|
doSingleScan = false;
|
|
|
|
final WalletBase wallet;
|
|
|
|
@observable
|
|
RescanWalletState state;
|
|
|
|
@observable
|
|
bool isButtonEnabled;
|
|
|
|
@observable
|
|
bool doSingleScan;
|
|
|
|
@computed
|
|
bool get isSilentPaymentsScan => wallet.type == WalletType.bitcoin;
|
|
|
|
@computed
|
|
Future<bool> get isBitcoinMempoolAPIEnabled async =>
|
|
wallet.type == WalletType.bitcoin && await bitcoin!.checkIfMempoolAPIIsEnabled(wallet);
|
|
|
|
@action
|
|
Future<void> rescanCurrentWallet({required int restoreHeight}) async {
|
|
state = RescanWalletState.rescaning;
|
|
if (wallet.type != WalletType.bitcoin) {
|
|
wallet.rescan(height: restoreHeight);
|
|
wallet.transactionHistory.clear();
|
|
} else {
|
|
bitcoin!.rescan(wallet, height: restoreHeight, doSingleScan: doSingleScan);
|
|
}
|
|
state = RescanWalletState.none;
|
|
}
|
|
}
|