Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
'use strict';

var bitcore = module.exports;
var bitcore = {};

// module information
bitcore.version = 'v' + require('./package.json').version;
bitcore.versionGuard = function(version) {
if (version !== undefined) {
bitcore.versionGuard = function(globalBitcore) {
if (globalBitcore && globalBitcore.version !== bitcore.version) {
var message = 'More than one instance of bitcore-lib found. ' +
'Please make sure to require bitcore-lib and check that submodules do' +
' not also include their own bitcore-lib dependency.';
throw new Error(message);
}
};
bitcore.versionGuard(global._bitcore);
global._bitcore = bitcore.version;

// Return the original loaded bitcore-lib
if(global._bitcore) {
module.exports = global._bitcore;
return;
}

global._bitcore = bitcore;

// crypto
bitcore.crypto = {};
Expand Down Expand Up @@ -68,3 +75,5 @@ bitcore.deps._ = require('lodash');
// Internal usage, exposed for testing/advanced tweaking
bitcore._HDKeyCache = require('./lib/hdkeycache');
bitcore.Transaction.sighash = require('./lib/transaction/sighash');

module.exports = bitcore;