mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-26 00:58:44 +00:00
coin control fixes
This commit is contained in:
parent
4ec9d7b2e1
commit
e5e2a8706b
2 changed files with 34 additions and 4 deletions
cw_bitcoin/lib
|
@ -1170,7 +1170,7 @@ abstract class ElectrumWalletBase
|
|||
await updateAllUnspents();
|
||||
|
||||
if (unspentCoinsInfo.isEmpty) {
|
||||
unspentCoins.forEach((coin) => _addCoinInfo(coin));
|
||||
unspentCoins.forEach((coin) => addCoinInfo(coin));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1190,7 +1190,7 @@ abstract class ElectrumWalletBase
|
|||
if (coin.bitcoinAddressRecord is! BitcoinSilentPaymentAddressRecord)
|
||||
coin.bitcoinAddressRecord.balance += coinInfo.value;
|
||||
} else {
|
||||
_addCoinInfo(coin);
|
||||
addCoinInfo(coin);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1222,7 +1222,7 @@ abstract class ElectrumWalletBase
|
|||
if (coin.bitcoinAddressRecord is! BitcoinSilentPaymentAddressRecord)
|
||||
coin.bitcoinAddressRecord.balance += coinInfo.value;
|
||||
} else {
|
||||
_addCoinInfo(coin);
|
||||
addCoinInfo(coin);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1249,7 +1249,7 @@ abstract class ElectrumWalletBase
|
|||
}
|
||||
|
||||
@action
|
||||
Future<void> _addCoinInfo(BitcoinUnspent coin) async {
|
||||
Future<void> addCoinInfo(BitcoinUnspent coin) async {
|
||||
final newInfo = UnspentCoinsInfo(
|
||||
walletId: id,
|
||||
hash: coin.hash,
|
||||
|
|
|
@ -481,6 +481,36 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
unconfirmed += utxo.value.toInt();
|
||||
}
|
||||
});
|
||||
|
||||
// update unspent balances:
|
||||
|
||||
// reset coin balances to 0:
|
||||
unspentCoins.forEach((coin) {
|
||||
if (coin.bitcoinAddressRecord is! BitcoinSilentPaymentAddressRecord)
|
||||
coin.bitcoinAddressRecord.balance = 0;
|
||||
});
|
||||
|
||||
unspentCoins.forEach((coin) {
|
||||
final coinInfoList = unspentCoinsInfo.values.where(
|
||||
(element) =>
|
||||
element.walletId.contains(id) &&
|
||||
element.hash.contains(coin.hash) &&
|
||||
element.vout == coin.vout,
|
||||
);
|
||||
|
||||
if (coinInfoList.isNotEmpty) {
|
||||
final coinInfo = coinInfoList.first;
|
||||
|
||||
coin.isFrozen = coinInfo.isFrozen;
|
||||
coin.isSending = coinInfo.isSending;
|
||||
coin.note = coinInfo.note;
|
||||
if (coin.bitcoinAddressRecord is! BitcoinSilentPaymentAddressRecord)
|
||||
coin.bitcoinAddressRecord.balance += coinInfo.value;
|
||||
} else {
|
||||
super.addCoinInfo(coin);
|
||||
}
|
||||
});
|
||||
|
||||
return ElectrumBalance(confirmed: confirmed, unconfirmed: unconfirmed, frozen: balance.frozen);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue