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 })
}
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 })
}