mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 20:25:48 +00:00
Fix requires in bin directory
This commit is contained in:
@@ -1,47 +1,52 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
/* eslint-disable no-var */
|
||||||
|
'use strict';
|
||||||
|
var SerializedObject = require('..').SerializedObject;
|
||||||
|
|
||||||
var SerializedObject = require('../src/js/ripple/serializedobject').SerializedObject;
|
function main() {
|
||||||
|
var argv = process.argv.slice(2);
|
||||||
|
var blob = argv.shift();
|
||||||
|
|
||||||
var argv = process.argv.slice(2);
|
if (blob === '-') {
|
||||||
|
read_input(ready);
|
||||||
var blob;
|
} else {
|
||||||
|
ready(blob);
|
||||||
blob = argv.shift();
|
}
|
||||||
|
|
||||||
if (blob === '-') {
|
|
||||||
read_input(ready);
|
|
||||||
} else {
|
|
||||||
ready();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function read_input(callback) {
|
function read_input(callback) {
|
||||||
tx_json = '';
|
var tx_json = '';
|
||||||
process.stdin.on('data', function(data) { tx_json += data; });
|
process.stdin.on('data', function(data) {
|
||||||
|
tx_json += data;
|
||||||
|
});
|
||||||
process.stdin.on('end', callback);
|
process.stdin.on('end', callback);
|
||||||
process.stdin.resume();
|
process.stdin.resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
function ready() {
|
function ready(blob) {
|
||||||
var valid_arguments = blob;
|
var valid_arguments = blob;
|
||||||
|
|
||||||
if (!valid_arguments) {
|
if (!valid_arguments) {
|
||||||
console.error('Invalid arguments\n');
|
console.error('Invalid arguments\n');
|
||||||
print_usage();
|
print_usage();
|
||||||
} else {
|
} else {
|
||||||
decode();
|
decode(blob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_usage() {
|
function print_usage() {
|
||||||
|
/* eslint-disable max-len */
|
||||||
console.log(
|
console.log(
|
||||||
'Usage: decode_binary.js <hex_blob>\n\n',
|
'Usage: decode_binary.js <hex_blob>\n\n',
|
||||||
'Example: decode_binary.js 120000240000000161D6871AFD498D00000000000000000000000000005553440000000000550FC62003E785DC231A1058A05E56E3F09CF4E668400000000000000A732102AE75B908F0A95F740A7BFA96057637E5C2170BC8DAD13B2F7B52AE75FAEBEFCF811450F97A072F1C4357F1AD84566A609479D927C9428314550FC62003E785DC231A1058A05E56E3F09CF4E6'
|
'Example: decode_binary.js 120000240000000161D6871AFD498D00000000000000000000000000005553440000000000550FC62003E785DC231A1058A05E56E3F09CF4E668400000000000000A732102AE75B908F0A95F740A7BFA96057637E5C2170BC8DAD13B2F7B52AE75FAEBEFCF811450F97A072F1C4357F1AD84566A609479D927C9428314550FC62003E785DC231A1058A05E56E3F09CF4E6'
|
||||||
);
|
);
|
||||||
};
|
/* eslint-enable max-len */
|
||||||
|
}
|
||||||
|
|
||||||
function decode() {
|
function decode(blob) {
|
||||||
buffer = new SerializedObject(blob);
|
var buffer = new SerializedObject(blob);
|
||||||
console.log(buffer.to_json());
|
console.log(buffer.to_json());
|
||||||
};
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
// vim:sw=2:sts=2:ts=8:et
|
// vim:sw=2:sts=2:ts=8:et
|
||||||
|
|||||||
123
bin/rsign.js
123
bin/rsign.js
@@ -1,62 +1,23 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
/* eslint-disable no-var */
|
||||||
var Transaction = require('../src/js/ripple/transaction').Transaction;
|
'use strict';
|
||||||
|
var Transaction = require('..').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) {
|
function read_input(callback) {
|
||||||
tx_json = '';
|
var stdin = '';
|
||||||
process.stdin.on('data', function(data) { tx_json += data; });
|
process.stdin.on('data', function(data) {
|
||||||
process.stdin.on('end', callback);
|
stdin += data;
|
||||||
|
});
|
||||||
|
process.stdin.on('end', function() {
|
||||||
|
callback(stdin);
|
||||||
|
});
|
||||||
process.stdin.resume();
|
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() {
|
function print_usage() {
|
||||||
console.log(
|
console.log(
|
||||||
'Usage: rsign.js <secret> <json>\n\n',
|
'Usage: rsign.js <secret> <json>\n\n',
|
||||||
'Example: rsign.js ssq55ueDob4yV3kPVnNQLHB6icwpC','\''+
|
'Example: rsign.js ssq55ueDob4yV3kPVnNQLHB6icwpC', '\'' +
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
TransactionType: 'Payment',
|
TransactionType: 'Payment',
|
||||||
Account: 'r3P9vH81KBayazSTrQj6S25jW6kDb779Gi',
|
Account: 'r3P9vH81KBayazSTrQj6S25jW6kDb779Gi',
|
||||||
@@ -64,14 +25,14 @@ function print_usage() {
|
|||||||
Amount: '200000000',
|
Amount: '200000000',
|
||||||
Fee: '10',
|
Fee: '10',
|
||||||
Sequence: 1
|
Sequence: 1
|
||||||
})+'\''
|
}) + '\''
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
function sign_transaction() {
|
function sign_transaction(tx_json_object, secret, verbose) {
|
||||||
var tx = new Transaction();
|
var tx = new Transaction();
|
||||||
|
|
||||||
tx.tx_json = tx_json;
|
tx.tx_json = tx_json_object;
|
||||||
tx._secret = secret;
|
tx._secret = secret;
|
||||||
tx.complete();
|
tx.complete();
|
||||||
|
|
||||||
@@ -81,16 +42,56 @@ function sign_transaction() {
|
|||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
var sim = { };
|
var sim = { };
|
||||||
|
sim.tx_blob = tx.serialize().to_hex();
|
||||||
sim.tx_blob = tx.serialize().to_hex();
|
sim.tx_json = tx.tx_json;
|
||||||
sim.tx_json = tx.tx_json;
|
|
||||||
sim.tx_signing_hash = unsigned_hash;
|
sim.tx_signing_hash = unsigned_hash;
|
||||||
sim.tx_unsigned = unsigned_blob;
|
sim.tx_unsigned = unsigned_blob;
|
||||||
|
|
||||||
console.log(JSON.stringify(sim, null, 2));
|
console.log(JSON.stringify(sim, null, 2));
|
||||||
} else {
|
} else {
|
||||||
console.log(tx.serialize().to_hex());
|
console.log(tx.serialize().to_hex());
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
function ready(tx_json, secret, verbose) {
|
||||||
|
if (!(tx_json && secret)) {
|
||||||
|
console.error('Invalid arguments\n');
|
||||||
|
print_usage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var tx_json_object;
|
||||||
|
try {
|
||||||
|
tx_json_object = JSON.parse(tx_json);
|
||||||
|
} catch(exception) {
|
||||||
|
console.error('Invalid JSON\n');
|
||||||
|
print_usage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sign_transaction(tx_json_object, secret, verbose);
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
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(function(stdin) {
|
||||||
|
ready(stdin, secret, verbose);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
ready(tx_json, secret, verbose);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
// vim:sw=2:sts=2:ts=8:et
|
// vim:sw=2:sts=2:ts=8:et
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
/* eslint-disable no-var */
|
||||||
|
'use strict';
|
||||||
|
var UInt160 = require('..').UInt160;
|
||||||
|
|
||||||
var UInt160 = require('../').UInt160;
|
function main() {
|
||||||
var address = process.argv[2];
|
var address = process.argv[2];
|
||||||
|
|
||||||
if (address === '-') {
|
if (address === '-') {
|
||||||
readInput(validateAddress);
|
readInput(validateAddress);
|
||||||
} else {
|
} else {
|
||||||
validateAddress(address);
|
validateAddress(address);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function readInput(callback) {
|
function readInput(callback) {
|
||||||
@@ -19,8 +23,10 @@ function readInput(callback) {
|
|||||||
process.stdin.on('end', function() {
|
process.stdin.on('end', function() {
|
||||||
callback(result);
|
callback(result);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
function validateAddress(address) {
|
function validateAddress(address) {
|
||||||
process.stdout.write((UInt160.is_valid(address.trim()) ? '0' : '1') + '\r\n');
|
process.stdout.write((UInt160.is_valid(address.trim()) ? '0' : '1') + '\r\n');
|
||||||
};
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
|
|||||||
@@ -51,7 +51,8 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "gulp",
|
"build": "gulp",
|
||||||
"compile": "babel --optional runtime -d dist/npm/ src/",
|
"compile": "babel -i runtime -d dist/npm/ src/",
|
||||||
|
"compile-with-source-maps": "babel -i runtime -s -t -d dist/npm/ src/",
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"postinstall": "cd node_modules/sjcl; ./configure --with-all --compress=none; make",
|
"postinstall": "cd node_modules/sjcl; ./configure --with-all --compress=none; make",
|
||||||
"test": "istanbul test _mocha",
|
"test": "istanbul test _mocha",
|
||||||
|
|||||||
Reference in New Issue
Block a user