Merge remote-tracking branch 'matiu/feature/support-soop-browser'
Conflicts: Script.js ScriptInterpreter.js Transaction.js test/testdata.js ...conflicts resolved by taking Manuel's changes, and then manually including Matias's changes on those same files. The conflicts resulted from differences in indentation, which is because Matias' changes unindendented all the code that had been but is not now inside a function.
This commit is contained in:
commit
c19fb7a3ce
15
Address.js
15
Address.js
@ -1,14 +1,13 @@
|
|||||||
require('classtool');
|
'use strict';
|
||||||
|
var imports = require('soop').imports();
|
||||||
function ClassSpec(b) {
|
var parent = imports.parent || require('./util/VersionedData');
|
||||||
var superclass = b.superclass || require('./util/VersionedData').class();
|
|
||||||
|
|
||||||
function Address() {
|
function Address() {
|
||||||
Address.super(this, arguments);
|
Address.super(this, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
Address.superclass = superclass;
|
Address.parent = parent;
|
||||||
superclass.applyEncodingsTo(Address);
|
parent.applyEncodingsTo(Address);
|
||||||
|
|
||||||
Address.prototype.validate = function() {
|
Address.prototype.validate = function() {
|
||||||
this.doAsBinary(function() {
|
this.doAsBinary(function() {
|
||||||
@ -17,6 +16,4 @@ function ClassSpec(b) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return Address;
|
module.exports = require('soop')(Address);
|
||||||
}
|
|
||||||
module.defineClass(ClassSpec);
|
|
||||||
|
|||||||
25
Block.js
25
Block.js
@ -1,18 +1,17 @@
|
|||||||
require('classtool');
|
var imports = require('soop').imports();
|
||||||
|
|
||||||
function spec(b) {
|
var util = imports.util || require('./util/util');
|
||||||
var util = b.util || require('./util/util');
|
var Debug1 = imports.Debug1 || function() {};
|
||||||
var Debug1 = b.Debug1 || function() {};
|
var Script = imports.Script || require('./Script');
|
||||||
var Script = b.Script || require('./Script').class();
|
var Bignum = imports.Bignum || require('bignum');
|
||||||
var Bignum = b.Bignum || require('bignum');
|
var Binary = imports.Binary || require('binary');
|
||||||
var Binary = b.Binary || require('binary');
|
var Step = imports.Step || require('step');
|
||||||
var Step = b.Step || require('step');
|
var buffertools = imports.buffertools || require('buffertools');
|
||||||
var buffertools = b.buffertools || require('buffertools');
|
var Transaction = imports.Transaction || require('./Transaction');
|
||||||
var Transaction = b.Transaction || require('./Transaction').class();
|
|
||||||
var TransactionIn = Transaction.In;
|
var TransactionIn = Transaction.In;
|
||||||
var TransactionOut = Transaction.Out;
|
var TransactionOut = Transaction.Out;
|
||||||
var COINBASE_OP = Transaction.COINBASE_OP;
|
var COINBASE_OP = Transaction.COINBASE_OP;
|
||||||
var VerificationError = b.VerificationError || require('./util/error').VerificationError;
|
var VerificationError = imports.VerificationError || require('./util/error').VerificationError;
|
||||||
var BlockRules = {
|
var BlockRules = {
|
||||||
maxTimeOffset: 2 * 60 * 60, // How far block timestamps can be into the future
|
maxTimeOffset: 2 * 60 * 60, // How far block timestamps can be into the future
|
||||||
largestHash: Bignum(2).pow(256)
|
largestHash: Bignum(2).pow(256)
|
||||||
@ -589,6 +588,4 @@ function spec(b) {
|
|||||||
return block;
|
return block;
|
||||||
};
|
};
|
||||||
|
|
||||||
return Block;
|
module.exports = require('soop')(Block);
|
||||||
};
|
|
||||||
module.defineClass(spec);
|
|
||||||
|
|||||||
7
Bloom.js
7
Bloom.js
@ -1,6 +1,3 @@
|
|||||||
require('classtool');
|
|
||||||
|
|
||||||
function ClassSpec(b) {
|
|
||||||
var MAX_BLOOM_FILTER_SIZE = 36000; // bytes
|
var MAX_BLOOM_FILTER_SIZE = 36000; // bytes
|
||||||
var MAX_HASH_FUNCS = 50;
|
var MAX_HASH_FUNCS = 50;
|
||||||
var LN2SQUARED = 0.4804530139182014246671025263266649717305529515945455;
|
var LN2SQUARED = 0.4804530139182014246671025263266649717305529515945455;
|
||||||
@ -110,7 +107,5 @@ function ClassSpec(b) {
|
|||||||
MAX_HASH_FUNCS);
|
MAX_HASH_FUNCS);
|
||||||
};
|
};
|
||||||
|
|
||||||
return Bloom;
|
|
||||||
};
|
|
||||||
module.defineClass(ClassSpec);
|
|
||||||
|
|
||||||
|
module.exports = require('soop')(Bloom);
|
||||||
|
|||||||
@ -1,24 +1,23 @@
|
|||||||
require('classtool');
|
var imports = require('soop').imports();
|
||||||
|
|
||||||
function spec(b) {
|
var config = imports.config || require('./config');
|
||||||
var config = b.config || require('./config');
|
var log = imports.log || require('./util/log');
|
||||||
var log = b.log || require('./util/log');
|
var network = imports.network || require('./networks')[config.network];
|
||||||
var network = b.network || require('./networks')[config.network];
|
|
||||||
|
|
||||||
var MAX_RECEIVE_BUFFER = 10000000;
|
var MAX_RECEIVE_BUFFER = 10000000;
|
||||||
var PROTOCOL_VERSION = 70000;
|
var PROTOCOL_VERSION = 70000;
|
||||||
|
|
||||||
var Binary = b.Binary || require('binary');
|
var Binary = imports.Binary || require('binary');
|
||||||
var Put = b.Put || require('bufferput');
|
var Put = imports.Put || require('bufferput');
|
||||||
var Buffers = b.Buffers || require('buffers');
|
var Buffers = imports.Buffers || require('buffers');
|
||||||
require('./Buffers.monkey').patch(Buffers);
|
require('./Buffers.monkey').patch(Buffers);
|
||||||
var noop = function() {};
|
|
||||||
var Block = require('./Block').class();
|
var Block = require('./Block');
|
||||||
var Transaction = require('./Transaction').class();
|
var Transaction = require('./Transaction');
|
||||||
var util = b.util || require('./util/util');
|
var util = imports.util || require('./util/util');
|
||||||
var Parser = b.Parser || require('./util/BinaryParser').class();
|
var Parser = imports.Parser || require('./util/BinaryParser');
|
||||||
var buffertools = b.buffertools || require('buffertools');
|
var buffertools = imports.buffertools || require('buffertools');
|
||||||
var doubleSha256 = b.doubleSha256 || util.twoSha256;
|
var doubleSha256 = imports.doubleSha256 || util.twoSha256;
|
||||||
var nonce = util.generateNonce();
|
var nonce = util.generateNonce();
|
||||||
|
|
||||||
var BIP0031_VERSION = 60000;
|
var BIP0031_VERSION = 60000;
|
||||||
@ -53,7 +52,7 @@ function spec(b) {
|
|||||||
|
|
||||||
this.setupHandlers();
|
this.setupHandlers();
|
||||||
}
|
}
|
||||||
Connection.superclass = b.superclass || require('events').EventEmitter;
|
Connection.parent = imports.parent || require('events').EventEmitter;
|
||||||
|
|
||||||
Connection.prototype.setupHandlers = function () {
|
Connection.prototype.setupHandlers = function () {
|
||||||
this.socket.addListener('connect', this.handleConnect.bind(this));
|
this.socket.addListener('connect', this.handleConnect.bind(this));
|
||||||
@ -542,6 +541,4 @@ function spec(b) {
|
|||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
return Connection;
|
module.exports = require('soop')(Connection);
|
||||||
};
|
|
||||||
module.defineClass(spec);
|
|
||||||
|
|||||||
26
Gruntfile.js
26
Gruntfile.js
@ -3,26 +3,28 @@
|
|||||||
module.exports = function(grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
//Load NPM tasks
|
//Load NPM tasks
|
||||||
grunt.loadNpmTasks('grunt-browserify');
|
|
||||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||||
grunt.loadNpmTasks('grunt-mocha-test');
|
grunt.loadNpmTasks('grunt-mocha-test');
|
||||||
grunt.loadNpmTasks('grunt-markdown');
|
grunt.loadNpmTasks('grunt-markdown');
|
||||||
|
grunt.loadNpmTasks('grunt-shell');
|
||||||
|
|
||||||
// Project Configuration
|
// Project Configuration
|
||||||
grunt.initConfig({
|
grunt.initConfig({
|
||||||
|
shell: {
|
||||||
browserify: {
|
browserify: {
|
||||||
client: {
|
|
||||||
src: ['bitcore.js'],
|
|
||||||
dest: 'browser/bundle.js',
|
|
||||||
options: {
|
options: {
|
||||||
debug: true,
|
stdout: true
|
||||||
alias: [
|
|
||||||
'browserify-bignum/bignumber.js:bignum',
|
|
||||||
'browserify-buffertools/buffertools.js:buffertools'
|
|
||||||
],
|
|
||||||
standalone: 'bitcore',
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
command: 'node ./browserify.js > browser/bundle.js',
|
||||||
|
},
|
||||||
|
browserifyData: {
|
||||||
|
options: {
|
||||||
|
stdout: true
|
||||||
|
},
|
||||||
|
command: 'browserify -t brfs test/testdata.js > browser/testdata.js'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
browserify: {
|
||||||
test_data: {
|
test_data: {
|
||||||
src: ['test/testdata.js'],
|
src: ['test/testdata.js'],
|
||||||
dest: 'browser/testdata.js',
|
dest: 'browser/testdata.js',
|
||||||
@ -40,7 +42,7 @@ module.exports = function(grunt) {
|
|||||||
},
|
},
|
||||||
scripts: {
|
scripts: {
|
||||||
files: ['**/*.js', '**/*.html', '!**/node_modules/**', '!browser/bundle.js', '!browser/testdata.js'],
|
files: ['**/*.js', '**/*.html', '!**/node_modules/**', '!browser/bundle.js', '!browser/testdata.js'],
|
||||||
tasks: ['browserify' /*, 'mochaTest'*/ ],
|
tasks: ['shell' /*, 'mochaTest'*/ ],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mochaTest: {
|
mochaTest: {
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
require('classtool');
|
var imports = require('soop').imports();
|
||||||
|
|
||||||
function spec(b) {
|
|
||||||
function Opcode(num) {
|
function Opcode(num) {
|
||||||
this.code = num;
|
this.code = num;
|
||||||
};
|
};
|
||||||
@ -156,6 +155,4 @@ function spec(b) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Opcode;
|
module.exports = require('soop')(Opcode);
|
||||||
};
|
|
||||||
module.defineClass(spec);
|
|
||||||
|
|||||||
13
Peer.js
13
Peer.js
@ -1,9 +1,8 @@
|
|||||||
require('classtool');
|
var imports = require('soop').imports();
|
||||||
|
|
||||||
function spec(b) {
|
var Net = imports.Net || require('net');
|
||||||
var Net = b.Net || require('net');
|
var Binary = imports.Binary || require('binary');
|
||||||
var Binary = b.Binary || require('binary');
|
var buffertools = imports.buffertools || require('buffertools');
|
||||||
var buffertools = b.buffertools || require('buffertools');
|
|
||||||
|
|
||||||
function Peer(host, port, services) {
|
function Peer(host, port, services) {
|
||||||
if ("string" === typeof host) {
|
if ("string" === typeof host) {
|
||||||
@ -56,6 +55,4 @@ function spec(b) {
|
|||||||
return put.buffer();
|
return put.buffer();
|
||||||
};
|
};
|
||||||
|
|
||||||
return Peer;
|
module.exports = require('soop')(Peer);
|
||||||
};
|
|
||||||
module.defineClass(spec);
|
|
||||||
|
|||||||
@ -1,15 +1,16 @@
|
|||||||
require('classtool');
|
|
||||||
|
|
||||||
function spec(b) {
|
var imports = require('soop').imports();
|
||||||
var config = b.config || require('./config');
|
var config = imports.config || require('./config');
|
||||||
var log = b.log || require('./util/log');
|
var log = imports.log || require('./util/log');
|
||||||
var network = b.network || require('./networks')[config.network];
|
var network = imports.network || require('./networks')[config.network];
|
||||||
var Connection = b.Connection || require('./Connection').createClass(
|
|
||||||
{config: config, network: network});
|
|
||||||
var Peer = b.Peer || require('./Peer').class();
|
|
||||||
var noop = function() {};
|
|
||||||
|
|
||||||
GetAdjustedTime = b.GetAdjustedTime || function () {
|
var Connection = imports.Connection ||
|
||||||
|
require('soop').load('Connection', {config: config, network: network}) ||
|
||||||
|
require ('./Connection');
|
||||||
|
|
||||||
|
var Peer = imports.Peer || require('./Peer');
|
||||||
|
|
||||||
|
GetAdjustedTime = imports.GetAdjustedTime || function () {
|
||||||
// TODO: Implement actual adjustment
|
// TODO: Implement actual adjustment
|
||||||
return Math.floor(new Date().getTime() / 1000);
|
return Math.floor(new Date().getTime() / 1000);
|
||||||
};
|
};
|
||||||
@ -28,8 +29,8 @@ function spec(b) {
|
|||||||
this.minConnections = 8;
|
this.minConnections = 8;
|
||||||
this.minKnownPeers = 10;
|
this.minKnownPeers = 10;
|
||||||
};
|
};
|
||||||
PeerManager.superclass = b.superclass || require('events').EventEmitter;
|
|
||||||
|
|
||||||
|
PeerManager.parent = imports.parent || require('events').EventEmitter;
|
||||||
PeerManager.Connection = Connection;
|
PeerManager.Connection = Connection;
|
||||||
|
|
||||||
PeerManager.prototype.start = function() {
|
PeerManager.prototype.start = function() {
|
||||||
@ -210,6 +211,4 @@ function spec(b) {
|
|||||||
return this.connections.slice(0);
|
return this.connections.slice(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
return PeerManager;
|
module.exports = require('soop')(PeerManager);
|
||||||
};
|
|
||||||
module.defineClass(spec);
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
require('classtool');
|
var imports = require('soop').imports();
|
||||||
|
|
||||||
function ClassSpec(b) {
|
var parent = imports.parent || require('./util/VersionedData');
|
||||||
var superclass = b.superclass || require('./util/VersionedData').class();
|
|
||||||
|
|
||||||
//compressed is true if public key is compressed; false otherwise
|
//compressed is true if public key is compressed; false otherwise
|
||||||
function PrivateKey(version, buf, compressed) {
|
function PrivateKey(version, buf, compressed) {
|
||||||
@ -10,8 +9,8 @@ function ClassSpec(b) {
|
|||||||
this.compressed(compressed);
|
this.compressed(compressed);
|
||||||
};
|
};
|
||||||
|
|
||||||
PrivateKey.superclass = superclass;
|
PrivateKey.parent = parent;
|
||||||
superclass.applyEncodingsTo(PrivateKey);
|
parent.applyEncodingsTo(PrivateKey);
|
||||||
|
|
||||||
PrivateKey.prototype.validate = function() {
|
PrivateKey.prototype.validate = function() {
|
||||||
this.doAsBinary(function() {
|
this.doAsBinary(function() {
|
||||||
@ -62,6 +61,4 @@ function ClassSpec(b) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return PrivateKey;
|
module.exports = require('soop')(PrivateKey);
|
||||||
};
|
|
||||||
module.defineClass(ClassSpec);
|
|
||||||
|
|||||||
30
README.md
30
README.md
@ -17,9 +17,9 @@ Bitcore runs on [node](http://nodejs.org/), and can be installed via [npm](https
|
|||||||
npm install bitcore
|
npm install bitcore
|
||||||
```
|
```
|
||||||
|
|
||||||
It is a collection of objects useful to bitcoin applications; class-like idioms are enabled via [Classtool](https://github.com/gasteve/classtool). In most cases, a developer will require the object's class directly:
|
It is a collection of objects useful to bitcoin applications; class-like idioms are enabled via [Soop](https://github.com/gasteve/soop). In most cases, a developer will require the object's class directly:
|
||||||
```
|
```
|
||||||
var Address = require('bitcore/Address').class();
|
var Address = require('bitcore/Address');
|
||||||
```
|
```
|
||||||
|
|
||||||
#Examples
|
#Examples
|
||||||
@ -29,7 +29,7 @@ Some examples are provided at the [examples](/examples) path. Here are some snip
|
|||||||
## Validating an address
|
## Validating an address
|
||||||
Validating a Bitcoin address:
|
Validating a Bitcoin address:
|
||||||
```js
|
```js
|
||||||
var Address = require('bitcore/Address').class();
|
var Address = require('bitcore/Address');
|
||||||
|
|
||||||
var addrStrings = [
|
var addrStrings = [
|
||||||
"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
|
"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
|
||||||
@ -57,10 +57,9 @@ For this example you need a running bitcoind instance with RPC enabled.
|
|||||||
```js
|
```js
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var networks = require('bitcore/networks');
|
var networks = require('bitcore/networks');
|
||||||
var Peer = require('bitcore/Peer').class();
|
var Peer = require('bitcore/Peer');
|
||||||
var PeerManager = require('bitcore/PeerManager').createClass({
|
var PeerManager = require('soop').load('bitcore/PeerManager',
|
||||||
network: networks.testnet
|
{network: networks.testnet});
|
||||||
});
|
|
||||||
|
|
||||||
var handleBlock = function(info) {
|
var handleBlock = function(info) {
|
||||||
|
|
||||||
@ -109,14 +108,13 @@ PeerManager will emit the following events: 'version', 'verack', 'addr', 'getadd
|
|||||||
For this example you need a running bitcoind instance with RPC enabled.
|
For this example you need a running bitcoind instance with RPC enabled.
|
||||||
```js
|
```js
|
||||||
var networks = require('bitcore/networks');
|
var networks = require('bitcore/networks');
|
||||||
var Peer = require('bitcore/Peer').class();
|
var Peer = require('bitcore/Peer');
|
||||||
var Transaction = require('bitcore/Transaction').class();
|
var Transaction = require('bitcore/Transaction');
|
||||||
var Address = require('bitcore/Address').class();
|
var Address = require('bitcore/Address');
|
||||||
var Script = require('bitcore/Script').class();
|
var Script = require('bitcore/Script');
|
||||||
var coinUtil = require('bitcore/util/util');
|
var coinUtil = require('bitcore/util/util');
|
||||||
var PeerManager = require('bitcore/PeerManager').createClass({
|
var PeerManager = require('soop').load('bitcore/PeerManager',
|
||||||
network: networks.testnet
|
{network: networks.testnet});
|
||||||
});
|
|
||||||
|
|
||||||
var createTx = function() {
|
var createTx = function() {
|
||||||
|
|
||||||
@ -185,7 +183,7 @@ peerman.start();
|
|||||||
For this example you need a running bitcoind instance with RPC enabled.
|
For this example you need a running bitcoind instance with RPC enabled.
|
||||||
```js
|
```js
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var RpcClient = require('bitcore/RpcClient').class();
|
var RpcClient = require('bitcore/RpcClient');
|
||||||
var hash = process.argv[2] || '0000000000b6288775bbd326bedf324ca8717a15191da58391535408205aada4';
|
var hash = process.argv[2] || '0000000000b6288775bbd326bedf324ca8717a15191da58391535408205aada4';
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
@ -217,7 +215,7 @@ Check the list of all supported RPC call at [RpcClient.js](RpcClient.js)
|
|||||||
Gets an address strings from a ScriptPubKey Buffer
|
Gets an address strings from a ScriptPubKey Buffer
|
||||||
|
|
||||||
```
|
```
|
||||||
var Address = require('bitcore/Address').class();
|
var Address = require('bitcore/Address');
|
||||||
var coinUtil= require('bitcore/util/util');
|
var coinUtil= require('bitcore/util/util');
|
||||||
|
|
||||||
var getAddrStr = function(s) {
|
var getAddrStr = function(s) {
|
||||||
|
|||||||
16
RpcClient.js
16
RpcClient.js
@ -1,12 +1,11 @@
|
|||||||
// RpcClient.js
|
// RpcClient.js
|
||||||
// MIT/X11-like license. See LICENSE.txt.
|
// MIT/X11-like license. See LICENSE.txt.
|
||||||
// Copyright 2013 BitPay, Inc.
|
// Copyright 2013 BitPay, Inc.
|
||||||
require('classtool');
|
//
|
||||||
|
var imports = require('soop').imports();
|
||||||
function ClassSpec(b) {
|
var http = imports.http || require('http');
|
||||||
var http = b.http || require('http');
|
var https = imports.https || require('https');
|
||||||
var https = b.https || require('https');
|
var log = imports.log || require('./util/log');
|
||||||
var log = b.log || require('./util/log');
|
|
||||||
|
|
||||||
function RpcClient(opts) {
|
function RpcClient(opts) {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
@ -204,7 +203,6 @@ function ClassSpec(b) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
generateRPCMethods(RpcClient, callspec, rpc);
|
generateRPCMethods(RpcClient, callspec, rpc);
|
||||||
return RpcClient;
|
|
||||||
};
|
module.exports = require('soop')(RpcClient);
|
||||||
module.defineClass(ClassSpec);
|
|
||||||
|
|
||||||
|
|||||||
15
SIN.js
15
SIN.js
@ -1,8 +1,5 @@
|
|||||||
require('classtool');
|
var imports = require('soop').imports();
|
||||||
|
var parent = imports.parent || require('./util/VersionedData');
|
||||||
function ClassSpec(b) {
|
|
||||||
var superclass = b.superclass || require('./util/VersionedData').class();
|
|
||||||
|
|
||||||
|
|
||||||
function SIN(type, payload) {
|
function SIN(type, payload) {
|
||||||
if (typeof type != 'number') {
|
if (typeof type != 'number') {
|
||||||
@ -15,8 +12,8 @@ function ClassSpec(b) {
|
|||||||
this.type(type);
|
this.type(type);
|
||||||
this.payload(payload);
|
this.payload(payload);
|
||||||
};
|
};
|
||||||
SIN.superclass = superclass;
|
SIN.parent = parent;
|
||||||
superclass.applyEncodingsTo(SIN);
|
parent.applyEncodingsTo(SIN);
|
||||||
|
|
||||||
SIN.SIN_PERSIST_MAINNET = 0x01; // associated with sacrifice TX
|
SIN.SIN_PERSIST_MAINNET = 0x01; // associated with sacrifice TX
|
||||||
SIN.SIN_PERSIST_TESTNET = 0x11; // associated with sacrifice TX
|
SIN.SIN_PERSIST_TESTNET = 0x11; // associated with sacrifice TX
|
||||||
@ -55,6 +52,4 @@ function ClassSpec(b) {
|
|||||||
if (this.data.length != 22) throw new Error('invalid data length');
|
if (this.data.length != 22) throw new Error('invalid data length');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return SIN;
|
module.exports = require('soop')(SIN);
|
||||||
};
|
|
||||||
module.defineClass(ClassSpec);
|
|
||||||
|
|||||||
10
SINKey.js
10
SINKey.js
@ -1,10 +1,7 @@
|
|||||||
require('classtool');
|
|
||||||
|
|
||||||
function ClassSpec(b) {
|
|
||||||
var coinUtil = require('./util/util');
|
var coinUtil = require('./util/util');
|
||||||
var timeUtil = require('./util/time');
|
var timeUtil = require('./util/time');
|
||||||
var KeyModule = require('./Key');
|
var KeyModule = require('./Key');
|
||||||
var SIN = require('./SIN').class();
|
var SIN = require('./SIN');
|
||||||
|
|
||||||
function SINKey(cfg) {
|
function SINKey(cfg) {
|
||||||
if (typeof cfg != 'object')
|
if (typeof cfg != 'object')
|
||||||
@ -37,7 +34,4 @@ function ClassSpec(b) {
|
|||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
return SINKey;
|
module.exports = require('soop')(SINKey);
|
||||||
};
|
|
||||||
module.defineClass(ClassSpec);
|
|
||||||
|
|
||||||
|
|||||||
23
Script.js
23
Script.js
@ -1,20 +1,17 @@
|
|||||||
require('classtool');
|
var imports = require('soop').imports();
|
||||||
|
var config = imports.config || require('./config');
|
||||||
function spec(b) {
|
var log = imports.log || require('./util/log');
|
||||||
var config = b.config || require('./config');
|
var Opcode = imports.Opcode || require('./Opcode');
|
||||||
var log = b.log || require('./util/log');
|
var buffertools = imports.buffertools || require('buffertools');
|
||||||
|
|
||||||
var Opcode = b.Opcode || require('./Opcode').class();
|
|
||||||
var buffertools = b.buffertools || require('buffertools');
|
|
||||||
|
|
||||||
// Make opcodes available as pseudo-constants
|
// Make opcodes available as pseudo-constants
|
||||||
for (var i in Opcode.map) {
|
for (var i in Opcode.map) {
|
||||||
eval(i + " = " + Opcode.map[i] + ";");
|
eval(i + " = " + Opcode.map[i] + ";");
|
||||||
}
|
}
|
||||||
|
|
||||||
var util = b.util || require('./util/util');
|
var util = imports.util || require('./util/util');
|
||||||
var Parser = b.Parser || require('./util/BinaryParser').class();
|
var Parser = imports.Parser || require('./util/BinaryParser');
|
||||||
var Put = b.Put || require('bufferput');
|
var Put = imports.Put || require('bufferput');
|
||||||
|
|
||||||
var TX_UNKNOWN = 0;
|
var TX_UNKNOWN = 0;
|
||||||
var TX_PUBKEY = 1;
|
var TX_PUBKEY = 1;
|
||||||
@ -512,6 +509,4 @@ function spec(b) {
|
|||||||
return buf.buffer();
|
return buf.buffer();
|
||||||
};
|
};
|
||||||
|
|
||||||
return Script;
|
module.exports = require('soop')(Script);
|
||||||
};
|
|
||||||
module.defineClass(spec);
|
|
||||||
|
|||||||
@ -1,22 +1,17 @@
|
|||||||
require('classtool');
|
var imports = require('soop').imports();
|
||||||
|
var config = imports.config || require('./config');
|
||||||
function spec(b) {
|
var log = imports.log || require('./util/log');
|
||||||
var assert = require('assert');
|
var Opcode = imports.Opcode || require('./Opcode');
|
||||||
var config = b.config || require('./config');
|
var buffertools = imports.buffertools || require('buffertools');
|
||||||
var log = b.log || require('./util/log');
|
var bignum = imports.bignum || require('bignum');
|
||||||
|
var Util = imports.Util || require('./util/util');
|
||||||
var Opcode = b.Opcode || require('./Opcode').class();
|
var Script = require('./Script');
|
||||||
var buffertools = b.buffertools || require('buffertools');
|
|
||||||
|
|
||||||
// Make opcodes available as pseudo-constants
|
// Make opcodes available as pseudo-constants
|
||||||
for (var i in Opcode.map) {
|
for (var i in Opcode.map) {
|
||||||
eval(i + " = " + Opcode.map[i] + ";");
|
eval(i + " = " + Opcode.map[i] + ";");
|
||||||
}
|
}
|
||||||
|
|
||||||
var bignum = b.bignum || require('bignum');
|
|
||||||
var Util = b.Util || require('./util/util');
|
|
||||||
var Script = require('./Script').class();
|
|
||||||
|
|
||||||
function ScriptInterpreter() {
|
function ScriptInterpreter() {
|
||||||
this.stack = [];
|
this.stack = [];
|
||||||
this.disableUnsafeOpcodes = true;
|
this.disableUnsafeOpcodes = true;
|
||||||
@ -1062,6 +1057,4 @@ function spec(b) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return ScriptInterpreter;
|
module.exports = require('soop')(ScriptInterpreter);
|
||||||
};
|
|
||||||
module.defineClass(spec);
|
|
||||||
|
|||||||
@ -1,21 +1,16 @@
|
|||||||
require('classtool');
|
var imports = require('soop').imports();
|
||||||
|
var config = imports.config || require('./config');
|
||||||
function spec(b) {
|
var log = imports.log || require('./util/log');
|
||||||
var config = b.config || require('./config');
|
var Address = imports.Address || require('./Address');
|
||||||
var log = b.log || require('./util/log');
|
var Script = imports.Script || require('./Script');
|
||||||
var Address = b.Address || require('./Address').class();
|
var ScriptInterpreter = imports.ScriptInterpreter || require('./ScriptInterpreter');
|
||||||
var Script = b.Script || require('./Script').class();
|
var util = imports.util || require('./util/util');
|
||||||
var ScriptInterpreter = b.ScriptInterpreter || require('./ScriptInterpreter').class();
|
var bignum = imports.bignum || require('bignum');
|
||||||
var util = b.util || require('./util/util');
|
var Put = imports.Put || require('bufferput');
|
||||||
var bignum = b.bignum || require('bignum');
|
var Parser = imports.Parser || require('./util/BinaryParser');
|
||||||
var Put = b.Put || require('bufferput');
|
var Step = imports.Step || require('step');
|
||||||
var Parser = b.Parser || require('./util/BinaryParser').class();
|
var buffertools = imports.buffertools || require('buffertools');
|
||||||
var Step = b.Step || require('step');
|
var error = imports.error || require('./util/error');
|
||||||
var buffertools = b.buffertools || require('buffertools');
|
|
||||||
|
|
||||||
var error = b.error || require('./util/error');
|
|
||||||
var VerificationError = error.VerificationError;
|
|
||||||
var MissingSourceError = error.MissingSourceError;
|
|
||||||
|
|
||||||
var COINBASE_OP = Buffer.concat([util.NULL_HASH, new Buffer('FFFFFFFF', 'hex')]);
|
var COINBASE_OP = Buffer.concat([util.NULL_HASH, new Buffer('FFFFFFFF', 'hex')]);
|
||||||
|
|
||||||
@ -821,6 +816,4 @@ function spec(b) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return Transaction;
|
module.exports = require('soop')(Transaction);
|
||||||
};
|
|
||||||
module.defineClass(spec);
|
|
||||||
|
|||||||
12
Wallet.js
12
Wallet.js
@ -1,12 +1,12 @@
|
|||||||
require('classtool');
|
var imports = require('soop').imports();
|
||||||
|
|
||||||
var hex = function(hex) {return new Buffer(hex, 'hex');};
|
var hex = function(hex) {return new Buffer(hex, 'hex');};
|
||||||
|
|
||||||
function ClassSpec(b) {
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var EncFile = require('./util/EncFile');
|
var EncFile = require('./util/EncFile');
|
||||||
var Address = require('./Address').class();
|
var Address = require('./Address');
|
||||||
var networks = require('./networks');
|
var networks = require('./networks');
|
||||||
var util = b.util || require('./util/util');
|
var util = imports.util || require('./util/util');
|
||||||
var ENC_METHOD = 'aes-256-cbc';
|
var ENC_METHOD = 'aes-256-cbc';
|
||||||
|
|
||||||
var skeleton = {
|
var skeleton = {
|
||||||
@ -136,7 +136,5 @@ function ClassSpec(b) {
|
|||||||
return addrStr;
|
return addrStr;
|
||||||
};
|
};
|
||||||
|
|
||||||
return Wallet;
|
module.exports = require('soop')(Wallet);
|
||||||
};
|
|
||||||
module.defineClass(ClassSpec);
|
|
||||||
|
|
||||||
|
|||||||
11
WalletKey.js
11
WalletKey.js
@ -1,11 +1,10 @@
|
|||||||
require('classtool');
|
var imports = require('soop').imports();
|
||||||
|
|
||||||
function ClassSpec(b) {
|
|
||||||
var coinUtil = require('./util/util');
|
var coinUtil = require('./util/util');
|
||||||
var timeUtil = require('./util/time');
|
var timeUtil = require('./util/time');
|
||||||
var KeyModule = require('./Key');
|
var KeyModule = require('./Key');
|
||||||
var PrivateKey = require('./PrivateKey').class();
|
var PrivateKey = require('./PrivateKey');
|
||||||
var Address = require('./Address').class();
|
var Address = require('./Address');
|
||||||
|
|
||||||
function WalletKey(cfg) {
|
function WalletKey(cfg) {
|
||||||
if (!cfg) cfg = {};
|
if (!cfg) cfg = {};
|
||||||
@ -50,6 +49,4 @@ function ClassSpec(b) {
|
|||||||
this.privKey.regenerateSync();
|
this.privKey.regenerateSync();
|
||||||
};
|
};
|
||||||
|
|
||||||
return WalletKey;
|
module.exports = require('soop')(WalletKey);
|
||||||
};
|
|
||||||
module.defineClass(ClassSpec);
|
|
||||||
|
|||||||
16
bitcore.js
16
bitcore.js
@ -3,25 +3,27 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports.bignum = require('bignum');
|
module.exports.bignum = require('bignum');
|
||||||
module.exports.base58 = require('base58-native');
|
module.exports.base58 = require('base58-native');
|
||||||
module.exports.buffertools = require('buffertools');
|
module.exports.buffertools = require('buffertools');
|
||||||
|
|
||||||
module.exports.config = require('./config');
|
module.exports.config = require('./config');
|
||||||
module.exports.const = require('./const');
|
module.exports.const = require('./const');
|
||||||
module.exports.Deserialize = require('./Deserialize');
|
module.exports.Deserialize = require('./Deserialize');
|
||||||
module.exports.log = require('./util/log');
|
module.exports.log = require('./util/log');
|
||||||
module.exports.networks = require('./networks');
|
module.exports.networks = require('./networks');
|
||||||
module.exports.util = require('./util/util');
|
module.exports.util = require('./util/util');
|
||||||
|
|
||||||
module.exports.EncodedData = require('./util/EncodedData');
|
module.exports.EncodedData = require('./util/EncodedData');
|
||||||
module.exports.VersionedData = require('./util/VersionedData');
|
module.exports.VersionedData = require('./util/VersionedData');
|
||||||
module.exports.Address = require('./Address');
|
module.exports.Address = require('./Address');
|
||||||
module.exports.Opcode = require('./Opcode');
|
module.exports.Opcode = require('./Opcode');
|
||||||
module.exports.Script = require('./Script');
|
module.exports.Script = require('./Script');
|
||||||
module.exports.Transaction = require('./Transaction');
|
module.exports.Transaction = require('./Transaction');
|
||||||
module.exports.Peer = require('./Peer');
|
|
||||||
module.exports.PeerManager = require('./PeerManager');
|
|
||||||
module.exports.Block = require('./Block');
|
|
||||||
module.exports.Connection = require('./Connection');
|
module.exports.Connection = require('./Connection');
|
||||||
|
module.exports.Peer = require('./Peer');
|
||||||
|
module.exports.Block = require('./Block');
|
||||||
module.exports.ScriptInterpreter = require('./ScriptInterpreter');
|
module.exports.ScriptInterpreter = require('./ScriptInterpreter');
|
||||||
module.exports.Bloom = require('./Bloom');
|
module.exports.Bloom = require('./Bloom');
|
||||||
module.exports.KeyModule = require('./Key');
|
module.exports.KeyModule = require('./Key');
|
||||||
@ -34,6 +36,14 @@ module.exports.WalletKey = require('./WalletKey');
|
|||||||
module.exports.Buffer = Buffer;
|
module.exports.Buffer = Buffer;
|
||||||
|
|
||||||
if (typeof process.versions === 'undefined') {
|
if (typeof process.versions === 'undefined') {
|
||||||
|
// Browser specific
|
||||||
module.exports.bignum.config({EXPONENTIAL_AT: 9999999, DECIMAL_PLACES: 0, ROUNDING_MODE: 1});
|
module.exports.bignum.config({EXPONENTIAL_AT: 9999999, DECIMAL_PLACES: 0, ROUNDING_MODE: 1});
|
||||||
|
// module.exports.PeerManager = function () {
|
||||||
|
// throw new Error('PeerManager not availabe in browser Bitcore, under .bitcore. Use it with: require(\'PeerManager\');');
|
||||||
|
// };
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Nodejs specific
|
||||||
|
module.exports.PeerManager = require('./PeerManager');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6
browser/bignum_config.js
Normal file
6
browser/bignum_config.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
require('bignum').config({
|
||||||
|
EXPONENTIAL_AT: 9999999,
|
||||||
|
DECIMAL_PLACES: 0,
|
||||||
|
ROUNDING_MODE: 1,
|
||||||
|
});
|
||||||
|
|
||||||
88
browserify.js
Normal file
88
browserify.js
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Example for usage of browserify with soop
|
||||||
|
*
|
||||||
|
* The key parameter 'pack'
|
||||||
|
* The supplied 'custom_prelude.js' file is needed for
|
||||||
|
* .load function of soop.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
|
var browserify = require('browserify');
|
||||||
|
var browserPack = require('browser-pack');
|
||||||
|
var opts = {};
|
||||||
|
|
||||||
|
|
||||||
|
var preludePath = 'node_modules/soop/example/custom_prelude.js';
|
||||||
|
|
||||||
|
var pack = function (params) {
|
||||||
|
params.raw = true;
|
||||||
|
params.sourceMapPrefix = '//#';
|
||||||
|
params.prelude= fs.readFileSync(preludePath, 'utf8');
|
||||||
|
params.preludePath= preludePath;
|
||||||
|
return browserPack(params);
|
||||||
|
};
|
||||||
|
|
||||||
|
opts.pack = pack;
|
||||||
|
opts.debug = true;
|
||||||
|
|
||||||
|
var modules = [
|
||||||
|
'Address',
|
||||||
|
'Block',
|
||||||
|
'Bloom',
|
||||||
|
'Buffers.monkey',
|
||||||
|
'Connection',
|
||||||
|
'Deserialize',
|
||||||
|
'Gruntfile',
|
||||||
|
'Number.monkey',
|
||||||
|
'Opcode',
|
||||||
|
'Peer',
|
||||||
|
'PeerManager',
|
||||||
|
'PrivateKey',
|
||||||
|
'RpcClient',
|
||||||
|
'SIN',
|
||||||
|
'SINKey',
|
||||||
|
'Script',
|
||||||
|
'ScriptInterpreter',
|
||||||
|
'Sign',
|
||||||
|
'Transaction',
|
||||||
|
'Wallet',
|
||||||
|
'WalletKey',
|
||||||
|
'config',
|
||||||
|
'const',
|
||||||
|
'networks',
|
||||||
|
'bitcore',
|
||||||
|
];
|
||||||
|
|
||||||
|
var b = browserify(opts);
|
||||||
|
b.require('browserify-bignum/bignumber.js', {expose: 'bignum'} );
|
||||||
|
b.require('browserify-buffertools/buffertools.js', {expose:'buffertools'});
|
||||||
|
b.require('buffer', {expose: 'buffer'});
|
||||||
|
b.require('base58-native');
|
||||||
|
b.require('./Key.js', {expose: 'KeyModule'});
|
||||||
|
b.require('./util/log');
|
||||||
|
b.require('./util/util');
|
||||||
|
b.require('./util/EncodedData');
|
||||||
|
b.require('./util/VersionedData');
|
||||||
|
b.add('./browser/bignum_config.js');
|
||||||
|
|
||||||
|
modules.forEach(function(m) {
|
||||||
|
b.require('./' + m + '.js' ,{expose:m} );
|
||||||
|
});
|
||||||
|
|
||||||
|
var bopts = {
|
||||||
|
// detectGlobals: true,
|
||||||
|
// insertGlobals: 'Buffer',
|
||||||
|
// insertGlobalVars: {
|
||||||
|
// Buffer: function () {
|
||||||
|
// return 'require("buffer").Buffer';
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
};
|
||||||
|
|
||||||
|
b.bundle(bopts).pipe(process.stdout);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// Replace '..' with 'bitcore' if you plan on using this code elsewhere.
|
// Replace '..' with 'bitcore' if you plan on using this code elsewhere.
|
||||||
|
|
||||||
var Address = require('../Address').class();
|
var Address = require('../Address');
|
||||||
|
|
||||||
var addrStrings = [
|
var addrStrings = [
|
||||||
"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
|
"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
|
||||||
|
|||||||
@ -4,10 +4,9 @@
|
|||||||
|
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var networks = require('../networks');
|
var networks = require('../networks');
|
||||||
var Peer = require('../Peer').class();
|
var Peer = require('../Peer');
|
||||||
var PeerManager = require('../PeerManager').createClass({
|
var PeerManager = require('soop').load('../PeerManager',
|
||||||
network: networks.testnet
|
{network: networks.testnet});
|
||||||
});
|
|
||||||
|
|
||||||
var handleBlock = function(info) {
|
var handleBlock = function(info) {
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
// Replace '..' with 'bitcore' if you plan on using this code elsewhere.
|
// Replace '..' with 'bitcore' if you plan on using this code elsewhere.
|
||||||
|
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var RpcClient = require('../RpcClient').class();
|
var RpcClient = require('../RpcClient');
|
||||||
var hash = process.argv[2] || '0000000000b6288775bbd326bedf324ca8717a15191da58391535408205aada4';
|
var hash = process.argv[2] || '0000000000b6288775bbd326bedf324ca8717a15191da58391535408205aada4';
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
|
|||||||
@ -2,14 +2,13 @@
|
|||||||
// Replace '..' with 'bitcore' if you plan on using this code elsewhere.
|
// Replace '..' with 'bitcore' if you plan on using this code elsewhere.
|
||||||
|
|
||||||
var networks = require('../networks');
|
var networks = require('../networks');
|
||||||
var Peer = require('../Peer').class();
|
var Peer = require('../Peer');
|
||||||
var Transaction = require('../Transaction').class();
|
var Transaction = require('../Transaction');
|
||||||
var Address = require('../Address').class();
|
var Address = require('../Address');
|
||||||
var Script = require('../Script').class();
|
var Script = require('../Script');
|
||||||
var coinUtil = require('../util/util');
|
var coinUtil = require('../util/util');
|
||||||
var PeerManager = require('../PeerManager').createClass({
|
var PeerManager = require('soop').load('../PeerManager',
|
||||||
network: networks.testnet
|
{network: networks.testnet});
|
||||||
});
|
|
||||||
|
|
||||||
var createTx = function() {
|
var createTx = function() {
|
||||||
|
|
||||||
|
|||||||
@ -6,18 +6,19 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<pre>
|
||||||
<div id='content'></div>
|
<div id='content'></div>
|
||||||
|
</pre>
|
||||||
<script src="../browser/bundle.js"></script>
|
<script src="../browser/bundle.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
var Address = require('Address');
|
||||||
|
|
||||||
print = function(s){
|
print = function(s){
|
||||||
var div = document.getElementById('content');
|
var div = document.getElementById('content');
|
||||||
div.innerHTML += s + '<br />';
|
div.innerHTML += s + '<br />';
|
||||||
};
|
};
|
||||||
|
|
||||||
var Address = bitcore.Address.class();
|
|
||||||
|
|
||||||
var addrStrings = [
|
var addrStrings = [
|
||||||
"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
|
"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
|
||||||
"1A1zP1eP5QGefi2DMPTfTL5SLmv7Dixxxx",
|
"1A1zP1eP5QGefi2DMPTfTL5SLmv7Dixxxx",
|
||||||
@ -37,15 +38,33 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
print('<hr>');
|
||||||
|
|
||||||
|
var Key = require('KeyModule').Key;
|
||||||
var Key = bitcore.KeyModule.Key;
|
var buffertools = require('buffertools');
|
||||||
var k = Key.generateSync();
|
var k = Key.generateSync();
|
||||||
|
|
||||||
print ('Generated Key Pair:');
|
print ('Generate Key Pair:');
|
||||||
print ('Private:' + bitcore.buffertools.toHex(k.private));
|
print ('Private:' + buffertools.toHex(k.private));
|
||||||
print ('Public:' + bitcore.buffertools.toHex(k.public));
|
print ('Public:' + buffertools.toHex(k.public));
|
||||||
|
|
||||||
|
print('<hr>');
|
||||||
|
/*
|
||||||
|
Using bitcore root module
|
||||||
|
*/
|
||||||
|
|
||||||
|
var bitcore = require('bitcore');
|
||||||
|
var k = bitcore.KeyModule.Key.generateSync();
|
||||||
|
|
||||||
|
print ('Generate Key Pair:');
|
||||||
|
print ('Private:' + buffertools.toHex(k.private));
|
||||||
|
print ('Public:' + buffertools.toHex(k.public));
|
||||||
|
|
||||||
|
print('<hr>');
|
||||||
|
|
||||||
|
console.log('[example.html.65:PeerManager:]'); //TODO
|
||||||
|
|
||||||
|
var pm = require('PeerManager');
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@ -44,7 +44,7 @@
|
|||||||
"test": "mocha test -R spec"
|
"test": "mocha test -R spec"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"classtool": "git://github.com/bitpay/classtool.git",
|
"soop": "git://github.com/matiu/node-soop.git#feature/browser-support",
|
||||||
"base58-native": "=0.1.3",
|
"base58-native": "=0.1.3",
|
||||||
"bindings": "=1.1.1",
|
"bindings": "=1.1.1",
|
||||||
"bufferput": "git://github.com/bitpay/node-bufferput.git",
|
"bufferput": "git://github.com/bitpay/node-bufferput.git",
|
||||||
@ -57,7 +57,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"grunt-contrib-watch": "~0.5.3",
|
"grunt-contrib-watch": "~0.5.3",
|
||||||
"grunt-mocha-test": "~0.8.2",
|
"grunt-mocha-test": "~0.8.2",
|
||||||
"grunt-browserify": "~1.3.0",
|
"grunt-shell": "~0.6.4",
|
||||||
|
"browser-pack": "*",
|
||||||
"grunt-markdown": "~0.5.0",
|
"grunt-markdown": "~0.5.0",
|
||||||
"mocha": ">=1.15.1",
|
"mocha": ">=1.15.1",
|
||||||
"browserify-bignum": "git://github.com/maraoz/browserify-bignum.git",
|
"browserify-bignum": "git://github.com/maraoz/browserify-bignum.git",
|
||||||
|
|||||||
@ -13,7 +13,14 @@
|
|||||||
<script>mocha.setup('bdd')</script>
|
<script>mocha.setup('bdd')</script>
|
||||||
<script src="../browser/bundle.js"></script>
|
<script src="../browser/bundle.js"></script>
|
||||||
<script src="../browser/testdata.js"></script>
|
<script src="../browser/testdata.js"></script>
|
||||||
<script src="adapter.js"></script>
|
|
||||||
|
<script>
|
||||||
|
var bitcore = require('bitcore');
|
||||||
|
this.Buffer = require('buffer').Buffer;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <script src="adapter.js"></script> -->
|
||||||
|
|
||||||
<script src="test.Address.js"></script>
|
<script src="test.Address.js"></script>
|
||||||
<script src="test.basic.js"></script>
|
<script src="test.basic.js"></script>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ describe('Address', function() {
|
|||||||
should.exist(AddressModule);
|
should.exist(AddressModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
Address = AddressModule.class();
|
Address = AddressModule;
|
||||||
should.exist(Address);
|
should.exist(Address);
|
||||||
});
|
});
|
||||||
it('should be able to create instance', function() {
|
it('should be able to create instance', function() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
var BlockModule = bitcore.Block;
|
var BlockModule = bitcore.Block;
|
||||||
@ -12,7 +12,7 @@ describe('Block', function() {
|
|||||||
should.exist(BlockModule);
|
should.exist(BlockModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
Block = BlockModule.class();
|
Block = BlockModule;
|
||||||
should.exist(Block);
|
should.exist(Block);
|
||||||
});
|
});
|
||||||
it('should be able to create instance', function() {
|
it('should be able to create instance', function() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ describe('Bloom', function() {
|
|||||||
should.exist(BloomModule);
|
should.exist(BloomModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
Bloom = BloomModule.class();
|
Bloom = BloomModule;
|
||||||
should.exist(Bloom);
|
should.exist(Bloom);
|
||||||
});
|
});
|
||||||
it('should be able to create instance', function() {
|
it('should be able to create instance', function() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ describe('Connection', function() {
|
|||||||
should.exist(ConnectionModule);
|
should.exist(ConnectionModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
Connection = ConnectionModule.class();
|
Connection = ConnectionModule;
|
||||||
should.exist(Connection);
|
should.exist(Connection);
|
||||||
});
|
});
|
||||||
it('should be able to create instance', function() {
|
it('should be able to create instance', function() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ describe('EncodedData', function() {
|
|||||||
should.exist(EncodedDataModule);
|
should.exist(EncodedDataModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
EncodedData = EncodedDataModule.class();
|
EncodedData = EncodedDataModule;
|
||||||
should.exist(EncodedData);
|
should.exist(EncodedData);
|
||||||
});
|
});
|
||||||
it('should be able to create an instance', function() {
|
it('should be able to create an instance', function() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var buffertools = require('buffertools');
|
var buffertools = require('buffertools');
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ describe('Opcode', function() {
|
|||||||
should.exist(OpcodeModule);
|
should.exist(OpcodeModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
Opcode = OpcodeModule.class();
|
Opcode = OpcodeModule;
|
||||||
should.exist(Opcode);
|
should.exist(Opcode);
|
||||||
});
|
});
|
||||||
it('should be able to create instance', function() {
|
it('should be able to create instance', function() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ describe('Peer', function() {
|
|||||||
should.exist(PeerModule);
|
should.exist(PeerModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
Peer = PeerModule.class();
|
Peer = PeerModule;
|
||||||
should.exist(Peer);
|
should.exist(Peer);
|
||||||
});
|
});
|
||||||
it('should be able to create instance', function() {
|
it('should be able to create instance', function() {
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
var PeerManagerModule = bitcore.PeerManager;
|
var PeerManagerModule = bitcore.PeerManager || require('PeerManager');
|
||||||
|
|
||||||
var PeerManager;
|
var PeerManager;
|
||||||
|
|
||||||
describe('PeerManager', function() {
|
describe('PeerManager', function() {
|
||||||
@ -13,7 +14,7 @@ describe('PeerManager', function() {
|
|||||||
should.exist(PeerManagerModule);
|
should.exist(PeerManagerModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
PeerManager = PeerManagerModule.class();
|
PeerManager = PeerManagerModule;
|
||||||
should.exist(PeerManager);
|
should.exist(PeerManager);
|
||||||
});
|
});
|
||||||
it('should be able to create instance', function() {
|
it('should be able to create instance', function() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ describe('PrivateKey', function() {
|
|||||||
should.exist(PrivateKeyModule);
|
should.exist(PrivateKeyModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
PrivateKey = PrivateKeyModule.class();
|
PrivateKey = PrivateKeyModule;
|
||||||
should.exist(PrivateKey);
|
should.exist(PrivateKey);
|
||||||
});
|
});
|
||||||
it('should be able to create instance', function() {
|
it('should be able to create instance', function() {
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
var RpcClientModule = bitcore.RpcClient;
|
var RpcClientModule = bitcore.RpcClient;
|
||||||
var RpcClient;
|
var RpcClient;
|
||||||
RpcClient = RpcClientModule.class();
|
RpcClient = RpcClientModule;
|
||||||
|
|
||||||
describe('RpcClient', function() {
|
describe('RpcClient', function() {
|
||||||
it('should initialze the main object', function() {
|
it('should initialze the main object', function() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ describe('SIN', function() {
|
|||||||
should.exist(SINModule);
|
should.exist(SINModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
SIN = SINModule.class();
|
SIN = SINModule;
|
||||||
should.exist(SIN);
|
should.exist(SIN);
|
||||||
});
|
});
|
||||||
it('should be able to create instance', function() {
|
it('should be able to create instance', function() {
|
||||||
|
|||||||
@ -1,10 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var chai = chai || require('chai');
|
||||||
|
var bitcore = bitcore || require('../bitcore');
|
||||||
var chai = require('chai');
|
|
||||||
var bitcore = require('../bitcore');
|
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
var SINKeyModule = bitcore.SINKey;
|
var SINKeyModule = bitcore.SINKey;
|
||||||
@ -16,7 +13,7 @@ describe('SINKey', function() {
|
|||||||
should.exist(SINKeyModule);
|
should.exist(SINKeyModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
SINKey = SINKeyModule.class();
|
SINKey = SINKeyModule;
|
||||||
should.exist(SINKey);
|
should.exist(SINKey);
|
||||||
});
|
});
|
||||||
it('should be able to create instance', function() {
|
it('should be able to create instance', function() {
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
var ScriptModule = bitcore.Script;
|
var ScriptModule = bitcore.Script;
|
||||||
var Address = bitcore.Address.class();
|
var Address = bitcore.Address;
|
||||||
var networks = bitcore.networks;
|
var networks = bitcore.networks;
|
||||||
var Script;
|
var Script;
|
||||||
var test_data = require('./testdata');
|
var test_data = require('./testdata');
|
||||||
@ -16,7 +16,7 @@ describe('Script', function() {
|
|||||||
should.exist(ScriptModule);
|
should.exist(ScriptModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
Script = ScriptModule.class();
|
Script = ScriptModule;
|
||||||
should.exist(Script);
|
should.exist(Script);
|
||||||
});
|
});
|
||||||
it('should be able to create instance', function() {
|
it('should be able to create instance', function() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ describe('ScriptInterpreter', function() {
|
|||||||
should.exist(ScriptInterpreterModule);
|
should.exist(ScriptInterpreterModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
ScriptInterpreter = ScriptInterpreterModule.class();
|
ScriptInterpreter = ScriptInterpreterModule;
|
||||||
should.exist(ScriptInterpreter);
|
should.exist(ScriptInterpreter);
|
||||||
});
|
});
|
||||||
it('should be able to create instance', function() {
|
it('should be able to create instance', function() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
@ -9,7 +9,7 @@ var TransactionModule = bitcore.Transaction;
|
|||||||
var Transaction;
|
var Transaction;
|
||||||
var In;
|
var In;
|
||||||
var Out;
|
var Out;
|
||||||
var Script = bitcore.Script.class();
|
var Script = bitcore.Script;
|
||||||
var buffertools = require('buffertools');
|
var buffertools = require('buffertools');
|
||||||
var test_data = require('./testdata');
|
var test_data = require('./testdata');
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ describe('Transaction', function() {
|
|||||||
should.exist(TransactionModule);
|
should.exist(TransactionModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
Transaction = TransactionModule.class();
|
Transaction = TransactionModule;
|
||||||
should.exist(Transaction);
|
should.exist(Transaction);
|
||||||
In = Transaction.In;
|
In = Transaction.In;
|
||||||
Out = Transaction.Out;
|
Out = Transaction.Out;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ describe('VersionedData', function() {
|
|||||||
should.exist(VersionedDataModule);
|
should.exist(VersionedDataModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
VersionedData = VersionedDataModule.class();
|
VersionedData = VersionedDataModule;
|
||||||
should.exist(VersionedData);
|
should.exist(VersionedData);
|
||||||
});
|
});
|
||||||
it('should be able to create an instance', function() {
|
it('should be able to create an instance', function() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ describe('Wallet', function() {
|
|||||||
should.exist(WalletModule);
|
should.exist(WalletModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
Wallet = WalletModule.class();
|
Wallet = WalletModule;
|
||||||
should.exist(Wallet);
|
should.exist(Wallet);
|
||||||
});
|
});
|
||||||
it('should be able to create instance', function() {
|
it('should be able to create instance', function() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ describe('WalletKey', function() {
|
|||||||
should.exist(WalletKeyModule);
|
should.exist(WalletKeyModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
WalletKey = WalletKeyModule.class();
|
WalletKey = WalletKeyModule;
|
||||||
should.exist(WalletKey);
|
should.exist(WalletKey);
|
||||||
});
|
});
|
||||||
it('should be able to create instance', function() {
|
it('should be able to create instance', function() {
|
||||||
|
|||||||
@ -1,15 +1,27 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
|
var test_data;
|
||||||
|
if (typeof dataValid !== 'undefined' ) {
|
||||||
|
test_data = {
|
||||||
|
dataValid: dataValid,
|
||||||
|
dataInvalid: dataInvalid,
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
test_data = require('./testdata');
|
||||||
|
}
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
var Address = bitcore.Address.class();
|
var Address = bitcore.Address;
|
||||||
var PrivateKey = bitcore.PrivateKey.class();
|
var PrivateKey = bitcore.PrivateKey;
|
||||||
var networks = bitcore.networks;
|
var networks = bitcore.networks;
|
||||||
var KeyModule = bitcore.KeyModule;
|
var KeyModule = bitcore.KeyModule;
|
||||||
|
|
||||||
var test_data = require('./testdata');
|
|
||||||
|
|
||||||
|
|
||||||
function test_encode_priv(b58, payload, isTestnet, isCompressed) {
|
function test_encode_priv(b58, payload, isTestnet, isCompressed) {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var expect = chai.expect;
|
var expect = chai.expect;
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = chai || require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = bitcore || require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
var chai = require('chai');
|
|
||||||
var bitcore = require('../bitcore');
|
var chai = chai || require('chai');
|
||||||
|
var bitcore = bitcore || require('../bitcore');
|
||||||
var coinUtil = bitcore.util;
|
var coinUtil = bitcore.util;
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
var buffertools = require('buffertools');
|
var buffertools = require('buffertools');
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
|
||||||
var dataValid = JSON.parse(fs.readFileSync('test/data/base58_keys_valid.json'));
|
var dataValid = JSON.parse(fs.readFileSync('test/data/base58_keys_valid.json'));
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* Simple synchronous parser based on node-binary.
|
* Simple synchronous parser based on node-binary.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function spec(b) {
|
var imports = require('soop').imports();
|
||||||
function Parser(buffer)
|
function Parser(buffer)
|
||||||
{
|
{
|
||||||
this.subject = buffer;
|
this.subject = buffer;
|
||||||
@ -143,6 +143,4 @@ function spec(b) {
|
|||||||
return this.buffer(len);
|
return this.buffer(len);
|
||||||
};
|
};
|
||||||
|
|
||||||
return Parser;
|
module.exports = require('soop')(Parser);
|
||||||
};
|
|
||||||
module.defineClass(spec);
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
require('classtool');
|
var imports = require('soop').imports();
|
||||||
|
var base58 = imports.base58 || require('base58-native').base58Check;
|
||||||
|
|
||||||
function ClassSpec(b) {
|
|
||||||
var base58 = b.base58 || require('base58-native').base58Check;
|
|
||||||
|
|
||||||
// Constructor. Takes the following forms:
|
// Constructor. Takes the following forms:
|
||||||
// new EncodedData(<base58_address_string>)
|
// new EncodedData(<base58_address_string>)
|
||||||
@ -154,6 +153,6 @@ function ClassSpec(b) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
EncodedData.applyEncodingsTo(EncodedData);
|
EncodedData.applyEncodingsTo(EncodedData);
|
||||||
return EncodedData;
|
|
||||||
}
|
module.exports = require('soop')(EncodedData);
|
||||||
module.defineClass(ClassSpec);
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
require('classtool');
|
var imports = require('soop').imports();
|
||||||
|
var base58 = imports.base58 || require('base58-native').base58Check;
|
||||||
|
var parent = imports.parent || require('./EncodedData');
|
||||||
|
|
||||||
function ClassSpec(b) {
|
|
||||||
var superclass = b.superclass || require('./EncodedData').class();
|
|
||||||
|
|
||||||
function VersionedData(version, payload) {
|
function VersionedData(version, payload) {
|
||||||
if(typeof version != 'number') {
|
if(typeof version != 'number') {
|
||||||
@ -13,8 +13,9 @@ function ClassSpec(b) {
|
|||||||
this.version(version);
|
this.version(version);
|
||||||
this.payload(payload);
|
this.payload(payload);
|
||||||
};
|
};
|
||||||
VersionedData.superclass = superclass;
|
|
||||||
superclass.applyEncodingsTo(VersionedData);
|
VersionedData.parent = parent;
|
||||||
|
parent.applyEncodingsTo(VersionedData);
|
||||||
|
|
||||||
// get or set the version data (the first byte of the address)
|
// get or set the version data (the first byte of the address)
|
||||||
VersionedData.prototype.version = function(num) {
|
VersionedData.prototype.version = function(num) {
|
||||||
@ -34,6 +35,4 @@ function ClassSpec(b) {
|
|||||||
return this.as('binary').slice(1);
|
return this.as('binary').slice(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
return VersionedData;
|
module.exports = require('soop')(VersionedData);
|
||||||
};
|
|
||||||
module.defineClass(ClassSpec);
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user