mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-02-04 12:16:31 +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,
|
required this.pendingSpendable,
|
||||||
});
|
});
|
||||||
|
|
||||||
Decimal getTotal({bool includeBlocked = false}) => Format.satoshisToAmount(
|
Decimal getTotal({bool includeBlocked = true}) => Format.satoshisToAmount(
|
||||||
includeBlocked ? total : total - blockedTotal,
|
includeBlocked ? total : total - blockedTotal,
|
||||||
coin: coin,
|
coin: coin,
|
||||||
);
|
);
|
||||||
|
@ -39,12 +39,7 @@ class Balance {
|
||||||
coin: coin,
|
coin: coin,
|
||||||
);
|
);
|
||||||
|
|
||||||
String toJsonIgnoreCoin() => jsonEncode({
|
String toJsonIgnoreCoin() => jsonEncode(toMap()..remove("coin"));
|
||||||
"total": total,
|
|
||||||
"spendable": spendable,
|
|
||||||
"blockedTotal": blockedTotal,
|
|
||||||
"pendingSpendable": pendingSpendable,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory Balance.fromJson(String json, Coin coin) {
|
factory Balance.fromJson(String json, Coin coin) {
|
||||||
final decoded = jsonDecode(json);
|
final decoded = jsonDecode(json);
|
||||||
|
@ -56,4 +51,17 @@ class Balance {
|
||||||
pendingSpendable: decoded["pendingSpendable"] as int,
|
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,
|
coin: coin,
|
||||||
db: db,
|
db: db,
|
||||||
getChainHeight: () => chainHeight,
|
getChainHeight: () => chainHeight,
|
||||||
refreshedBalanceCallback: updateCachedBalance,
|
refreshedBalanceCallback: (balance) async {
|
||||||
|
_balance = balance;
|
||||||
|
await updateCachedBalance(_balance!);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
initPaynymWalletInterface(
|
initPaynymWalletInterface(
|
||||||
walletId: walletId,
|
walletId: walletId,
|
||||||
|
|
Loading…
Reference in a new issue