Fixed issue where if script ended in 00's it would not put nonces in correct position

This commit is contained in:
Ben Wilson 2023-06-30 18:08:41 -04:00
parent 057fbe785f
commit 0c80b084ee

View File

@ -92,7 +92,9 @@ export class MiningJob {
}
// set the nonces
testBlock.transactions[0].ins[0].script = Buffer.from(testBlock.transactions[0].ins[0].script.toString('hex').replace('0000000000000000', `${extraNonce}${extraNonce2}`), 'hex');
const nonceFreeScript = testBlock.transactions[0].ins[0].script.toString('hex');
testBlock.transactions[0].ins[0].script = Buffer.from(`${nonceFreeScript.substring(0, nonceFreeScript.length - 16)}${extraNonce}${extraNonce2}`, 'hex');
//@ts-ignore
//recompute the root