mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-23 06:38:35 +02:00
* fix checkbox * save the output state * add note as a header * Allow copy the Amount and Address * add frozen balance to dashboard * add block explorer * fix url launcher * code formatting * minor fixes * Revert "minor fixes" This reverts commit d230b6a07bc3855407251991926ab0f257c55a5a. * fix missing implementations error * [skip ci] update localization * fix unspent with same txid * add amount check * add vout check * remove formattedTotalAvailableBalance * remove unrelated mac os files
41 lines
1.2 KiB
Dart
41 lines
1.2 KiB
Dart
import 'dart:convert';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:cw_bitcoin/bitcoin_amount_format.dart';
|
|
import 'package:cw_core/balance.dart';
|
|
|
|
class ElectrumBalance extends Balance {
|
|
const ElectrumBalance({required this.confirmed, required this.unconfirmed, required this.frozen})
|
|
: super(confirmed, unconfirmed);
|
|
|
|
static ElectrumBalance? fromJSON(String? jsonSource) {
|
|
if (jsonSource == null) {
|
|
return null;
|
|
}
|
|
|
|
final decoded = json.decode(jsonSource) as Map;
|
|
|
|
return ElectrumBalance(
|
|
confirmed: decoded['confirmed'] as int? ?? 0,
|
|
unconfirmed: decoded['unconfirmed'] as int? ?? 0,
|
|
frozen: decoded['frozen'] as int? ?? 0);
|
|
}
|
|
|
|
final int confirmed;
|
|
final int unconfirmed;
|
|
final int frozen;
|
|
|
|
@override
|
|
String get formattedAvailableBalance => bitcoinAmountToString(amount: confirmed - frozen);
|
|
|
|
@override
|
|
String get formattedAdditionalBalance => bitcoinAmountToString(amount: unconfirmed);
|
|
|
|
String get formattedFrozenBalance {
|
|
final frozenFormatted = bitcoinAmountToString(amount: frozen);
|
|
return frozenFormatted == '0.0' ? '' : frozenFormatted;
|
|
}
|
|
|
|
String toJSON() =>
|
|
json.encode({'confirmed': confirmed, 'unconfirmed': unconfirmed, 'frozen': frozen});
|
|
}
|