From efc65f284075a4e2577089f7626cb4df5d5dddab Mon Sep 17 00:00:00 2001 From: Daniel Cogan Date: Fri, 17 Mar 2023 16:39:59 -0700 Subject: [PATCH] Add noteSize and noteCommitment to getBlock RPC (#3665) --- ironfish/src/rpc/routes/chain/getBlock.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ironfish/src/rpc/routes/chain/getBlock.ts b/ironfish/src/rpc/routes/chain/getBlock.ts index 64762b09de..a5154d3e9e 100644 --- a/ironfish/src/rpc/routes/chain/getBlock.ts +++ b/ironfish/src/rpc/routes/chain/getBlock.ts @@ -23,6 +23,8 @@ export type GetBlockResponse = { previousBlockHash: string sequence: number timestamp: number + noteSize: number + noteCommitment: string transactions: Array<{ fee: string hash: string @@ -57,6 +59,8 @@ export const GetBlockResponseSchema: yup.ObjectSchema = yup previousBlockHash: yup.string().defined(), sequence: yup.number().defined(), timestamp: yup.number().defined(), + noteSize: yup.number().defined(), + noteCommitment: yup.string().defined(), transactions: yup .array( yup @@ -124,6 +128,10 @@ router.register( throw new ValidationError(error) } + if (header.noteSize === null) { + throw new ValidationError('Block header was saved to database without a note size') + } + const block = await node.chain.getBlock(header) if (!block) { throw new ValidationError(`No block with header ${header.hash.toString('hex')}`) @@ -154,6 +162,8 @@ router.register( previousBlockHash: header.previousBlockHash.toString('hex'), sequence: Number(header.sequence), timestamp: header.timestamp.valueOf(), + noteSize: header.noteSize, + noteCommitment: header.noteCommitment.toString('hex'), transactions: transactions, }, metadata: {