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>
83 lines
2.5 KiB
Dart
83 lines
2.5 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:cw_core/amount/money.dart';
|
|
import 'package:cw_core/balance.dart';
|
|
import "package:cw_core/crypto_currency.dart";
|
|
import 'package:cw_core/currency.dart';
|
|
|
|
class ElectrumBalance extends Balance {
|
|
|
|
factory ElectrumBalance.zero(CryptoCurrency currency) => ElectrumBalance(
|
|
confirmed: Money.zero(currency),
|
|
unconfirmed: Money.zero(currency),
|
|
frozen: Money.zero(currency),
|
|
);
|
|
|
|
ElectrumBalance({
|
|
required this.confirmed,
|
|
required this.unconfirmed,
|
|
required this.frozen,
|
|
this.secondConfirmed,
|
|
this.secondUnconfirmed,
|
|
}) : super(confirmed, unconfirmed,
|
|
secondAvailable: secondConfirmed, secondUnavailable: secondUnconfirmed);
|
|
|
|
Money confirmed;
|
|
Money unconfirmed;
|
|
Money? secondConfirmed;
|
|
Money? secondUnconfirmed;
|
|
|
|
@override
|
|
Money get available => (confirmed + unconfirmed) - frozen;
|
|
|
|
@override
|
|
Money get unavailable => unconfirmed;
|
|
|
|
@override
|
|
Money frozen;
|
|
|
|
static ElectrumBalance? fromJSON(String? jsonSource, Currency currency) {
|
|
if (jsonSource == null) return null;
|
|
|
|
final decoded = json.decode(jsonSource) as Map;
|
|
|
|
return ElectrumBalance(
|
|
confirmed: Money.fromInt(decoded['confirmed'] as int? ?? 0, currency),
|
|
unconfirmed: Money.fromInt(decoded['unconfirmed'] as int? ?? 0, currency),
|
|
frozen: Money.fromInt(decoded['frozen'] as int? ?? 0, currency),
|
|
secondConfirmed: Money.fromInt(decoded['secondConfirmed'] as int? ?? 0, currency),
|
|
secondUnconfirmed: Money.fromInt(decoded['secondUnconfirmed'] as int? ?? 0, currency),
|
|
);
|
|
}
|
|
|
|
String toJSON() => json.encode({
|
|
'confirmed': confirmed.amount.toInt(),
|
|
'unconfirmed': unavailable.amount.toInt(),
|
|
'frozen': frozen.amount.toInt(),
|
|
'secondConfirmed': secondAvailable?.amount.toInt() ?? 0,
|
|
'secondUnconfirmed': secondUnavailable?.amount.toInt() ?? 0,
|
|
});
|
|
|
|
// Value equality so instances can be compared/deduped (e.g. by MobX reactions via MapEquality)
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is ElectrumBalance &&
|
|
other.confirmed == confirmed &&
|
|
other.unconfirmed == unconfirmed &&
|
|
other.frozen == frozen &&
|
|
other.secondConfirmed == secondConfirmed &&
|
|
other.secondUnconfirmed == secondUnconfirmed);
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
confirmed,
|
|
unconfirmed,
|
|
frozen,
|
|
secondConfirmed,
|
|
secondUnconfirmed,
|
|
);
|
|
}
|
|
|
|
|