From fe39654d18ce234df3161c377768f92a5b9293dc Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 7 Aug 2025 18:05:04 -0700 Subject: [PATCH] Use public key for open block pow per spec. --- src/lib/block.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/block.ts b/src/lib/block.ts index 6bc6315..4199f29 100644 --- a/src/lib/block.ts +++ b/src/lib/block.ts @@ -229,8 +229,9 @@ export class Block { const difficulty: bigint = (this.subtype === 'send' || this.subtype === 'change') ? DIFFICULTY_SEND : DIFFICULTY_RECEIVE + const hash = +this.previous === 0 ? this.account.publicKey : this.previous if (work == null) { - const result = await NanoPow.work_generate(this.previous, { difficulty }) + const result = await NanoPow.work_generate(hash, { difficulty }) if ('error' in result) { throw new Error('Failed to generate work', { cause: result.error }) } @@ -239,7 +240,7 @@ export class Block { if (typeof work !== 'string') { throw new TypeError('Invalid work') } - const check = await NanoPow.work_validate(work, this.previous, { difficulty }) + const check = await NanoPow.work_validate(work, hash, { difficulty }) if ('error' in check) { throw new Error('Failed to validate work generated', { cause: check.error }) } -- 2.47.3