mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-24 19:25:52 +00:00
balance refresh and total display fixes
This commit is contained in:
parent
ea49ed32ab
commit
2b1d438953
2 changed files with 19 additions and 8 deletions
|
@ -19,7 +19,7 @@ class Balance {
|
|||
required this.pendingSpendable,
|
||||
});
|
||||
|
||||
Decimal getTotal({bool includeBlocked = false}) => Format.satoshisToAmount(
|
||||
Decimal getTotal({bool includeBlocked = true}) => Format.satoshisToAmount(
|
||||
includeBlocked ? total : total - blockedTotal,
|
||||
coin: coin,
|
||||
);
|
||||
|
@ -39,12 +39,7 @@ class Balance {
|
|||
coin: coin,
|
||||
);
|
||||
|
||||
String toJsonIgnoreCoin() => jsonEncode({
|
||||
"total": total,
|
||||
"spendable": spendable,
|
||||
"blockedTotal": blockedTotal,
|
||||
"pendingSpendable": pendingSpendable,
|
||||
});
|
||||
String toJsonIgnoreCoin() => jsonEncode(toMap()..remove("coin"));
|
||||
|
||||
factory Balance.fromJson(String json, Coin coin) {
|
||||
final decoded = jsonDecode(json);
|
||||
|
@ -56,4 +51,17 @@ class Balance {
|
|||
pendingSpendable: decoded["pendingSpendable"] as int,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"coin": coin,
|
||||
"total": total,
|
||||
"spendable": spendable,
|
||||
"blockedTotal": blockedTotal,
|
||||
"pendingSpendable": pendingSpendable,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return toMap().toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,10 @@ class BitcoinWallet extends CoinServiceAPI
|
|||
coin: coin,
|
||||
db: db,
|
||||
getChainHeight: () => chainHeight,
|
||||
refreshedBalanceCallback: updateCachedBalance,
|
||||
refreshedBalanceCallback: (balance) async {
|
||||
_balance = balance;
|
||||
await updateCachedBalance(_balance!);
|
||||
},
|
||||
);
|
||||
initPaynymWalletInterface(
|
||||
walletId: walletId,
|
||||
|
|
Loading…
Reference in a new issue