Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function addFakeBlock (blocks) {
const b = new bitcoin.Block()
if (blocks.length) {
b.prevHash = blocks[blocks.length - 1].getHash()
} else {
b.prevHash = crypto.randomBytes(32)
}
b.merkleRoot = crypto.randomBytes(32)
b.timestamp = Date.now() / 1000
b.bits = Math.random() * 100000000 | 0
b.nonce = Math.random() * 100000000 | 0
b.height = b.blockHeight = blocks.length
b.transactions = []
blocks.push(b)
return b
}