Merge branch 'master' of github.com:jedmccaleb/NewCoin

This commit is contained in:
JoelKatz
2013-03-11 07:22:57 -07:00
4 changed files with 72 additions and 5 deletions

65
bin/rsign.js Executable file
View File

@@ -0,0 +1,65 @@
#!/usr/bin/node
var Transaction = require('../src/js/transaction').Transaction;
var cursor = 2;
var verbose;
var secret;
var tx_json;
var usage = function () {
console.log(
"Usage: rsign.js <secret> <json>\n"
+ " Example: rsign.js ssq55ueDob4yV3kPVnNQLHB6icwpC '{ \"TransactionType\" : \"Payment\", \"Account\" : \"r3P9vH81KBayazSTrQj6S25jW6kDb779Gi\", \"Destination\" : \"r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV\", \"Amount\" : \"200000000\", \"Fee\" : \"10\", \"Sequence\" : \"1\" }'"
);
};
if (process.argv.length > cursor && process.argv[cursor] === "-v")
{
verbose = true;
cursor++;
}
if (process.argv.length > cursor)
{
secret = process.argv[cursor++];
}
if (process.argv.length > cursor)
{
tx_json = JSON.parse(process.argv[cursor++]);
}
if (process.argv.length !== cursor || !secret || !tx_json)
{
usage();
}
else
{
var tx = new Transaction();
tx.tx_json = tx_json;
tx._secret = secret;
tx.complete();
var unsigned = tx.serialize().to_hex();
tx.sign();
if (verbose)
{
var sim = {};
sim.tx_blob = tx.serialize().to_hex();
sim.tx_json = tx.tx_json;
sim.tx_signing_hash = tx.signing_hash().to_hex();
sim.tx_unsigned = unsigned;
console.log(JSON.stringify(sim, undefined, 2));
}
else
{
console.log(tx.serialize().to_hex());
}
}
// vim:sw=2:sts=2:ts=8:et

View File

@@ -1,11 +1,12 @@
{
"name": "ripple-lib",
"version": "0.7.2",
"version": "0.7.3",
"description": "Ripple JavaScript client library",
"files": [
"src/js/*.js",
"build/sjcl.js"
"build/sjcl.js",
"bin/rsign.js"
],
"main": "src/js",
"directories": {

View File

@@ -178,10 +178,11 @@ Transaction.prototype.set_state = function (state) {
Transaction.prototype.complete = function () {
var tx_json = this.tx_json;
if (this.remote.local_fee && undefined === tx_json.Fee) {
if (undefined === tx_json.Fee && this.remote.local_fee) {
tx_json.Fee = Transaction.fees['default'].to_json();
}
if (this.remote.local_signing && undefined === tx_json.SigningPubKey) {
if (undefined === tx_json.SigningPubKey && (!this.remote || this.remote.local_signing)) {
var seed = Seed.from_json(this._secret);
var key = seed.get_key(this.tx_json.Account);
tx_json.SigningPubKey = key.to_hex_pub();