monero fixes (#1581)
Some checks are pending
Cache Dependencies / test (push) Waiting to run

* correct comparision while syncing

* fix issue from report 25916.txt

* return proper address even if numSubaddresses returned 0
This commit is contained in:
cyan 2024-08-07 18:12:49 +02:00 committed by GitHub
parent e58d87e94c
commit 96e4a4eb6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 13 additions and 5 deletions

View file

@ -42,12 +42,16 @@ class Subaddress {
List<Subaddress> getAllSubaddresses() { List<Subaddress> getAllSubaddresses() {
final size = monero.Wallet_numSubaddresses(wptr!, accountIndex: subaddress!.accountIndex); final size = monero.Wallet_numSubaddresses(wptr!, accountIndex: subaddress!.accountIndex);
return List.generate(size, (index) { final list = List.generate(size, (index) {
return Subaddress( return Subaddress(
accountIndex: subaddress!.accountIndex, accountIndex: subaddress!.accountIndex,
addressIndex: index, addressIndex: index,
); );
}).reversed.toList(); }).reversed.toList();
if (list.length == 0) {
list.add(Subaddress(addressIndex: subaddress!.accountIndex, accountIndex: 0));
}
return list;
} }
void addSubaddressSync({required int accountIndex, required String label}) { void addSubaddressSync({required int accountIndex, required String label}) {

View file

@ -131,7 +131,7 @@ void storeSync() async {
return monero.Wallet_synchronized(Pointer.fromAddress(addr)); return monero.Wallet_synchronized(Pointer.fromAddress(addr));
}); });
if (lastStorePointer == wptr!.address && if (lastStorePointer == wptr!.address &&
lastStoreHeight + 5000 < monero.Wallet_blockChainHeight(wptr!) && lastStoreHeight + 5000 > monero.Wallet_blockChainHeight(wptr!) &&
!synchronized) { !synchronized) {
return; return;
} }

View file

@ -109,7 +109,7 @@ abstract class MoneroWalletAddressesBase extends WalletAddresses with Store {
accountIndex: accountIndex, accountIndex: accountIndex,
defaultLabel: defaultLabel, defaultLabel: defaultLabel,
usedAddresses: usedAddresses.toList()); usedAddresses: usedAddresses.toList());
subaddress = subaddressList.subaddresses.last; subaddress = (subaddressList.subaddresses.isEmpty) ? Subaddress(id: 0, address: address, label: defaultLabel) : subaddressList.subaddresses.last;
address = subaddress!.address; address = subaddress!.address;
} }

View file

@ -41,12 +41,16 @@ class Subaddress {
List<Subaddress> getAllSubaddresses() { List<Subaddress> getAllSubaddresses() {
final size = wownero.Wallet_numSubaddresses(wptr!, accountIndex: subaddress!.accountIndex); final size = wownero.Wallet_numSubaddresses(wptr!, accountIndex: subaddress!.accountIndex);
return List.generate(size, (index) { final list = List.generate(size, (index) {
return Subaddress( return Subaddress(
accountIndex: subaddress!.accountIndex, accountIndex: subaddress!.accountIndex,
addressIndex: index, addressIndex: index,
); );
}).reversed.toList(); }).reversed.toList();
if (list.isEmpty) {
list.add(Subaddress(addressIndex: 0, accountIndex: subaddress!.accountIndex));
}
return list;
} }
void addSubaddressSync({required int accountIndex, required String label}) { void addSubaddressSync({required int accountIndex, required String label}) {

View file

@ -109,7 +109,7 @@ abstract class WowneroWalletAddressesBase extends WalletAddresses with Store {
accountIndex: accountIndex, accountIndex: accountIndex,
defaultLabel: defaultLabel, defaultLabel: defaultLabel,
usedAddresses: usedAddresses.toList()); usedAddresses: usedAddresses.toList());
subaddress = subaddressList.subaddresses.last; subaddress = (subaddressList.subaddresses.isEmpty) ? Subaddress(id: 0, address: address, label: defaultLabel) : subaddressList.subaddresses.last;
address = subaddress!.address; address = subaddress!.address;
} }