mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
CW-325-Coin-Control-enhancements (#846)
* 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 d230b6a07b
.
* 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
This commit is contained in:
parent
f26815efb8
commit
315c4c911c
37 changed files with 525 additions and 339 deletions
|
@ -63,7 +63,8 @@ abstract class ElectrumWalletBase extends WalletBase<ElectrumBalance,
|
|||
_scripthashesUpdateSubject = {},
|
||||
balance = ObservableMap<CryptoCurrency, ElectrumBalance>.of(
|
||||
currency != null
|
||||
? {currency: initialBalance ?? const ElectrumBalance(confirmed: 0, unconfirmed: 0)}
|
||||
? {currency: initialBalance ?? const ElectrumBalance(confirmed: 0, unconfirmed: 0,
|
||||
frozen: 0)}
|
||||
: {}),
|
||||
this.unspentCoinsInfo = unspentCoinsInfo,
|
||||
super(walletInfo) {
|
||||
|
@ -133,8 +134,8 @@ abstract class ElectrumWalletBase extends WalletBase<ElectrumBalance,
|
|||
await walletAddresses.discoverAddresses();
|
||||
await updateTransactions();
|
||||
_subscribeForUpdates();
|
||||
await _updateBalance();
|
||||
await updateUnspent();
|
||||
await updateBalance();
|
||||
_feeRates = await electrumClient.feeRates();
|
||||
|
||||
Timer.periodic(const Duration(minutes: 1),
|
||||
|
@ -343,7 +344,7 @@ abstract class ElectrumWalletBase extends WalletBase<ElectrumBalance,
|
|||
electrumClient: electrumClient, amount: amount, fee: fee)
|
||||
..addListener((transaction) async {
|
||||
transactionHistory.addOne(transaction);
|
||||
await _updateBalance();
|
||||
await updateBalance();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -497,7 +498,10 @@ abstract class ElectrumWalletBase extends WalletBase<ElectrumBalance,
|
|||
hash: coin.hash,
|
||||
isFrozen: coin.isFrozen,
|
||||
isSending: coin.isSending,
|
||||
noteRaw: coin.note
|
||||
noteRaw: coin.note,
|
||||
address: coin.address.address,
|
||||
value: coin.value,
|
||||
vout: coin.vout,
|
||||
);
|
||||
|
||||
await unspentCoinsInfo.add(newInfo);
|
||||
|
@ -634,8 +638,8 @@ abstract class ElectrumWalletBase extends WalletBase<ElectrumBalance,
|
|||
_scripthashesUpdateSubject[sh] = electrumClient.scripthashUpdate(sh);
|
||||
_scripthashesUpdateSubject[sh]?.listen((event) async {
|
||||
try {
|
||||
await _updateBalance();
|
||||
await updateUnspent();
|
||||
await updateBalance();
|
||||
await updateTransactions();
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
|
@ -653,7 +657,17 @@ abstract class ElectrumWalletBase extends WalletBase<ElectrumBalance,
|
|||
final sh = scriptHash(addressRecord.address, networkType: networkType);
|
||||
final balanceFuture = electrumClient.getBalance(sh);
|
||||
balanceFutures.add(balanceFuture);
|
||||
}
|
||||
}
|
||||
|
||||
var totalFrozen = 0;
|
||||
unspentCoinsInfo.values.forEach((info) {
|
||||
unspentCoins.forEach((element) {
|
||||
if (element.hash == info.hash && info.isFrozen && element.address.address == info.address
|
||||
&& element.value == info.value) {
|
||||
totalFrozen += element.value;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
final balances = await Future.wait(balanceFutures);
|
||||
var totalConfirmed = 0;
|
||||
|
@ -672,10 +686,11 @@ abstract class ElectrumWalletBase extends WalletBase<ElectrumBalance,
|
|||
}
|
||||
}
|
||||
|
||||
return ElectrumBalance(confirmed: totalConfirmed, unconfirmed: totalUnconfirmed);
|
||||
return ElectrumBalance(confirmed: totalConfirmed, unconfirmed: totalUnconfirmed,
|
||||
frozen: totalFrozen);
|
||||
}
|
||||
|
||||
Future<void> _updateBalance() async {
|
||||
Future<void> updateBalance() async {
|
||||
balance[currency] = await _fetchBalances();
|
||||
await save();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue