mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-04-11 15:01:54 +00:00
fix: getWlptr failing nullcheck in hardware monero wallets (#2149)
now null wptr on listener calls will be handled gracefully Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
parent
23a47ed561
commit
7a5999d90e
2 changed files with 10 additions and 6 deletions
cw_monero/lib/api
|
@ -7,7 +7,8 @@ bool get isViewOnly => int.tryParse(monero.Wallet_secretSpendKey(wptr!)) == 0;
|
|||
int _wlptrForW = 0;
|
||||
monero.WalletListener? _wlptr = null;
|
||||
|
||||
monero.WalletListener getWlptr() {
|
||||
monero.WalletListener? getWlptr() {
|
||||
if (wptr == null) return null;
|
||||
if (wptr!.address == _wlptrForW) return _wlptr!;
|
||||
_wlptrForW = wptr!.address;
|
||||
_wlptr = monero.MONERO_cw_getWalletListener(wptr!);
|
||||
|
|
|
@ -2,7 +2,6 @@ import 'dart:async';
|
|||
import 'dart:ffi';
|
||||
import 'dart:isolate';
|
||||
|
||||
import 'package:cw_core/root_dir.dart';
|
||||
import 'package:cw_core/utils/print_verbose.dart';
|
||||
import 'package:cw_monero/api/account_list.dart';
|
||||
import 'package:cw_monero/api/exceptions/setup_wallet_exception.dart';
|
||||
|
@ -22,14 +21,18 @@ int getSyncingHeight() {
|
|||
}
|
||||
|
||||
bool isNeededToRefresh() {
|
||||
final ret = monero.MONERO_cw_WalletListener_isNeedToRefresh(getWlptr());
|
||||
monero.MONERO_cw_WalletListener_resetNeedToRefresh(getWlptr());
|
||||
final wlptr = getWlptr();
|
||||
if (wlptr == null) return false;
|
||||
final ret = monero.MONERO_cw_WalletListener_isNeedToRefresh(wlptr);
|
||||
monero.MONERO_cw_WalletListener_resetNeedToRefresh(wlptr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool isNewTransactionExist() {
|
||||
final ret = monero.MONERO_cw_WalletListener_isNewTransactionExist(getWlptr());
|
||||
monero.MONERO_cw_WalletListener_resetIsNewTransactionExist(getWlptr());
|
||||
final wlptr = getWlptr();
|
||||
if (wlptr == null) return false;
|
||||
final ret = monero.MONERO_cw_WalletListener_isNewTransactionExist(wlptr);
|
||||
monero.MONERO_cw_WalletListener_resetIsNewTransactionExist(wlptr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue