From: Chris Duncan Date: Wed, 5 Aug 2026 01:58:21 +0000 (-0700) Subject: Validate wallet refresh frontier contents. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=00cb5e6795e5d655f832f82b0ae87ea0f200edce;p=libnemo.git Validate wallet refresh frontier contents. --- 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') {