Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
var chai = require('chai');
var Net = require('net');
var Socks5Client = require('socks5-client');
/* jshint unused: false */
var should = chai.should();
var expect = chai.expect;
var sinon = require('sinon');
var fs = require('fs');
var bitcore = require('bitcore-lib');
var _ = bitcore.deps._;
var P2P = require('../');
var Peer = P2P.Peer;
var EventEmitter = require('events').EventEmitter;
var Messages = P2P.Messages;
var messages = new Messages();
var Networks = bitcore.Networks;
describe('Peer', function() {
describe('Integration test', function() {
it('parses this stream of data from a connection', function(callback) {
var peer = new Peer('');
var stub = sinon.stub();
var dataCallback;
var connectCallback;
var expected = {
'use strict';
var chai = require('chai');
/* jshint unused: false */
var should = chai.should();
var sinon = require('sinon');
var bitcore = require('bitcore-lib');
var _ = bitcore.deps._;
var Random = bitcore.crypto.Random;
var BN = bitcore.crypto.BN;
var BufferUtil = bitcore.util.buffer;
var p2p = require('../');
var Peer = p2p.Peer;
var Pool = p2p.Pool;
var Networks = bitcore.Networks;
var Messages = p2p.Messages;
var Inventory = p2p.Inventory;
var Block = bitcore.Block;
var Transaction = bitcore.Transaction;
// config
var network = process.env.NETWORK === 'testnet' ? Networks.testnet : Networks.livenet;
var messages = new Messages({
network: network
'use strict';
var util = require('util');
var EventEmitter = require('events').EventEmitter;
var async = require('async');
var assert = require('assert');
var bitcore = require('bitcore-lib');
var _ = bitcore.deps._;
var index = require('./');
var log = index.log;
var Bus = require('./bus');
var errors = require('./errors');
function Node(config) {
if(!(this instanceof Node)) {
return new Node(config);
}
this._init(config);
if (!_.isUndefined(config.formatLogs)) {
this.log.formatting = config.formatLogs ? true : false;
}
'use strict';
var async = require('async');
var fs = require('fs');
var path = require('path');
var spawn = require('child_process').spawn;
var bitcore = require('bitcore-lib');
var $ = bitcore.util.preconditions;
var _ = bitcore.deps._;
var utils = require('../utils');
/**
* Will remove a service from bitcore-node.json
* @param {String} configFilePath - The absolute path to the configuration file
* @param {String} service - The name of the module
* @param {Function} done
*/
function removeConfig(configFilePath, service, done) {
$.checkArgument(utils.isAbsolutePath(configFilePath), 'An absolute path is expected');
fs.readFile(configFilePath, function(err, data) {
if (err) {
return done(err);
}
var config = JSON.parse(data);
$.checkState(
'use strict';
var inherits = require('inherits');
var $ = require('bitcore-lib').util.preconditions;
var Script = require('bitcore-lib').Script;
var Transaction = require('bitcore-lib').Transaction;
var _ = require('bitcore-lib').deps._;
/**
* A commitment transaction (also referred to as Lock transaction).
*
* @constructor
* @param {Object} opts
* @param {Array.} opts.publicKeys
* @param {string|bitcore.Network} opts.network - livenet by default
*/
function Commitment(opts) {
$.checkArgument(opts.publicKeys && opts.publicKeys.length === 2, 'Must provide exactly two public keys');
Transaction.call(this, opts.transaction);
this.network = opts.network || 'livenet';
this.publicKeys = opts.publicKeys;
var fs = require('fs');
var BaseService = require('../../service');
var inherits = require('util').inherits;
var async = require('async');
var mkdirp = require('mkdirp');
var index = require('../../');
var log = index.log;
var errors = index.errors;
var bitcore = require('bitcore-lib');
var Networks = bitcore.Networks;
var levelup = require('levelup');
var leveldown = require('leveldown');
var memdown = require('memdown');
var $ = bitcore.util.preconditions;
var _ = bitcore.deps._;
var Hash = bitcore.crypto.Hash;
var EventEmitter = require('events').EventEmitter;
var Address = bitcore.Address;
var AddressHistory = require('./history');
var constants = require('./constants');
var encoding = require('./encoding');
var InputsTransformStream = require('./streams/inputs-transform');
var OutputsTransformStream = require('./streams/outputs-transform');
/**
* The Address Service builds upon the Database Service and the Bitcoin Service to add additional
* functionality for getting information by base58check encoded addresses. This includes getting the
* balance for an address, the history for a collection of addresses, and unspent outputs for
* constructing transactions. This is typically the core functionality for building a wallet.
* @param {Object} options
'use strict';
var Payment = require('./transactions/payment');
var Refund = require('./transactions/refund');
var $ = require('bitcore-lib').util.preconditions;
var PrivateKey = require('bitcore-lib').PrivateKey;
var Script = require('bitcore-lib').Script;
var Address = require('bitcore-lib').Address;
var Networks = require('bitcore-lib').Networks;
var _ = require('bitcore-lib').deps._;
/**
* @constructor
*/
function Provider(opts) {
this.network = Networks.get(opts.network) || Networks.defaultNetwork;
if (!opts.paymentAddress) {
this.paymentKey = new PrivateKey();
this.paymentAddress = this.paymentKey.toAddress(this.network);
} else {
this.paymentAddress = new Address(opts.paymentAddress);
}
this.currentAmount = opts.currentAmount || 0;
this.key = opts.key || new PrivateKey();
}
'use strict';
var spawn = require('child_process').spawn;
var bitcore = require('bitcore-lib');
var async = require('async');
var $ = bitcore.util.preconditions;
var _ = bitcore.deps._;
var path = require('path');
var packageFile = require('../../package.json');
var mkdirp = require('mkdirp');
var fs = require('fs');
var defaultConfig = require('./default-config');
var version = '^' + packageFile.version;
var BASE_PACKAGE = {
description: 'A full Bitcoin node build with Bitcore',
repository: 'https://github.com/user/project',
license: 'MIT',
readme: 'README.md',
dependencies: {
'bitcore-lib': '^' + bitcore.version,
'bitcore-node': version
'use strict';
var async = require('async');
var fs = require('fs');
var path = require('path');
var spawn = require('child_process').spawn;
var bitcore = require('bitcore-lib');
var utils = require('../utils');
var $ = bitcore.util.preconditions;
var _ = bitcore.deps._;
/**
* @param {String} configFilePath - The absolute path to the configuration file
* @param {String} service - The name of the service
* @param {Function} done
*/
function addConfig(configFilePath, service, done) {
$.checkState(utils.isAbsolutePath(configFilePath), 'An absolute path is expected');
fs.readFile(configFilePath, function(err, data) {
if (err) {
return done(err);
}
var config = JSON.parse(data);
$.checkState(
Array.isArray(config.services),
'Configuration file is expected to have a services array.'
'use strict';
var path = require('path');
var BitcoreNode = require('../node');
var index = require('../');
var bitcore = require('bitcore-lib');
var _ = bitcore.deps._;
var log = index.log;
var shuttingDown = false;
var fs = require('fs');
function start(options) {
var fullConfig = _.clone(options.config);
var servicesPath;
if (options.servicesPath) {
servicesPath = options.servicesPath;
} else {
servicesPath = options.path;
}
fullConfig.path = path.resolve(options.path, './bitcore-node.json');