mirror of https://github.com/BTCPrivate/copay.git
better arg parsing
This commit is contained in:
parent
7453042ccd
commit
e01cf88a90
|
@ -22,12 +22,10 @@ program
|
||||||
.option('-d, --destination <n>', 'Destination Address')
|
.option('-d, --destination <n>', 'Destination Address')
|
||||||
.option('-n, --required <n>', 'Required number of signatures', parseInt)
|
.option('-n, --required <n>', 'Required number of signatures', parseInt)
|
||||||
.option('-k, --keys <items>', 'master private keys', list)
|
.option('-k, --keys <items>', 'master private keys', list)
|
||||||
.option('-a, --amount <n>', 'Optional, amount to transfer, in Satoshis', parseInt)
|
.option('-a, --amount <n>', 'Optional, amount to transfer, in Satoshis. If not provided, will wipe all funds', parseInt)
|
||||||
.option('-f, --fee [n]', 'Optional, fee in BTC (default 0.0001 BTC)', parseFloat)
|
.option('-f, --fee [n]', 'Optional, fee in BTC (default 0.0001 BTC), only if amount is not provided', parseFloat)
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
// Fee to asign to the tx. Please put a bigger number if you get 'unsufficient unspent'
|
|
||||||
var fee = parseFloat(program.fee) || 0.0001;
|
|
||||||
|
|
||||||
var rl = readline.createInterface({
|
var rl = readline.createInterface({
|
||||||
input: process.stdin,
|
input: process.stdin,
|
||||||
|
@ -40,11 +38,19 @@ var extPrivKeys = program.keys;
|
||||||
var destAddr = program.destination;
|
var destAddr = program.destination;
|
||||||
var amount = program.amount;
|
var amount = program.amount;
|
||||||
|
|
||||||
|
if (amount && program.fee) {
|
||||||
|
console.log('If amount if given, fee will be automatically calculated');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if (!requiredCopayers || !extPrivKeys || !extPrivKeys.length || !destAddr){
|
if (!requiredCopayers || !extPrivKeys || !extPrivKeys.length || !destAddr){
|
||||||
program.outputHelp();
|
program.outputHelp();
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fee to asign to the tx. Please put a bigger number if you get 'unsufficient unspent'
|
||||||
|
var fee = program.fee || 0.0001;
|
||||||
|
|
||||||
|
|
||||||
var totalCopayers = extPrivKeys.length;
|
var totalCopayers = extPrivKeys.length;
|
||||||
var addr = new bitcore.Address(destAddr);
|
var addr = new bitcore.Address(destAddr);
|
||||||
|
|
Loading…
Reference in New Issue