-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
rsign.js
executable file
·65 lines (52 loc) · 1.38 KB
/
rsign.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/node
var Transaction = require('ripple-lib').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