2023-11-15 23:12:23 +00:00
|
|
|
import 'package:cw_core/unspent_transaction_output.dart';
|
2024-12-09 18:23:59 +00:00
|
|
|
import 'package:cw_core/utils/print_verbose.dart';
|
2024-11-27 15:34:36 +00:00
|
|
|
import 'package:cw_monero/api/coins_info.dart';
|
|
|
|
import 'package:monero/monero.dart' as monero;
|
2023-08-24 13:54:05 +00:00
|
|
|
|
2023-11-15 23:12:23 +00:00
|
|
|
class MoneroUnspent extends Unspent {
|
|
|
|
MoneroUnspent(
|
|
|
|
String address, String hash, String keyImage, int value, bool isFrozen, this.isUnlocked)
|
|
|
|
: super(address, hash, value, 0, keyImage) {
|
2024-11-27 15:34:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
set isFrozen(bool freeze) {
|
2024-12-09 18:23:59 +00:00
|
|
|
printV("set isFrozen: $freeze ($keyImage): $freeze");
|
2024-11-27 15:34:36 +00:00
|
|
|
final coinId = getCoinByKeyImage(keyImage!);
|
|
|
|
if (coinId == null) throw Exception("Unable to find a coin for address $address");
|
|
|
|
if (freeze) {
|
|
|
|
freezeCoin(coinId);
|
|
|
|
} else {
|
|
|
|
thawCoin(coinId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool get isFrozen {
|
2024-12-09 18:23:59 +00:00
|
|
|
printV("get isFrozen");
|
2024-11-27 15:34:36 +00:00
|
|
|
final coinId = getCoinByKeyImage(keyImage!);
|
|
|
|
if (coinId == null) throw Exception("Unable to find a coin for address $address");
|
|
|
|
final coin = getCoin(coinId);
|
|
|
|
return monero.CoinsInfo_frozen(coin);
|
2023-11-15 23:12:23 +00:00
|
|
|
}
|
2023-08-24 13:54:05 +00:00
|
|
|
|
|
|
|
final bool isUnlocked;
|
|
|
|
}
|