mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
* add Wallet Accounts page and integrate UI * account model refactor * add walletInfoAccount table and API * add WalletAccountList API * add multi-account support for Electrum wallets * add Bitcoin lightning card and card style handling * refine account filtering and card selection * update current account balance on wallet changes * update configure.dar * Use named parameters for card design * Add Bitcoin account handling and refactor lookup * refactor dashboard * refactor cards UI and account balance handling * Improve Bitcoin account selection and balances * restrict unspent coin usage to current account * filter transactions by current Bitcoin account * refactor electrum wallet * refactor address generation * add accountIndex to address fetch logic * Update configure.dart * reload transactions on Bitcoin account change * restore multiple BTC accounts and improve fetch * show account balance with in btc * track account index in Bitcoin transactions * discover btc BIP39 accounts during restore * fix account switching and card ordering bugs * fix card customizer * limit account name length in modal * update BTC account list balance display * auto-reformat * formating fix * skip HD map validation * fix 0 balance issue * minor fix * quick bitcoin wallet sync * restore shuffle change output * restore address lookup fix * Update electrum.dart * remove account customizer * Merge branch 'CW-1142-Add-accounts-feature-to-BTC' into CW-1551-Quick-Bitcoin-Wallet-Sync * probe only segwit in account discovery * add account discovery limit and tracking * Improve Electrum sync account handling [skip ci] * remove legacy monero account and address list UI * rework BTC account balance refres * avoid unnecessary BTC account reloads * refactor account header in addresses page * fix blank popup when editing an account * fix: dedupe UTXO balance * minor fix * add Bitcoin current account API * Apply batched suggestions from code review [skip ci] Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * address PR review comments [skip ci] * remove account customizer and fix accounts init * restrict extra BTC accounts to SegWit * add BTC multi-account toggle * Fix BTC sync gating and account balance update * minor fix * Update electrum_wallet.dart * store selected account on WalletInfo * Refine wallet account reset visibility * refactor BTC address prep and move accounts page * refactor account stack and customizer routing * migrate legacy Lightning card styles * unify dashboard account change state * fix account routing and Electrum balances * fix account setup and wallet cards UI * disable Bitcoin Accounts for all hardware * merge conflicts fix * minor fixes * update cards_view [skip ci] * reverted cards view update [skip ci] * fix asset name * moved the transaction filtering into the electrum wallet * localization * disable accounts for watch-only wallets * fix: stop card render from switching the wallet account * fix: restore Lightning transactions in tx history * minor fix * fix: skip duplicate legacy address generation [skip ci] * fix: correct account balance/design mismatch bugs * addressing review comments --------- Co-authored-by: Robert Malikowski <malikowskirobert@gmail.com> Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
155 lines
4.9 KiB
Dart
155 lines
4.9 KiB
Dart
import "package:cw_core/receive_page_option.dart";
|
|
import 'package:mobx/mobx.dart';
|
|
import 'package:cw_core/balance.dart';
|
|
import 'package:cw_core/transaction_info.dart';
|
|
import 'package:cw_core/transaction_history.dart';
|
|
import 'package:cw_core/transaction_priority.dart';
|
|
import 'package:cw_core/wallet_addresses.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:cw_core/pending_transaction.dart';
|
|
import 'package:cw_core/currency_for_wallet_type.dart';
|
|
import 'package:cw_core/crypto_currency.dart';
|
|
import 'package:cw_core/sync_status.dart';
|
|
import 'package:cw_core/node.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:cw_core/pathForWallet.dart';
|
|
|
|
abstract class WalletBase<BalanceType extends Balance, HistoryType extends TransactionHistoryBase,
|
|
TransactionType extends TransactionInfo> {
|
|
WalletBase(this.walletInfo, this.derivationInfo);
|
|
|
|
static String idFor(String name, WalletType type) =>
|
|
walletTypeToString(type).toLowerCase() + '_' + name;
|
|
|
|
WalletInfo walletInfo;
|
|
DerivationInfo derivationInfo;
|
|
|
|
WalletType get type => walletInfo.type;
|
|
|
|
int? get chainId => null;
|
|
|
|
CryptoCurrency get currency => walletTypeToCryptoCurrency(
|
|
type,
|
|
chainId: chainId,
|
|
isTestnet: isTestnet,
|
|
);
|
|
|
|
String get id => walletInfo.id;
|
|
|
|
String get name => walletInfo.name;
|
|
|
|
//String get address;
|
|
|
|
//set address(String address);
|
|
|
|
ObservableMap<CryptoCurrency, BalanceType> get balance;
|
|
|
|
SyncStatus get syncStatus;
|
|
|
|
set syncStatus(SyncStatus status);
|
|
|
|
String? get seed;
|
|
|
|
String? get privateKey => null;
|
|
|
|
String? get hexSeed => null;
|
|
|
|
String? get passphrase => null;
|
|
|
|
Object get keys;
|
|
|
|
WalletAddresses get walletAddresses;
|
|
|
|
late HistoryType transactionHistory;
|
|
|
|
set isEnabledAutoGenerateSubaddress(bool value) {}
|
|
|
|
bool get isEnabledAutoGenerateSubaddress => false;
|
|
|
|
bool get isHardwareWallet => walletInfo.isHardwareWallet;
|
|
|
|
bool get isSoftwareWallet => walletInfo.hardwareWalletType == null;
|
|
|
|
HardwareWalletType? get hardwareWalletType => walletInfo.hardwareWalletType;
|
|
|
|
bool get hasRescan => false;
|
|
|
|
Future<void> connectToNode({required Node node});
|
|
|
|
// there is a default definition here because only coins with a pow node (nano based) need to override this
|
|
Future<void> connectToPowNode({required Node node}) async {}
|
|
|
|
// startBackgroundSync is used to start sync in the background, without doing any
|
|
// extra things in the background.
|
|
// startSync is used as a fallback.
|
|
Future<void> startBackgroundSync() => startSync();
|
|
Future<void> stopBackgroundSync(String password) => stopSync();
|
|
|
|
Future<void> startSync();
|
|
|
|
Future<void> stopSync() async {}
|
|
|
|
Future<PendingTransaction> createTransaction(Object credentials);
|
|
|
|
int calculateEstimatedFee(TransactionPriority priority, int? amount);
|
|
|
|
Future<void> updateEstimatedFeesParams(TransactionPriority? priority) async {}
|
|
|
|
// void fetchTransactionsAsync(
|
|
// void Function(TransactionType transaction) onTransactionLoaded,
|
|
// {void Function() onFinished});
|
|
|
|
Future<Map<String, TransactionType>> fetchTransactions();
|
|
|
|
Future<void> save();
|
|
|
|
Future<void> rescan({required int height});
|
|
|
|
Future<void> close({bool shouldCleanup = false});
|
|
|
|
Future<void> changePassword(String password);
|
|
|
|
String get password;
|
|
|
|
Future<void>? updateBalance();
|
|
Future<void> updateTransactionsHistory() async {}
|
|
|
|
void setExceptionHandler(void Function(FlutterErrorDetails) onError) => null;
|
|
|
|
Future<void> renameWalletFiles(String newWalletName) =>
|
|
copyWalletFilesTo(fromName: walletInfo.name, toName: newWalletName, type: type);
|
|
|
|
Future<String> signMessage(String message, {String? address = null});
|
|
|
|
Future<bool> verifyMessage(String message, String signature, {String? address = null});
|
|
|
|
bool isTestnet = false;
|
|
|
|
bool canSend() => true;
|
|
|
|
/// Check if the wallet's socket connection is healthy.
|
|
/// Returns true if the connection is alive, false otherwise.
|
|
/// Default implementation returns true (no-op for wallets without socket connections).
|
|
Future<bool> checkSocketHealth() async => true;
|
|
|
|
/// This is used to check if the current node is healthy by making a lightweight RPC call
|
|
/// Each wallet implementation should override this to make a single, efficient call
|
|
/// Returns true if the node is healthy, false otherwise
|
|
Future<bool> checkNodeHealth();
|
|
|
|
bool get hasPayjoinSupport => false;
|
|
bool get hasLightningSupport => false;
|
|
bool get hasSilentPaymentsScanning => false;
|
|
|
|
bool get hasAccountsSupport => false;
|
|
bool get hasNativeAccounts => false;
|
|
bool get canToggleMultiAccounts => hasAccountsSupport && !hasNativeAccounts;
|
|
|
|
// hardware wallet - bitbox, ledger, trezor.
|
|
// we also have airgap wallets but those can't sign messages
|
|
bool get canSignMessages => walletInfo.hardwareWalletType == null || walletInfo.isHardwareWallet;
|
|
|
|
bool receiveOptionAvailable(ReceivePageOption option) => true;
|
|
}
|