diff --git a/bin/rsign.js b/bin/rsign.js new file mode 100755 index 000000000..431b49431 --- /dev/null +++ b/bin/rsign.js @@ -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 \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 diff --git a/package.json b/package.json index 1cbd65733..997dbaa68 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/js/sjcl b/src/js/sjcl index d04d0bdcc..dbdef434e 160000 --- a/src/js/sjcl +++ b/src/js/sjcl @@ -1 +1 @@ -Subproject commit d04d0bdccd986e434b98fe393e1e01286c10fc36 +Subproject commit dbdef434e76c3f16835f3126a7ff1c717b1ce8af diff --git a/src/js/transaction.js b/src/js/transaction.js index 61eb541a1..ee82d0bb7 100644 --- a/src/js/transaction.js +++ b/src/js/transaction.js @@ -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();