Skip to content
This repository has been archived by the owner on Nov 16, 2019. It is now read-only.

Commit

Permalink
Revert refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared Deckard committed Sep 17, 2014
1 parent fc1fcc6 commit 22962b3
Show file tree
Hide file tree
Showing 275 changed files with 46,536 additions and 255 deletions.
57 changes: 48 additions & 9 deletions Gulpfile.js
Expand Up @@ -5,7 +5,6 @@ var rename = require('gulp-rename');
var webpack = require('webpack');
var jshint = require('gulp-jshint');
var map = require('map-stream');
var exec = require('gulp-exec');
//var header = require('gulp-header');

var pkg = require('./package.json');
Expand All @@ -16,10 +15,50 @@ var banner = '/*! <%= pkg.name %> - v<%= pkg.version %> - '
+ '* Copyright (c) <%= new Date().getFullYear() %> <%= pkg.author.name %>;'
+ ' Licensed <%= pkg.license %> */'

gulp.task('build', [], function(callback) {
var sjclSrc = [
'src/js/sjcl/core/sjcl.js',
'src/js/sjcl/core/aes.js',
'src/js/sjcl/core/bitArray.js',
'src/js/sjcl/core/codecString.js',
'src/js/sjcl/core/codecHex.js',
'src/js/sjcl/core/codecBase64.js',
'src/js/sjcl/core/codecBytes.js',
'src/js/sjcl/core/sha256.js',
'src/js/sjcl/core/sha512.js',
'src/js/sjcl/core/sha1.js',
'src/js/sjcl/core/ccm.js',
'src/js/sjcl/core/gcm.js',
// 'src/js/sjcl/core/cbc.js',
// 'src/js/sjcl/core/ocb2.js',
'src/js/sjcl/core/hmac.js',
'src/js/sjcl/core/pbkdf2.js',
'src/js/sjcl/core/random.js',
'src/js/sjcl/core/convenience.js',
'src/js/sjcl/core/bn.js',
'src/js/sjcl/core/ecc.js',
'src/js/sjcl/core/srp.js',
'src/js/sjcl-custom/sjcl-ecc-pointextras.js',
'src/js/sjcl-custom/sjcl-secp256k1.js',
'src/js/sjcl-custom/sjcl-ripemd160.js',
'src/js/sjcl-custom/sjcl-extramath.js',
'src/js/sjcl-custom/sjcl-montgomery.js',
'src/js/sjcl-custom/sjcl-validecc.js',
'src/js/sjcl-custom/sjcl-ecdsa-canonical.js',
'src/js/sjcl-custom/sjcl-ecdsa-der.js',
'src/js/sjcl-custom/sjcl-ecdsa-recoverablepublickey.js',
'src/js/sjcl-custom/sjcl-jacobi.js'
];

gulp.task('concat-sjcl', function() {
return gulp.src(sjclSrc)
.pipe(concat('sjcl.js'))
.pipe(gulp.dest('./build/'));
});

gulp.task('build', [ 'concat-sjcl' ], function(callback) {
webpack({
cache: true,
entry: './src/index.js',
entry: './src/js/ripple/index.js',
output: {
library: 'stellar',
path: './build/',
Expand All @@ -29,16 +68,16 @@ gulp.task('build', [], function(callback) {
});

gulp.task('build-min', [ 'build' ], function(callback) {
return gulp.src([ './build/stellar-', '.js' ].join(pkg.version))
return gulp.src([ './build/ripple-', '.js' ].join(pkg.version))
.pipe(uglify())
.pipe(rename([ 'stellar-', '-min.js' ].join(pkg.version)))
.pipe(gulp.dest('./build/'));
});

gulp.task('build-debug', [], function(callback) {
gulp.task('build-debug', [ 'concat-sjcl' ], function(callback) {
webpack({
cache: true,
entry: './src/index.js',
entry: './src/js/ripple/index.js',
output: {
library: 'stellar',
path: './build/',
Expand All @@ -50,7 +89,7 @@ gulp.task('build-debug', [], function(callback) {
});

gulp.task('lint', function() {
gulp.src('src/*.js')
gulp.src('src/js/ripple/*.js')
.pipe(jshint())
.pipe(map(function(file, callback) {
if (!file.jshint.success) {
Expand All @@ -76,7 +115,7 @@ gulp.task('lint', function() {
});

gulp.task('watch', function() {
gulp.watch('src/*', [ 'build-debug' ]);
gulp.watch('src/js/ripple/*', [ 'build-debug' ]);
});

gulp.task('default', [ 'build', 'build-debug', 'build-min' ]);
gulp.task('default', [ 'concat-sjcl', 'build', 'build-debug', 'build-min' ]);
45 changes: 45 additions & 0 deletions HISTORY.md
@@ -0,0 +1,45 @@

##0.7.35

+ `LastLedgerSequence` is set by default on outgoing transactions. This refers to the last valid ledger index (AKA sequence) for a transaction. By default, this index is set to the current index (at submission time) plus 8. In theory, this allows ripple-lib to deterministically fail a transaction whose submission request timed out, but whose associated server continues to emit ledger_closed events.

+ Transactions that err with `telINSUF_FEE_P` will be automatically resubmitted. This error indicates that the `Fee` supplied in the transaction submission request was inadquate. Ideally, the `Fee` is tracked by ripple-lib in real-time, and the resubmitted transaction will most likely succeed.

+ Added Transaction.iff(function(callback) { }). Callback expects first argument to be an Error or null, second argument is a boolean which indicates whether or not to proceed with the transaction submission. If an `iff` function is specified, it will be executed prior to every submission of the transaction (including resubmissions).

+ Transactions will now emit `presubmit` and `postsubmit` events. They will be emitted before and after a transaction is submitted, respectively.

+ Added Transaction.summary(). Returns a summary of a transaction in semi-human-readable form. JSON-stringifiable.

+ Remote.requestAccountTx() with `binary: true` will automatically parse transactions.

+ Added Remote.requestAccountTx filter, map, and reduce.

```js
remote.requestAccountTx({
account: 'retc',
ledger_index_min: -1,
ledger_index_max: -1,
limit: 100,
binary: true,

filter: function(transaction) {
return transaction.tx.TransactionType === 'Payment';
},

map: function(transaction) {
return Number(transaction.tx.Amount);
},

reduce: function(a, b) {
return a + b;
},

pluck: 'transactions'
}, console.log)
```

+ Added persistence hooks.

+ General performance improvements, especially for long-running processes.

44 changes: 44 additions & 0 deletions bench/modpow.js
@@ -0,0 +1,44 @@
var Benchmark;
try {
Benchmark = require('benchmark');
} catch (e) {
console.error("Please install Benchmark.js: npm install benchmark");
process.exit(1);
}

var sjcl = require('../build/sjcl');
var jsbn = require('../src/js/jsbn/jsbn');

var base = "3f70f29d3f3ae354a6d2536ceafba83cfc787cd91e7acd2b6bde05e62beb8295ae18e3f786726f8d034bbc15bf8331df959f59d431736d5f306aaba63dacec279484e39d76db9b527738072af15730e8b9956a64e8e4dbe868f77d1414a8a8b8bf65380a1f008d39c5fabe1a9f8343929342ab7b4f635bdc52532d764701ff3d8072c475c012ff0c59373e8bc423928d99f58c3a6d9f6ab21ee20bc8e8818fc147db09f60c81906f2c6f73dc69725f075853a89f0cd02a30a8dd86b660ccdeffc292f398efb54088c822774445a6afde471f7dd327ef9996296898a5747726ccaeeceeb2e459df98b4128cb5ab8c7cd20c563f960a1aa770f3c81f13f967b6cc";
var exponent = "322e393f76a1c22b147e7d193c00c023afb7c1500b006ff1bc1cc8d391fc38bd";
var modulus = "c7f1bc1dfb1be82d244aef01228c1409c198894eca9e21430f1669b4aa3864c9f37f3d51b2b4ba1ab9e80f59d267fda1521e88b05117993175e004543c6e3611242f24432ce8efa3b81f0ff660b4f91c5d52f2511a6f38181a7bf9abeef72db056508bbb4eeb5f65f161dd2d5b439655d2ae7081fcc62fdcb281520911d96700c85cdaf12e7d1f15b55ade867240722425198d4ce39019550c4c8a921fc231d3e94297688c2d77cd68ee8fdeda38b7f9a274701fef23b4eaa6c1a9c15b2d77f37634930386fc20ec291be95aed9956801e1c76601b09c413ad915ff03bfdc0b6b233686ae59e8caf11750b509ab4e57ee09202239baee3d6e392d1640185e1cd";
var expected = "5b3823974b3eda87286d3f38499de290bd575d8b02f06720acacf3d50950f9ca0ff6b749f3be03913ddca0b291e0b263bdab6c9cb97e4ab47ee9c235ff20931a8ca358726fab93614e2c549594f5c50b1c979b34f840b6d4fc51d6feb2dd072995421d17862cb405e040fc1ed662a3245a1f97bbafa6d1f7f76c7db6a802e3037acdf01ab5053f5da518d6753477193b9c25e1720519dcb9e2f6e70d5786656d356151845a49861dfc40187eff0e85cd18b1f3f3b97c476472edfa090b868b2388edfffecc521c20df8cebb8aacfb3669b020330dd6ea64b2a3067a972b8f249bccc19347eff43893e916f0949bd5789a5cce0f8b7cd87cece909d679345c0d4";

var BigInteger = jsbn.BigInteger;
var jsbnBase = new BigInteger(base, 16);
var jsbnExponent = new BigInteger(exponent, 16);
var jsbnModulus = new BigInteger(modulus, 16);

var bn = sjcl.bn;
var sjclBase = new bn(base);
var sjclExponent = new bn(exponent);
var sjclModulus = new bn(modulus);

var suite = new Benchmark.Suite;

// add tests
suite.add('jsbn#modPow', function() {
jsbnBase.modPow(jsbnExponent, jsbnModulus);
});
suite.add('sjcl#powermodMontgomery', function() {
sjclBase.powermodMontgomery(sjclExponent, sjclModulus);
});
suite.on('cycle', function(event) {
console.log(String(event.target));
});
suite.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').pluck('name'));
});
// run async
console.log("Running benchmark...");
suite.run({ 'async': false });
47 changes: 47 additions & 0 deletions bin/decode_binary.js
@@ -0,0 +1,47 @@
#!/usr/bin/env node

var SerializedObject = require('../src/js/ripple/serializedobject').SerializedObject;

var argv = process.argv.slice(2);

var blob;

blob = argv.shift();

if (blob === '-') {
read_input(ready);
} else {
ready();
}

function read_input(callback) {
tx_json = '';
process.stdin.on('data', function(data) { tx_json += data; });
process.stdin.on('end', callback);
process.stdin.resume();
}

function ready() {
var valid_arguments = blob;

if (!valid_arguments) {
console.error('Invalid arguments\n');
print_usage();
} else {
decode();
}
}

function print_usage() {
console.log(
'Usage: decode_binary.js <hex_blob>\n\n',
'Example: decode_binary.js 120000240000000161D6871AFD498D00000000000000000000000000005553440000000000550FC62003E785DC231A1058A05E56E3F09CF4E668400000000000000A732102AE75B908F0A95F740A7BFA96057637E5C2170BC8DAD13B2F7B52AE75FAEBEFCF811450F97A072F1C4357F1AD84566A609479D927C9428314550FC62003E785DC231A1058A05E56E3F09CF4E6'
);
};

function decode() {
buffer = new SerializedObject(blob);
console.log(buffer.to_json());
};

// vim:sw=2:sts=2:ts=8:et
96 changes: 96 additions & 0 deletions bin/rsign.js
@@ -0,0 +1,96 @@
#!/usr/bin/env node

var Transaction = require('../src/js/ripple/transaction').Transaction;

var argv = process.argv.slice(2);

var verbose;
var secret;
var tx_json;

if (~argv.indexOf('-v')){
argv.splice(argv.indexOf('-v'), 1);
verbose = true;
}

secret = argv.shift();
tx_json = argv.shift();

if (tx_json === '-') {
read_input(ready);
} else {
ready();
}

function read_input(callback) {
tx_json = '';
process.stdin.on('data', function(data) { tx_json += data; });
process.stdin.on('end', callback);
process.stdin.resume();
}

function ready() {
var valid_arguments = secret && tx_json;

if (!valid_arguments) {
console.error('Invalid arguments\n');
print_usage();
} else {
var valid_json = true;

try {
tx_json = JSON.parse(tx_json);
} catch(exception) {
valid_json = false;
}

if (!valid_json) {
console.error('Invalid JSON\n');
print_usage();
} else {
sign_transaction();
}
}
}

function print_usage() {
console.log(
'Usage: rsign.js <secret> <json>\n\n',
'Example: rsign.js ssq55ueDob4yV3kPVnNQLHB6icwpC',
JSON.stringify({
TransactionType: 'Payment',
Account: 'r3P9vH81KBayazSTrQj6S25jW6kDb779Gi',
Destination: 'r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV',
Amount: '200000000',
Fee: '10',
Sequence: 1
})
);
};

function sign_transaction() {
var tx = new Transaction();

tx.tx_json = tx_json;
tx._secret = secret;
tx.complete();

var unsigned_blob = tx.serialize().to_hex();
var unsigned_hash = tx.signingHash();
tx.sign();

if (verbose) {
var sim = { };

sim.tx_blob = tx.serialize().to_hex();
sim.tx_json = tx.tx_json;
sim.tx_signing_hash = unsigned_hash;
sim.tx_unsigned = unsigned_blob;

console.log(JSON.stringify(sim, null, 2));
} else {
console.log(tx.serialize().to_hex());
}
};

// vim:sw=2:sts=2:ts=8:et
26 changes: 26 additions & 0 deletions bin/validate_address.js
@@ -0,0 +1,26 @@
#!/usr/bin/env node

var UInt160 = require('../').UInt160;
var address = process.argv[2];

if (address === '-') {
readInput(validateAddress);
} else {
validateAddress(address);
}

function readInput(callback) {
var result = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(data) {
result += data;
});
process.stdin.on('end', function() {
callback(result);
});
};

function validateAddress(address) {
process.stdout.write((UInt160.is_valid(address.trim()) ? '0' : '1') + '\r\n');
};
4 changes: 2 additions & 2 deletions bower.json
@@ -1,9 +1,9 @@
{
"name": "stellar-lib",
"version": "0.10.0",
"version": "0.9.2",
"homepage": "https://github.com/stellar/stellar-lib",
"description": "Stellar JavaScript client library",
"main": "build/stellar-0.10.0.js",
"main": "build/stellar-0.9.2.js",
"keywords": [
"stellar",
"javascript",
Expand Down
3 changes: 3 additions & 0 deletions deploy/start rippled.bat
@@ -0,0 +1,3 @@
start newcoin
sleep 4
start index.html

0 comments on commit 22962b3

Please sign in to comment.