}
export type AccountInfoResponse = {
- account_version: string
+ account_version: '1' | '2'
balance: string
block_count: string
confirmation_height?: string
confirmed_representative: string
frontier: Hex
modified_timestamp: string
- open_block: string
+ open_block: Hex
pending?: string
receivable: string
representative: string
export function account_info (body: unknown): AccountInfoResponse {
if (body != null && typeof body === 'object') {
- if ('account_version' in body && typeof body.account_version === 'string'
+ if ('account_version' in body && (body.account_version === '1' || body.account_version === '2')
&& 'balance' in body && typeof body.balance === 'string'
&& 'block_count' in body && typeof body.block_count === 'string'
&& 'confirmed_balance' in body && typeof body.confirmed_balance === 'string'
- && 'confirmed_frontier' in body && hex.is(body.confirmed_frontier)
+ && 'confirmed_frontier' in body && hex.is(body.confirmed_frontier, 64)
&& 'confirmed_height' in body && typeof body.confirmed_height === 'string'
&& 'confirmed_receivable' in body && typeof body.confirmed_receivable === 'string'
&& 'confirmed_representative' in body && typeof body.confirmed_representative === 'string'
- && 'frontier' in body && hex.is(body.frontier)
+ && 'frontier' in body && hex.is(body.frontier, 64)
&& 'modified_timestamp' in body && typeof body.modified_timestamp === 'string'
- && 'open_block' in body && typeof body.open_block === 'string'
+ && 'open_block' in body && hex.is(body.open_block, 64)
&& 'receivable' in body && typeof body.receivable === 'string'
&& 'representative' in body && typeof body.representative === 'string'
&& 'representative_block' in body && typeof body.representative_block === 'string'
for (const [address, frontier] of Object.entries(frontiers) as [string, unknown][]) {
try {
Account.validate(address)
- if (hex.is(frontier)) {
+ if (hex.is(frontier, 64)) {
response.frontiers ??= {}
response.frontiers[address] = frontier
}
//! SPDX-FileCopyrightText: 2026 Chris Duncan <chris@codecow.com>
//! SPDX-License-Identifier: GPL-3.0-or-later
+import { Account } from '../account'
+import { hex } from '../convert'
import { RpcError } from '../errors'
export type BlockInfoRequest = {
&& 'contents' in body && body.contents != null && typeof body.contents === 'object'
&& 'account' in body.contents && typeof body.contents.account === 'string'
&& 'balance' in body.contents && typeof body.contents.balance === 'string'
- && 'link' in body.contents && typeof body.contents.link === 'string' && /^[0-9A-F]{64}$/i.test(body.contents.link)
- && 'link_as_account' in body.contents && typeof body.contents.link_as_account === 'string'
- && 'previous' in body.contents && typeof body.contents.previous === 'string' && /^[0-9A-F]{64}$/i.test(body.contents.previous)
+ && 'link' in body.contents && hex.is(body.contents.link, 64)
+ && 'link_as_account' in body.contents && Account.validate(body.contents.link_as_account)
+ && 'previous' in body.contents && hex.is(body.contents.previous, 64)
&& 'representative' in body.contents && typeof body.contents.representative === 'string'
- && 'signature' in body.contents && typeof body.contents.signature === 'string' && /^[0-9A-F]{128}$/i.test(body.contents.signature)
+ && 'signature' in body.contents && hex.is(body.contents.signature, 128)
&& 'type' in body.contents && body.contents.type === 'state'
&& 'work' in body.contents && typeof body.contents.work === 'string'
) {