]> git.codecow.com Git - libnemo.git/commitdiff
Validate wallet refresh frontier contents.
authorChris Duncan <chris@codecow.com>
Wed, 5 Aug 2026 01:58:21 +0000 (18:58 -0700)
committerChris Duncan <chris@codecow.com>
Wed, 5 Aug 2026 01:58:21 +0000 (18:58 -0700)
src/lib/wallet/refresh.ts

index ca9513aa3877d088735be0fe58c0bd2d3d2bae03..15dc5c5465369652d419cc89cd8c81430cb30185 100644 (file)
@@ -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<string, string> = {}
+                               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') {