You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.1 KiB

10 years ago
#!/usr/bin/env node
10 years ago
var _ = require('lodash');
10 years ago
var program = require('commander');
var ClientLib = require('../lib/clientlib.js');
var common = require('./common');
program
10 years ago
.version('0.0.1')
.option('-c,--config [file]', 'Wallet config filename')
.option('-v,--verbose', 'be verbose')
.usage('[options] <txpid>')
.parse(process.argv);
10 years ago
var args = program.args;
10 years ago
if (!args[0])
10 years ago
program.help();
10 years ago
var txpid = args[0];
10 years ago
10 years ago
var cli = new ClientLib({
filename: program.config
10 years ago
});
10 years ago
cli.txProposals({}, function(err, x) {
common.die(err);
10 years ago
10 years ago
if (program.verbose)
console.log('* Raw Server Response:\n', x); //TODO
var txps = _.filter(x, function(x) {
10 years ago
return _.endsWith(common.shortID(x.id), txpid);
10 years ago
});
if (!txps.length)
10 years ago
common.die('Could not find TX Proposal:' + txpid);
10 years ago
if (txps.length > 1)
10 years ago
common.die('More that one TX Proposals match:' + txpid + ' : ' + _.map(txps, function(x) {
10 years ago
return x.id;
}).join(' '));;
var txp = txps[0];
10 years ago
cli.sign(txp, function(err, x) {
common.die(err);
if (program.verbose)
console.log('* Raw Server Response:\n', x); //TODO
console.log('Transaction signed.');
});
10 years ago
});