From 30e12345443776e5426e2f85abc6f78554875eb7 Mon Sep 17 00:00:00 2001 From: Nesopie Date: Wed, 27 Mar 2024 19:20:08 +0530 Subject: [PATCH] fix: merkle root calculation --- src/features/block/merkleRoot.ts | 4 +--- src/features/block/mine.ts | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/features/block/merkleRoot.ts b/src/features/block/merkleRoot.ts index b1c3864..dce49a4 100644 --- a/src/features/block/merkleRoot.ts +++ b/src/features/block/merkleRoot.ts @@ -1,6 +1,4 @@ -import { Transaction } from "../../types"; -import { reversify, sha256 } from "../../utils"; -import { txSerializer } from "../encoding/serializer"; +import { sha256 } from "../../utils"; export const merkleRoot = (txs: string[]) => { let curr = txs; diff --git a/src/features/block/mine.ts b/src/features/block/mine.ts index ab124b5..0b51f6b 100644 --- a/src/features/block/mine.ts +++ b/src/features/block/mine.ts @@ -34,7 +34,7 @@ export const mine = ( const prevBlockHash = DIFFICULTY; //make it the same as the difficulty const merkleRootHash = merkleRoot( - [coinbaseTransaction, ...txs].map((tx) => tx.txid) + [coinbaseTransaction, ...txs].map((tx) => reversify(tx.txid)) ); const time = Buffer.alloc(4);