Merge pull request #799 from cypherstack/update-epicbox-address-in-isar

Update address to match epicbox config
This commit is contained in:
julian-CStack 2024-05-03 14:26:58 -06:00 committed by GitHub
commit ce9ff9b280
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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;
}