Skip to content

Commit

Permalink
fix: merkle root calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nesopie committed Mar 25, 2024
1 parent 2464bc1 commit d12dea0
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/features/block/mine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ export const mine = (
"0000ffff00000000000000000000000000000000000000000000000000000000";
const version = Buffer.alloc(4);
version.writeInt32LE(4);
//make it the same as the difficulty

const witnessMerkleRootHash = reversify(
merkleRoot([
ZEROS, //zeros are for the coinbase transaction
...txs.map((tx) => sha256(sha256(txSerializer(tx).serializedWTx))),
])
);
const witnessMerkleRootHash = merkleRoot([
ZEROS, //zeros are for the coinbase transaction
...txs.map((tx) => sha256(sha256(txSerializer(tx).serializedWTx))),
]);
const commitmentHash = sha256(sha256(witnessMerkleRootHash + ZEROS));
const fees = totalFee(txs);
const coinbaseTransaction = generateCoinbaseTransaction(fees, commitmentHash);
Expand Down

0 comments on commit d12dea0

Please sign in to comment.