From 96e4a4eb6c41a0a3c541a617073096ef96c1492f Mon Sep 17 00:00:00 2001 From: cyan Date: Wed, 7 Aug 2024 18:12:49 +0200 Subject: [PATCH] monero fixes (#1581) * correct comparision while syncing * fix issue from report 25916.txt * return proper address even if numSubaddresses returned 0 --- cw_monero/lib/api/subaddress_list.dart | 6 +++++- cw_monero/lib/api/wallet.dart | 2 +- cw_monero/lib/monero_wallet_addresses.dart | 2 +- cw_wownero/lib/api/subaddress_list.dart | 6 +++++- cw_wownero/lib/wownero_wallet_addresses.dart | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cw_monero/lib/api/subaddress_list.dart b/cw_monero/lib/api/subaddress_list.dart index 57edea76e..e5145692d 100644 --- a/cw_monero/lib/api/subaddress_list.dart +++ b/cw_monero/lib/api/subaddress_list.dart @@ -42,12 +42,16 @@ class Subaddress { List getAllSubaddresses() { final size = monero.Wallet_numSubaddresses(wptr!, accountIndex: subaddress!.accountIndex); - return List.generate(size, (index) { + final list = List.generate(size, (index) { return Subaddress( accountIndex: subaddress!.accountIndex, addressIndex: index, ); }).reversed.toList(); + if (list.length == 0) { + list.add(Subaddress(addressIndex: subaddress!.accountIndex, accountIndex: 0)); + } + return list; } void addSubaddressSync({required int accountIndex, required String label}) { diff --git a/cw_monero/lib/api/wallet.dart b/cw_monero/lib/api/wallet.dart index 6ca9cd1bb..0f6e59c4e 100644 --- a/cw_monero/lib/api/wallet.dart +++ b/cw_monero/lib/api/wallet.dart @@ -131,7 +131,7 @@ void storeSync() async { return monero.Wallet_synchronized(Pointer.fromAddress(addr)); }); if (lastStorePointer == wptr!.address && - lastStoreHeight + 5000 < monero.Wallet_blockChainHeight(wptr!) && + lastStoreHeight + 5000 > monero.Wallet_blockChainHeight(wptr!) && !synchronized) { return; } diff --git a/cw_monero/lib/monero_wallet_addresses.dart b/cw_monero/lib/monero_wallet_addresses.dart index f74e7dd5b..d4f22e46f 100644 --- a/cw_monero/lib/monero_wallet_addresses.dart +++ b/cw_monero/lib/monero_wallet_addresses.dart @@ -109,7 +109,7 @@ abstract class MoneroWalletAddressesBase extends WalletAddresses with Store { accountIndex: accountIndex, defaultLabel: defaultLabel, usedAddresses: usedAddresses.toList()); - subaddress = subaddressList.subaddresses.last; + subaddress = (subaddressList.subaddresses.isEmpty) ? Subaddress(id: 0, address: address, label: defaultLabel) : subaddressList.subaddresses.last; address = subaddress!.address; } diff --git a/cw_wownero/lib/api/subaddress_list.dart b/cw_wownero/lib/api/subaddress_list.dart index cec7d94cb..d8c91a584 100644 --- a/cw_wownero/lib/api/subaddress_list.dart +++ b/cw_wownero/lib/api/subaddress_list.dart @@ -41,12 +41,16 @@ class Subaddress { List getAllSubaddresses() { final size = wownero.Wallet_numSubaddresses(wptr!, accountIndex: subaddress!.accountIndex); - return List.generate(size, (index) { + final list = List.generate(size, (index) { return Subaddress( accountIndex: subaddress!.accountIndex, addressIndex: index, ); }).reversed.toList(); + if (list.isEmpty) { + list.add(Subaddress(addressIndex: 0, accountIndex: subaddress!.accountIndex)); + } + return list; } void addSubaddressSync({required int accountIndex, required String label}) { diff --git a/cw_wownero/lib/wownero_wallet_addresses.dart b/cw_wownero/lib/wownero_wallet_addresses.dart index dc4b42840..9eeb182eb 100644 --- a/cw_wownero/lib/wownero_wallet_addresses.dart +++ b/cw_wownero/lib/wownero_wallet_addresses.dart @@ -109,7 +109,7 @@ abstract class WowneroWalletAddressesBase extends WalletAddresses with Store { accountIndex: accountIndex, defaultLabel: defaultLabel, usedAddresses: usedAddresses.toList()); - subaddress = subaddressList.subaddresses.last; + subaddress = (subaddressList.subaddresses.isEmpty) ? Subaddress(id: 0, address: address, label: defaultLabel) : subaddressList.subaddresses.last; address = subaddress!.address; }