How to use the @tradle/bitcoinjs-lib.Block function in @tradle/bitcoinjs-lib

To help you get started, we’ve selected a few @tradle/bitcoinjs-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tradle / engine / test / bitcoin-fakechain.js View on Github external
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
}