This commit is contained in:
Ben Wilson 2023-06-23 16:00:25 -04:00
parent 7b77bf8006
commit a1d8590055

View File

@ -60,9 +60,9 @@ 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 merkleRoot = this.sha256(this.sha256(witnessRootHash));
const commitmentHash = this.sha256(this.sha256(witnessRootHash));
// 39th byte onwards: Optional data with no consensus meaning
this.coinbaseTransaction.outs[0].script = bitcoinjs.script.compile([bitcoinjs.opcodes.OP_RETURN, Buffer.concat([segwitMagicBits, merkleRoot])]);
this.coinbaseTransaction.outs[0].script = bitcoinjs.script.compile([bitcoinjs.opcodes.OP_RETURN, Buffer.concat([segwitMagicBits, commitmentHash])]);
//@ts-ignore
const serializedTx = this.coinbaseTransaction.__toBuffer().toString('hex');