block copy

This commit is contained in:
Ben Wilson
2023-07-30 17:59:51 -04:00
parent 89e785182c
commit e38f4e1edc
4 changed files with 13 additions and 14 deletions
+6 -4
View File
@@ -58,9 +58,11 @@ export class MiningJob {
}
public copyAndUpdateBlock(jobTemplate: { data: IJobTemplate, blockBuffer: Buffer }, versionMask: number, nonce: number, extraNonce: string, extraNonce2: string, timestamp: number): bitcoinjs.Block {
public copyAndUpdateBlock(jobTemplate: IJobTemplate, versionMask: number, nonce: number, extraNonce: string, extraNonce2: string, timestamp: number): bitcoinjs.Block {
const testBlock = Object.assign(new bitcoinjs.Block(), jobTemplate.block);
const testBlock = bitcoinjs.Block.fromBuffer(jobTemplate.blockBuffer);
testBlock.transactions[0] = this.coinbaseTransaction;
@@ -77,12 +79,12 @@ export class MiningJob {
testBlock.transactions[0].ins[0].script = Buffer.from(`${nonceScript.substring(0, nonceScript.length - 16)}${extraNonce}${extraNonce2}`, 'hex');
//recompute the root since we updated the coinbase script with the nonces
testBlock.merkleRoot = this.calculateMerkleRootHash(testBlock.transactions[0].getHash(false), jobTemplate.data.merkle_branch);
testBlock.merkleRoot = this.calculateMerkleRootHash(testBlock.transactions[0].getHash(false), jobTemplate.merkle_branch);
testBlock.timestamp = timestamp;
return testBlock;
return testBlock as any;
}