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

index f956dc814976a8de4e885f362bc5e6d0f7788a90..3fc558c196d7c03d2f56f72d54aae2efd48837e6 100644 (file)
@@ -46,7 +46,7 @@ export async function _refresh (account: Account, rpc: unknown): Promise<void> {
                throw new Error('Confirmed frontier block info subtype not found')
        }
        const confirmedFrontierSubtype = resConfirmedFrontierBlockInfo.subtype
-       if (!['change', 'epoch', 'open', 'receive', 'send'].includes(confirmedFrontierSubtype) {
+       if (!['change', 'epoch', 'open', 'receive', 'send'].includes(confirmedFrontierSubtype)) {
                throw new RangeError('Invalid subtype for confirmed frontier block', { cause: confirmedFrontierSubtype })
        }
        if (!('contents' in resConfirmedFrontierBlockInfo) || resConfirmedFrontierBlockInfo.contents == null || typeof resConfirmedFrontierBlockInfo.contents !== 'object') {
@@ -77,7 +77,7 @@ export async function _refresh (account: Account, rpc: unknown): Promise<void> {
                throw new Error('Frontier block info subtype not found')
        }
        const frontierSubtype = resFrontierBlockInfo.subtype
-       if (!['change', 'epoch', 'open', 'receive', 'send'].includes(frontierSubtype) {
+       if (!['change', 'epoch', 'open', 'receive', 'send'].includes(frontierSubtype)) {
                throw new RangeError('Invalid subtype for frontier block', { cause: frontierSubtype })
        }
        if (!('contents' in resFrontierBlockInfo) || resFrontierBlockInfo.contents == null || typeof resFrontierBlockInfo.contents !== 'object') {
index 24e4dcfdd30f683e02d8b8a226f26ccfe9fc2b18..ca9513aa3877d088735be0fe58c0bd2d3d2bae03 100644 (file)
@@ -49,6 +49,9 @@ export async function _refresh (wallet: Wallet, rpc: unknown, from: unknown, to:
                        if (frontiers[account.address] != null) {
                                account.frontier = frontiers[account.address]
                                const { subtype, contents: { balance, link, previous, representative, signature } } = blocks[account.frontier]
+                               if (!['change', 'epoch', 'open', 'receive', 'send'].includes(subtype)) {
+               throw new RangeError('Invalid subtype for account frontier block', { cause: subtype })
+       }
                                account.representative = representative
                                const frontierBlock = new Block(account, balance, previous, representative)
                                if (typeof frontierBlock[subtype] !== 'function') {