How to use the bsv.deps function in bsv

To help you get started, we’ve selected a few bsv 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 libitx / proxypay / src / proxy-payment.js View on Github external
const bsv = require('bsv')
const bitdb = require('./bitdb')
const bitindex = require('./bitindex')

// Use built-in all fallback to bsv Buffer
const _Buffer = typeof Buffer === 'function' ? Buffer : bsv.deps.Buffer;

const DUST_LIMIT = 547;

const defaults = {
  inputs: [],
  outpus: [],
  onCreate() { this.listen() },
  onFunded() { this.broadcast() },
  onPayment(tx) { console.log('Success', tx) },
  onError(err) { console.error('Error', err) },
  debug: false
}

class ProxyPayment {
  constructor(options) {
    this.options = {
github deanmlittle / bsv-p2p / lib / inventory.js View on Github external
'use strict';

var bsv = require('bsv');
var $ = bsv.util.preconditions;
var Buffer = require('buffer').Buffer;
var reverse = require('buffer-reverse');
var BufferReader = bsv.encoding.BufferReader;
var BufferWriter = bsv.encoding.BufferWriter;
var _ = bsv.deps._;

/**
 * A constructor for inventory related Bitcoin messages such as
 * "getdata", "inv" and "notfound".
 * @param {Object} obj
 * @param {Number} obj.type - Inventory.TYPE
 * @param {Buffer} obj.hash - The hash for the inventory
 * @constructor
 */
function Inventory(obj) {
  this.type = obj.type;
  if (!Buffer.isBuffer(obj.hash)) {
    throw new TypeError('Unexpected hash, expected to be a buffer');
  }
  this.hash = obj.hash;
}