Update address to match epicbox config

This commit is contained in:
likho 2024-03-08 19:31:34 +02:00
parent 7cebd31268
commit ed42dba9cc

View file

@ -317,6 +317,7 @@ class EpiccashWallet extends Bip39Wallet {
Future<Address> _generateAndStoreReceivingAddressForIndex(
int index,
) async {
Address? address = await getCurrentReceivingAddress();
EpicBoxConfigModel epicboxConfig = await getEpicBoxConfig();
@ -325,6 +326,7 @@ class EpiccashWallet extends Bip39Wallet {
//Check if the address is the same as the current epicbox domain
//Since we're only using one epicbpox now this doesn't apply but will be
// useful in the future
final encodedConfig = jsonEncode(epicboxConfig);
if (splitted[1] != epicboxConfig.host) {
//Update the address
address = await thisWalletAddress(index, epicboxConfig);
@ -332,6 +334,13 @@ class EpiccashWallet extends Bip39Wallet {
} else {
address = await thisWalletAddress(index, epicboxConfig);
}
if (info.cachedReceivingAddress != address.value) {
await info.updateReceivingAddress(
newAddress: address.value,
isar: mainDB.isar,
);
}
return address;
}
@ -360,7 +369,6 @@ class EpiccashWallet extends Bip39Wallet {
subType: AddressSubType.receiving,
publicKey: [], // ??
);
await mainDB.updateOrPutAddresses([address]);
return address;
}