From 00cb5e6795e5d655f832f82b0ae87ea0f200edce Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Tue, 4 Aug 2026 18:58:21 -0700 Subject: [PATCH] Validate wallet refresh frontier contents. --- src/lib/wallet/refresh.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lib/wallet/refresh.ts b/src/lib/wallet/refresh.ts index ca9513a..15dc5c5 100644 --- a/src/lib/wallet/refresh.ts +++ b/src/lib/wallet/refresh.ts @@ -48,10 +48,17 @@ export async function _refresh (wallet: Wallet, rpc: unknown, from: unknown, to: account.receivable = balances?.[account.address]?.receivable ?? 0 if (frontiers[account.address] != null) { account.frontier = frontiers[account.address] - const { subtype, contents: { balance, link, previous, representative, signature } } = blocks[account.frontier] + const { subtype } = blocks[account.frontier] if (!['change', 'epoch', 'open', 'receive', 'send'].includes(subtype)) { - throw new RangeError('Invalid subtype for account frontier block', { cause: subtype }) - } + throw new RangeError('Invalid subtype for account frontier block', { cause: subtype }) + } + const frontierContents: Record = {} + for (const [k, v] of Object.entries(blocks[account.frontier].contents)) { + if (Schema.block_info.contents.fields.includes(k) && typeof v === 'string') { + frontierContents[k] = v + } + } + const { balance, link, previous, representative, signature } = frontierContents account.representative = representative const frontierBlock = new Block(account, balance, previous, representative) if (typeof frontierBlock[subtype] !== 'function') { -- 2.52.0