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