From: Chris Duncan Date: Wed, 23 Jul 2025 15:23:06 +0000 (-0700) Subject: Remove ability to sign block from Block using its account since password is not an... X-Git-Tag: v0.10.5~55^2~20 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=00b9e1c40cbed3ac913a2e67f2bee89c6a06288f;p=libnemo.git Remove ability to sign block from Block using its account since password is not an argument at this time and signing with a locked account should be done from the account itself. --- diff --git a/src/lib/block.ts b/src/lib/block.ts index c424ec9..be9a740 100644 --- a/src/lib/block.ts +++ b/src/lib/block.ts @@ -127,12 +127,8 @@ abstract class Block { } /** - * Signs the block using a private key. If a key is not provided, the private - * key of the block's account will be used if it exists. If that fails, an - * error is thrown. - * - * If successful, the result is stored in the object's `signature` - * property. + * Signs the block using a private key. If successful, the result is stored in + * the object's `signature` property. * * @param {string} [key] - Hexadecimal-formatted private key to use for signing */ @@ -166,15 +162,15 @@ abstract class Block { throw new Error(result.status) } this.signature = result.signature - } else { + } else if (typeof input === 'string') { try { - const account = (typeof input === 'string') - ? await Account.import({ index: 0, privateKey: input }, '') - : this.account + const account = await Account.import({ index: 0, privateKey: input }, '') this.signature = await account.sign(this, '') } catch (err) { throw new Error(`Failed to sign block`, { cause: err }) } + } else { + throw new TypeError('invalid key for block signature', { cause: typeof input }) } }