Merge branch 'master' of github.com:bitpay/bitcore into feature/better-docs
This commit is contained in:
commit
f7f5ce0661
|
@ -7,7 +7,14 @@ module.exports.bignum = require('bignum');
|
|||
module.exports.base58 = require('base58-native');
|
||||
module.exports.EncodedData = require('./util/EncodedData');
|
||||
module.exports.VersionedData = require('./util/VersionedData');
|
||||
module.exports.Address= require('./Address');
|
||||
module.exports.Address = require('./Address');
|
||||
module.exports.config = require('./config');
|
||||
module.exports.log = require('./util/log');
|
||||
module.exports.Opcode = require('./Opcode');
|
||||
module.exports.util = require('./util/util');
|
||||
module.exports.Script = require('./Script');
|
||||
module.exports.SINKey = require('./SINKey');
|
||||
//module.exports.Transaction = require('./Transaction');
|
||||
|
||||
|
||||
if (typeof process.versions === 'undefined') {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
// load modules needed for testing in the browser
|
||||
|
||||
var fs = require('fs');
|
||||
//var fs = require('fs');
|
||||
|
||||
|
|
20
networks.js
20
networks.js
|
@ -16,21 +16,21 @@ exports.livenet = {
|
|||
bits: 486604799
|
||||
},
|
||||
genesisBlockTx: {
|
||||
'outs': [{
|
||||
'v': hex('00F2052A01000000'), // 50 BTC
|
||||
's': new Put()
|
||||
outs: [{
|
||||
v: hex('00F2052A01000000'), // 50 BTC
|
||||
s: new Put()
|
||||
.word8(65) // 65 bytes of data follow
|
||||
.put(hex('04678AFDB0FE5548271967F1A67130B7105CD6A828E03909A67962E0EA1F61DEB649F6BC3F4CEF38C4F35504E51EC112DE5C384DF7BA0B8D578A4C702B6BF11D5F'))
|
||||
.word8(0xAC) // OP_CHECKSIG
|
||||
.buffer()
|
||||
}],
|
||||
'lock_time': 0,
|
||||
'version': 1,
|
||||
'hash': hex('3BA3EDFD7A7B12B27AC72C3E67768F617FC81BC3888A51323A9FB8AA4B1E5E4A'),
|
||||
'ins': [{
|
||||
'q': 0xFFFFFFFF,
|
||||
'o': hex("0000000000000000000000000000000000000000000000000000000000000000FFFFFFFF"),
|
||||
's': new Put()
|
||||
lock_time: 0,
|
||||
version: 1,
|
||||
hash: hex('3BA3EDFD7A7B12B27AC72C3E67768F617FC81BC3888A51323A9FB8AA4B1E5E4A'),
|
||||
ins: [{
|
||||
q: 0xFFFFFFFF,
|
||||
o: hex("0000000000000000000000000000000000000000000000000000000000000000FFFFFFFF"),
|
||||
s: new Put()
|
||||
.put(hex('04FFFF001D010445'))
|
||||
.put(new Buffer('The Times 03/Jan/2009 Chancellor on brink of ' +
|
||||
'second bailout for banks', 'ascii'))
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
|
||||
var SINKey = require('./SINKey').class();
|
||||
|
||||
var sk = new SINKey();
|
||||
sk.generate();
|
||||
console.dir(sk.storeObj());
|
||||
|
|
@ -20,6 +20,9 @@
|
|||
<script src="test.EncodedData.js"></script>
|
||||
<script src="test.VersionedData.js"></script>
|
||||
<script src="test.Address.js"></script>
|
||||
<script src="test.Opcode.js"></script>
|
||||
<script src="test.Script.js"></script>
|
||||
<script src="test.misc.js"></script>
|
||||
<script>
|
||||
mocha.run();
|
||||
</script>
|
||||
|
|
|
@ -16,14 +16,14 @@ describe('Address', function() {
|
|||
Address = AddressModule.class();
|
||||
should.exist(Address);
|
||||
});
|
||||
it('should be able to create Address object', function() {
|
||||
it('should be able to create instance', function() {
|
||||
var a = new Address('1KfyjCgBSMsLqiCbakfSdeoBUqMqLUiu3T');
|
||||
should.exist(a);
|
||||
});
|
||||
it('should validate correctly', function() {
|
||||
var a = new Address("1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa");
|
||||
var m = new Address("32QBdjycLwbDTuGafUwaU5p5GxzSLPYoF6");
|
||||
var b = new Address("11111111111111111111111111122222234");
|
||||
var a = new Address('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa');
|
||||
var m = new Address('32QBdjycLwbDTuGafUwaU5p5GxzSLPYoF6');
|
||||
var b = new Address('11111111111111111111111111122222234');
|
||||
a.validate.bind(a).should.not.throw(Error);
|
||||
m.validate.bind(m).should.not.throw(Error);
|
||||
b.validate.bind(b).should.throw(Error);
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
'use strict';
|
||||
|
||||
var chai = require('chai');
|
||||
var bitcore = require('../bitcore');
|
||||
|
||||
var should = chai.should();
|
||||
|
||||
var OpcodeModule = bitcore.Opcode;
|
||||
var Opcode;
|
||||
|
||||
describe('Opcode', function() {
|
||||
it('should initialze the main object', function() {
|
||||
should.exist(OpcodeModule);
|
||||
});
|
||||
it('should be able to create class', function() {
|
||||
Opcode = OpcodeModule.class();
|
||||
should.exist(Opcode);
|
||||
});
|
||||
it('should be able to create instance', function() {
|
||||
var oc = new Opcode();
|
||||
should.exist(oc);
|
||||
});
|
||||
it.skip('should be able to create some constants', function() {
|
||||
// TODO: test works in node but not in browser
|
||||
for (var i in Opcode.map) {
|
||||
console.log('var '+i + ' = ' + Opcode.map[i] + ';');
|
||||
eval('var '+i + ' = ' + Opcode.map[i] + ';');
|
||||
console.log(eval(i));
|
||||
}
|
||||
should.exist(OP_VER);
|
||||
should.exist(OP_HASH160);
|
||||
should.exist(OP_RETURN);
|
||||
should.exist(OP_EQUALVERIFY);
|
||||
should.exist(OP_CHECKSIG);
|
||||
should.exist(OP_CHECKMULTISIG);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
|
||||
var chai = require('chai');
|
||||
var bitcore = require('../bitcore');
|
||||
|
||||
var should = chai.should();
|
||||
|
||||
var SINKeyModule = bitcore.SINKey;
|
||||
var SINKey;
|
||||
|
||||
|
||||
describe('SINKey', function() {
|
||||
it('should initialze the main object', function() {
|
||||
should.exist(SINKeyModule);
|
||||
});
|
||||
it('should be able to create class', function() {
|
||||
SINKey = SINKeyModule.class();
|
||||
should.exist(SINKey);
|
||||
});
|
||||
it('should be able to create instance', function() {
|
||||
var sk = new SINKey();
|
||||
sk.generate();
|
||||
should.exist(sk.created);
|
||||
should.exist(sk.privKey.private);
|
||||
should.exist(sk.privKey.public);
|
||||
should.exist(sk.privKey.compressed);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,40 @@
|
|||
'use strict';
|
||||
|
||||
var chai = require('chai');
|
||||
var bitcore = require('../bitcore');
|
||||
|
||||
var should = chai.should();
|
||||
|
||||
var ScriptModule = bitcore.Script;
|
||||
var Address = bitcore.Address.class();
|
||||
var Script;
|
||||
|
||||
describe('Script', function() {
|
||||
it('should initialze the main object', function() {
|
||||
should.exist(ScriptModule);
|
||||
});
|
||||
it('should be able to create class', function() {
|
||||
Script = ScriptModule.class();
|
||||
should.exist(Script);
|
||||
});
|
||||
it('should be able to create instance', function() {
|
||||
var s = new Script();
|
||||
should.exist(s);
|
||||
});
|
||||
it('should be able to create Script from Address', function() {
|
||||
var addr = new Address('1J57QmkaQ6JohJoQyaUJwngJ2vTQ3C6gHi');
|
||||
var script = Script.createPubKeyHashOut(addr.payload());
|
||||
should.exist(script);
|
||||
script.isPubkeyHash().should.be.true;
|
||||
});
|
||||
it('isP2SH should work', function() {
|
||||
var addr = new Address('1J57QmkaQ6JohJoQyaUJwngJ2vTQ3C6gHi');
|
||||
var script = Script.createPubKeyHashOut(addr.payload());
|
||||
script.isP2SH().should.be.false;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
'use strict';
|
||||
|
||||
var chai = require('chai');
|
||||
var bitcore = require('../bitcore');
|
||||
|
||||
var should = chai.should();
|
||||
|
||||
var TransactionModule = bitcore.Transaction;
|
||||
var Transaction;
|
||||
|
||||
describe.skip('Transaction', function() {
|
||||
it('should initialze the main object', function() {
|
||||
should.exist(TransactionModule);
|
||||
});
|
||||
it('should be able to create class', function() {
|
||||
Transaction = TransactionModule.class();
|
||||
should.exist(Transaction);
|
||||
});
|
||||
it('should be able to create instance', function() {
|
||||
var t = new Transaction();
|
||||
should.exist(t);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
'use strict';
|
||||
|
||||
var chai = require('chai');
|
||||
var bitcore = require('../bitcore');
|
||||
|
||||
var should = chai.should();
|
||||
|
||||
describe('Miscelaneous stuff', function() {
|
||||
it('should initialze the config object', function() {
|
||||
should.exist(bitcore.config);
|
||||
});
|
||||
it('should initialze the log object', function() {
|
||||
should.exist(bitcore.log);
|
||||
});
|
||||
it('should initialze the util object', function() {
|
||||
should.exist(bitcore.util);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
require('buffertools');
|
||||
'use strict';
|
||||
|
||||
var crypto = require('crypto');
|
||||
var bignum = require('bignum');
|
||||
var Binary = require('binary');
|
||||
|
@ -327,7 +328,8 @@ var varStrBuf = exports.varStrBuf = function varStrBuf(s) {
|
|||
exports.NULL_HASH = new Buffer(32).fill(0);
|
||||
exports.EMPTY_BUFFER = new Buffer(0);
|
||||
exports.ZERO_VALUE = new Buffer(8).fill(0);
|
||||
INT64_MAX = new Buffer('ffffffffffffffff', 'hex');
|
||||
var INT64_MAX = new Buffer('ffffffffffffffff', 'hex');
|
||||
exports.INT64_MAX = INT64_MAX;
|
||||
|
||||
// How much of Bitcoin's internal integer coin representation
|
||||
// makes 1 BTC
|
||||
|
|
Loading…
Reference in New Issue