From: Chris Duncan Date: Fri, 8 Aug 2025 01:05:04 +0000 (-0700) Subject: Use public key for open block pow per spec. X-Git-Tag: v0.10.5~43^2~46 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=fe39654d18ce234df3161c377768f92a5b9293dc;p=libnemo.git Use public key for open block pow per spec. --- 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 }) }