How to use the @tradle/bitcoinjs-lib.networks 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 / tim-old-engine / lib / optimizations.js View on Github external
utils.sharedEncryptionKey = function (aPriv, bPub, cb) {
    // TODO: unhardcode network
    if (typeof aPriv !== 'string') aPriv = aPriv.toWIF(bitcoin.networks.testnet)
    if (typeof bPub !== 'string') bPub = bPub.toHex()

    var key = aPriv + bPub
    var cached = ecdhCache.get(key)
    if (!cb) {
      if (!cached) {
        cached = sharedEncryptionKey.apply(this, arguments)
        ecdhCache.set(key, cached)
      }

      return cached
    }

    if (cached) return cb(null, cached)

    sharedEncryptionKey.call(utils, aPriv, bPub, function (err, result) {
github tradle / engine / test / bitcoin-fakechain.js View on Github external
const unspents = []
  opts.unspents.forEach(({ address, amounts }) => {
    const tx = fund(address, amounts)
    tx.outs.forEach(function (o, i) {
      unspents.push({
        txId: tx.getId(),
        confirmations: 6,
        address,
        value: o.value,
        vout: i
      })
    })
  })

  const fakechain = createFakeChain({
    network: bitcoin.networks[network.name],
    unspents,
    blocktime
  })

  const wrapper = utils.extend(new EventEmitter(), network.wrapCommonBlockchain(fakechain))
  fakechain.on('block', block => wrapper.emit('block', block))
  return wrapper
}