mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 12:09:43 +00:00
87178b2a54
* fix coin freezing * fix frozen balance * update monero_c hash * update monero_c hash (after merge) * fix test E make it ready * revert local change * throw error on wow as well * experiment with view model code * move view model into di.dart
29 lines
784 B
Dart
29 lines
784 B
Dart
import 'package:cw_monero/api/account_list.dart';
|
|
import 'package:monero/monero.dart' as monero;
|
|
|
|
monero.Coins? coins = null;
|
|
|
|
void refreshCoins(int accountIndex) {
|
|
coins = monero.Wallet_coins(wptr!);
|
|
monero.Coins_refresh(coins!);
|
|
}
|
|
|
|
int countOfCoins() => monero.Coins_count(coins!);
|
|
|
|
monero.CoinsInfo getCoin(int index) => monero.Coins_coin(coins!, index);
|
|
|
|
int? getCoinByKeyImage(String keyImage) {
|
|
final count = countOfCoins();
|
|
for (int i = 0; i < count; i++) {
|
|
final coin = getCoin(i);
|
|
final coinAddress = monero.CoinsInfo_keyImage(coin);
|
|
if (keyImage == coinAddress) {
|
|
return i;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
void freezeCoin(int index) => monero.Coins_setFrozen(coins!, index: index);
|
|
|
|
void thawCoin(int index) => monero.Coins_thaw(coins!, index: index);
|