From e01cf88a90d536ad5031cc1ad396b8809f6a2d92 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 3 Nov 2014 09:55:44 -0300 Subject: [PATCH] better arg parsing --- util/swipeWallet.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/util/swipeWallet.js b/util/swipeWallet.js index 743904002..98237497b 100755 --- a/util/swipeWallet.js +++ b/util/swipeWallet.js @@ -22,12 +22,10 @@ program .option('-d, --destination ', 'Destination Address') .option('-n, --required ', 'Required number of signatures', parseInt) .option('-k, --keys ', 'master private keys', list) - .option('-a, --amount ', 'Optional, amount to transfer, in Satoshis', parseInt) - .option('-f, --fee [n]', 'Optional, fee in BTC (default 0.0001 BTC)', parseFloat) + .option('-a, --amount ', '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), only if amount is not provided', parseFloat) .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({ input: process.stdin, @@ -40,11 +38,19 @@ var extPrivKeys = program.keys; var destAddr = program.destination; 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){ program.outputHelp(); 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 addr = new bitcore.Address(destAddr);