From 4cf5879dc3d8491347fce95c2159802686679d08 Mon Sep 17 00:00:00 2001 From: Anatole Debierre <62328077+a2br@users.noreply.github.com> Date: Wed, 3 Mar 2021 11:28:01 +0100 Subject: [PATCH] Remove unnecessary addBlock param The sender's publicKey can be found in the transaction instance --- index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index f436d99..35bbf00 100644 --- a/index.ts +++ b/index.ts @@ -74,11 +74,11 @@ class Chain { } // Add a new block to the chain if valid signature & proof of work is complete - addBlock(transaction: Transaction, senderPublicKey: string, signature: Buffer) { + addBlock(transaction: Transaction, signature: Buffer) { const verify = crypto.createVerify('SHA256'); verify.update(transaction.toString()); - const isValid = verify.verify(senderPublicKey, signature); + const isValid = verify.verify(transaction.payer, signature); if (isValid) { const newBlock = new Block(this.lastBlock.hash, transaction); @@ -112,7 +112,7 @@ class Wallet { sign.update(transaction.toString()).end(); const signature = sign.sign(this.privateKey); - Chain.instance.addBlock(transaction, this.publicKey, signature); + Chain.instance.addBlock(transaction, signature); } }