Fixes for randomize addresses for electrum wallets

This commit is contained in:
M 2022-01-12 16:32:56 +02:00
parent d6b9753ffa
commit 3b70cc91fe

View file

@ -132,7 +132,16 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
}
void randomizeAddress() {
const minCountOfVisibleAddresses = 5;
final random = Random();
address = addresses[random.nextInt(addresses.length)].address;
var availableAddresses = addresses
.where((addr) => !addr.isHidden)
.toList();
if (availableAddresses.length < minCountOfVisibleAddresses) {
availableAddresses = addresses;
}
address = availableAddresses[random.nextInt(availableAddresses.length)].address;
}
}