commit 511e81ab040a5b8fb61cd139d99fef15f1bc5ee4
parent 1701b6530b4f2a791630e2603b5f7a910c3e83f2
Author: Iván Ávalos <avalos@disroot.org>
Date: Fri, 26 Sep 2025 16:52:50 +0200
wallet-core: add fixup for token family hash
Diffstat:
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts
@@ -170,7 +170,7 @@ export const CURRENT_DB_CONFIG_KEY = "currentMainDbName";
* backwards-compatible way or object stores and indices
* are added.
*/
-export const WALLET_DB_MINOR_VERSION = 20;
+export const WALLET_DB_MINOR_VERSION = 21;
declare const symDbProtocolTimestamp: unique symbol;
@@ -3062,7 +3062,7 @@ export const WalletStoresV1 = {
"byTokenFamilyHash",
"tokenFamilyHash",
{
- versionAdded: 20,
+ versionAdded: 21,
},
),
},
@@ -3739,6 +3739,12 @@ export const walletDbFixups: FixupDescription[] = [
fn: fixup20250915TransactionsScope,
name: "fixup20250915TransactionsScope",
},
+ // Can be removed, since hash is generated
+ // on the fly for old tokens when missing.
+ {
+ fn: fixupTokenFamilyHash,
+ name: "fixupTokenFamilyHash",
+ },
];
/**
@@ -3851,6 +3857,19 @@ async function fixup20250916TopsBlunder(
}
}
+async function fixupTokenFamilyHash(
+ tx: WalletDbAllStoresReadWriteTransaction,
+): Promise<void> {
+ const tokens = await tx.tokens.getAll();
+ for (const token of tokens) {
+ if (! token.tokenFamilyHash) {
+ logger.info(`hashing token family info for ${token.tokenIssuePubHash}`);
+ token.tokenFamilyHash = TokenRecord.hashInfo(token);
+ await tx.tokens.put(token);
+ }
+ }
+}
+
export async function applyFixups(
db: DbAccess<typeof WalletStoresV1>,
): Promise<number> {
diff --git a/packages/taler-wallet-core/src/tokenFamilies.ts b/packages/taler-wallet-core/src/tokenFamilies.ts
@@ -39,7 +39,6 @@ function groupDiscounts(tokens: TokenRecord[]): DiscountListDetail[] {
const groupedIdx: number[] = [];
const items: DiscountListDetail[] = [];
- // FIXME: write proper DB fixup to generate hashes
tokens = tokens.map(t => {
t.tokenFamilyHash = (t.tokenFamilyHash)
? t.tokenFamilyHash