start to split into node commonjs style modules
- no longer is the global Bitcoin used for modules - cleaner and more maintainable code - add more tests
This commit is contained in:
parent
a6f05fb505
commit
0faac29134
35 changed files with 3401 additions and 3169 deletions
src
46
src/index.js
Normal file
46
src/index.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Bit-wise rotate left
|
||||
var rotl = function (n, b) {
|
||||
return (n << b) | (n >>> (32 - b));
|
||||
};
|
||||
|
||||
// Bit-wise rotate right
|
||||
var rotr = function (n, b) {
|
||||
return (n << (32 - b)) | (n >>> b);
|
||||
};
|
||||
|
||||
// Swap big-endian to little-endian and vice versa
|
||||
var endian = function (n) {
|
||||
// If number given, swap endian
|
||||
if (n.constructor == Number) {
|
||||
return rotl(n, 8) & 0x00FF00FF | rotl(n, 24) & 0xFF00FF00;
|
||||
}
|
||||
|
||||
// Else, assume array and swap all items
|
||||
for (var i = 0; i < n.length; i++) {
|
||||
n[i] = endian(n[i]);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Address: require('./address'),
|
||||
Key: require('./eckey'),
|
||||
BigInteger: require('./jsbn/jsbn'),
|
||||
Script: require('./script'),
|
||||
Opcode: require('./opcode'),
|
||||
Transaction: require('./transaction').Transaction,
|
||||
TransactionIn: require('./transaction').TransactionIn,
|
||||
TransactionOut: require('./transaction').TransactionOut,
|
||||
ECPointFp: require('./jsbn/ec').ECPointFp,
|
||||
Wallet: require('./wallet'),
|
||||
|
||||
ecdsa: require('./ecdsa'),
|
||||
|
||||
// base58 encoding/decoding to bytes
|
||||
base58: require('./base58'),
|
||||
|
||||
// conversions
|
||||
convert: require('./convert'),
|
||||
|
||||
endian: endian
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue