Matias Alejo Garcia
10 years ago
9 changed files with 142 additions and 4 deletions
@ -0,0 +1,14 @@ |
|||
#!/usr/bin/env node |
|||
|
|||
var program = require('commander'); |
|||
var cli = require('../lib/clilib.js'); |
|||
|
|||
program |
|||
.version('0.0.1') |
|||
.command('create <walletName> <m-n> [username]', 'creates a wallet') |
|||
.command('join <secret> [username]', 'join a wallet') |
|||
.command('status', 'get wallet status') |
|||
.parse(process.argv); |
|||
|
|||
|
|||
|
@ -0,0 +1,29 @@ |
|||
#!/usr/bin/env node |
|||
|
|||
var program = require('commander'); |
|||
var cli = require('../lib/clilib.js'); |
|||
var common = require('./common'); |
|||
|
|||
program |
|||
.version('0.0.1') |
|||
.option('-c,--config [file]', 'Wallet config filename') |
|||
.usage('[options] <walletName> <m-n> [copayerName]') |
|||
.parse(process.argv); |
|||
|
|||
var args = program.args; |
|||
if (!args[0]) |
|||
program.help(); |
|||
|
|||
var walletName = args[0]; |
|||
var copayerName = args[2] || process.env.USER; |
|||
|
|||
var mn = common.parseMN(args[1]); |
|||
|
|||
cli.setFilename(program.config); |
|||
|
|||
cli.createWallet(walletName, copayerName, mn[0], mn[1], function(err, secret) { |
|||
common.die(err); |
|||
console.log(' * Wallet Created.'); |
|||
console.log(' - Secret to share:\n\t' + secret); |
|||
}); |
|||
|
@ -0,0 +1,10 @@ |
|||
#!/usr/bin/env node
|
|||
|
|||
var program = require('commander'); |
|||
var cli = require('../lib/clilib.js'); |
|||
|
|||
program |
|||
.version('0.0.1') |
|||
.parse(process.argv); |
|||
|
|||
|
@ -0,0 +1,26 @@ |
|||
#!/usr/bin/env node |
|||
|
|||
var program = require('commander'); |
|||
var cli = require('../lib/clilib.js'); |
|||
var common = require('./common'); |
|||
|
|||
program |
|||
.version('0.0.1') |
|||
.option('-c,--config [file]', 'Wallet config filename') |
|||
.usage('[options] <secret> [copayerName]') |
|||
.parse(process.argv); |
|||
|
|||
var args = program.args; |
|||
if (!args[0]) |
|||
program.help(); |
|||
|
|||
var secret = args[0]; |
|||
var copayerName = args[1] || process.env.USER; |
|||
|
|||
cli.setFilename(program.config); |
|||
|
|||
cli.joinWallet(secret, copayerName, function(err, xx) { |
|||
common.die(err); |
|||
console.log(' * Wallet Joined.', xx); |
|||
}); |
|||
|
@ -0,0 +1,20 @@ |
|||
#!/usr/bin/env node |
|||
|
|||
var program = require('commander'); |
|||
var cli = require('../lib/clilib.js'); |
|||
var common = require('./common'); |
|||
|
|||
program |
|||
.version('0.0.1') |
|||
.option('-c,--config [file]', 'Wallet config filename') |
|||
.parse(process.argv); |
|||
|
|||
var args = program.args; |
|||
|
|||
cli.setFilename(program.config); |
|||
|
|||
cli.status(function(err, xx) { |
|||
common.die(err); |
|||
console.log(' * Status:', xx); |
|||
}); |
|||
|
@ -0,0 +1,27 @@ |
|||
var common = function() {}; |
|||
|
|||
|
|||
var die = common.die = function(err) { |
|||
if (err) { |
|||
console.error(err); |
|||
process.exit(1); |
|||
} |
|||
}; |
|||
|
|||
common.parseMN = function(MN) { |
|||
if (!MN) |
|||
die('No m-n parameter'); |
|||
var mn = MN.split('-'); |
|||
|
|||
var m = parseInt(mn[0]); |
|||
var n = parseInt(mn[1]); |
|||
|
|||
if (!m || ! n) { |
|||
die('Bad m-n parameter'); |
|||
} |
|||
|
|||
return [m, n]; |
|||
}; |
|||
|
|||
|
|||
module.exports = common; |
Loading…
Reference in new issue