bitcore-wallet-service/bit-wallet/bit-create

37 lines
1.0 KiB
JavaScript
Executable File

#!/usr/bin/env node
var _ = require('lodash');
var program = require('commander');
var ClientLib = require('../lib/client');
var utils = require('./cli-utils');
program = utils.configureCommander(program);
program
.option('-t, --testnet', 'Create a Testnet Wallet')
.option('-n, --nopasswd [level]', 'Set access for no password usage: none(default), readonly, readwrite, full', 'none')
.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 network = program.testnet ? 'testnet' : 'livenet';
var mn;
try {
mn = utils.parseMN(args[1]);
} catch (ex) {
utils.die(ex);
}
var client = utils.getClient(program);
client.createWallet(walletName, copayerName, mn[0], mn[1], network, function(err, secret) {
utils.die(err);
console.log(' * ' + _.capitalize(network) + ' Wallet Created.');
if (secret)
console.log(' - Secret to share:\n\t' + secret);
});