forked from aspectron/kaspa-core-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
93 lines (81 loc) · 3.18 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
'use strict';
var kaspacore = module.exports;
// module information
kaspacore.version = 'v' + require('./package.json').version;
kaspacore.versionGuard = function(version) {
if (version !== undefined) {
var message = 'More than one instance of kaspacore-lib found. ' +
'Please make sure to require kaspacore-lib and check that submodules do' +
' not also include their own kaspacore-lib dependency.';
throw new Error(message);
}
};
kaspacore.versionGuard(global._kaspacoreLibVersion);
global._kaspacoreLibVersion = kaspacore.version;
const deferred = ()=>{
let methods = {};
let promise = new Promise((resolve, reject)=>{
methods = {resolve, reject};
})
Object.assign(promise, methods);
return promise;
}
const readySignal = deferred();
kaspacore.ready = ()=>{
readySignal.resolve(true);
}
kaspacore.initRuntime = ()=>{
return readySignal;
}
// crypto
kaspacore.crypto = {};
kaspacore.crypto.BN = require('./lib/crypto/bn');
kaspacore.crypto.ECDSA = require('./lib/crypto/ecdsa');
kaspacore.crypto.Schnorr = require('./lib/crypto/schnorr');
kaspacore.crypto.Hash = require('./lib/crypto/hash');
kaspacore.crypto.Random = require('./lib/crypto/random');
kaspacore.crypto.Point = require('./lib/crypto/point');
kaspacore.crypto.Signature = require('./lib/crypto/signature');
// encoding
kaspacore.encoding = {};
kaspacore.encoding.Base58 = require('./lib/encoding/base58');
kaspacore.encoding.Base58Check = require('./lib/encoding/base58check');
kaspacore.encoding.BufferReader = require('./lib/encoding/bufferreader');
kaspacore.encoding.BufferWriter = require('./lib/encoding/bufferwriter');
kaspacore.encoding.Varint = require('./lib/encoding/varint');
// utilities
kaspacore.util = {};
kaspacore.util.buffer = require('./lib/util/buffer');
kaspacore.util.js = require('./lib/util/js');
kaspacore.util.preconditions = require('./lib/util/preconditions');
kaspacore.util.base32 = require('./lib/util/base32');
kaspacore.util.convertBits = require('./lib/util/convertBits');
kaspacore.setDebugLevel = (level)=>{
kaspacore.util.js.debugLevel = level;
}
// errors thrown by the library
kaspacore.errors = require('./lib/errors');
// main bitcoin library
kaspacore.Address = require('./lib/address');
kaspacore.Block = require('./lib/block');
kaspacore.MerkleBlock = require('./lib/block/merkleblock');
kaspacore.BlockHeader = require('./lib/block/blockheader');
kaspacore.HDPrivateKey = require('./lib/hdprivatekey.js');
kaspacore.HDPublicKey = require('./lib/hdpublickey.js');
kaspacore.Networks = require('./lib/networks');
kaspacore.Opcode = require('./lib/opcode');
kaspacore.PrivateKey = require('./lib/privatekey');
kaspacore.PublicKey = require('./lib/publickey');
kaspacore.Script = require('./lib/script');
kaspacore.Transaction = require('./lib/transaction');
kaspacore.URI = require('./lib/uri');
kaspacore.Unit = require('./lib/unit');
// dependencies, subject to change
kaspacore.deps = {};
kaspacore.deps.bnjs = require('bn.js');
kaspacore.deps.bs58 = require('bs58');
kaspacore.deps.Buffer = Buffer;
kaspacore.deps.elliptic = require('elliptic');
kaspacore.deps._ = require('lodash');
// Internal usage, exposed for testing/advanced tweaking
kaspacore.Transaction.sighash = require('./lib/transaction/sighash');