From 896125c08ba64cd18187f76f09c86efc70c32b48 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 7 Jul 2023 07:44:20 -0400 Subject: [PATCH] reserved value --- src/models/MiningJob.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/MiningJob.ts b/src/models/MiningJob.ts index f2d41ca..23e415c 100644 --- a/src/models/MiningJob.ts +++ b/src/models/MiningJob.ts @@ -53,7 +53,7 @@ export class MiningJob { // 4-byte - Commitment header (0xaa21a9ed) const segwitMagicBits = Buffer.from('aa21a9ed', 'hex'); // 32-byte - Commitment hash: Double-SHA256(witness root hash|witness reserved value) - const commitmentHash = this.sha256(this.sha256(Buffer.concat([this.block.witnessCommit, Buffer.alloc(32, 0)]))); + const commitmentHash = this.sha256(this.sha256(Buffer.concat([this.block.witnessCommit, coinbaseTransaction.ins[0].witness[0]]))); // 39th byte onwards: Optional data with no consensus meaning coinbaseTransaction.ins[0].script = Buffer.concat([Buffer.from([littleEndianBlockHeight.byteLength]), littleEndianBlockHeight, Buffer.from('00000000' + '00000000', 'hex')]); coinbaseTransaction.addOutput(bitcoinjs.script.compile([bitcoinjs.opcodes.OP_RETURN, Buffer.concat([segwitMagicBits, commitmentHash])]), 0);