Skip to content

Commit

Permalink
feat: add validation checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Nesopie committed Mar 31, 2024
1 parent 3e32cb3 commit 74fdba5
Show file tree
Hide file tree
Showing 23 changed files with 4,033 additions and 3,924 deletions.
6,001 changes: 2,963 additions & 3,038 deletions output.txt

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export const ZERO =
"0000000000000000000000000000000000000000000000000000000000000000";

export const DIFFICULTY =
"0000ffff00000000000000000000000000000000000000000000000000000000";

Expand Down
5 changes: 0 additions & 5 deletions src/features/block/mine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ export const mine = (
const version = Buffer.alloc(4);
version.writeInt32LE(4);

// const witnessMerkleRootHash = merkleRoot([
// ZEROS, //zeros are for the coinbase transaction
// ...txs.map((tx) => sha256(sha256(txSerializer(tx).serializedWTx))),
// ]);
const witnessMerkleRootHash = merkleRoot([
WITNESS_RESERVED_VALUE,
...txs.map((tx) => reversify(tx.wtxid)),
Expand All @@ -39,7 +35,6 @@ export const mine = (

const time = Buffer.alloc(4);
time.writeUint32LE(Math.floor(Date.now() / 1000));
// const nbits = "1f00ffff";
const nbits = Buffer.alloc(4);
nbits.writeUint32LE(0x1f00ffff);

Expand Down
Loading

0 comments on commit 74fdba5

Please sign in to comment.