URI: 
       tread command line arguments from stdin if '-' is passed - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 02e81a365522912ee4766529677cc8b02ce45b0e
   DIR parent 5686499eae5d1c410371cf9cf5226cdb2d83774b
  HTML Author: ThomasV <thomasv@gitorious>
       Date:   Sun, 16 Aug 2015 16:11:52 +0200
       
       read command line arguments from stdin if '-' is passed
       
       Diffstat:
         M electrum                            |      37 ++++++++++++++++++++-----------
         M lib/commands.py                     |      17 ++++++++++-------
       
       2 files changed, 34 insertions(+), 20 deletions(-)
       ---
   DIR diff --git a/electrum b/electrum
       t@@ -80,14 +80,11 @@ from electrum.commands import get_parser, known_commands, Commands, config_varia
        # get password routine
        def prompt_password(prompt, confirm=True):
            import getpass
       -    if sys.stdin.isatty():
       -        password = getpass.getpass(prompt)
       -        if password and confirm:
       -            password2 = getpass.getpass("Confirm: ")
       -            if password != password2:
       -                sys.exit("Error: Passwords do not match.")
       -    else:
       -        password = raw_input(prompt)
       +    password = getpass.getpass(prompt)
       +    if password and confirm:
       +        password2 = getpass.getpass("Confirm: ")
       +        if password != password2:
       +            sys.exit("Error: Passwords do not match.")
            if not password:
                password = None
            return password
       t@@ -204,6 +201,20 @@ def run_cmdline(config):
            # options
            args += map(lambda x: config.get(x), cmd.options)
        
       +    # pipe data
       +    for i, arg in enumerate(args):
       +        if arg == '-':
       +            if not sys.stdin.isatty():
       +                pipe_data = sys.stdin.read()
       +                try:
       +                    pipe_data = json.loads(pipe_data)
       +                except:
       +                    pass
       +                args[i] = pipe_data
       +                break
       +            else:
       +                raise BaseException('Cannot get argument from stdin')
       +
            # instanciate wallet for command-line
            storage = WalletStorage(config.get_wallet_path())
        
       t@@ -272,14 +283,16 @@ def run_cmdline(config):
            always_hook('cmdline_load_wallet', wallet)
        
            # important warning
       -    if cmd.name in ['dumpprivkey', 'dumpprivkeys']:
       +    if cmd.name in ['getprivatekeys', 'dumpprivkeys']:
                print_stderr("WARNING: ALL your private keys are secret.")
                print_stderr("Exposing a single private key can compromise your entire wallet!")
                print_stderr("In particular, DO NOT use 'redeem private key' services proposed by third parties.")
        
            # commands needing password
       -    if cmd.requires_password:
       -        if wallet.use_encryption:
       +    if cmd.requires_password and wallet.use_encryption:
       +        if config.get('password'):
       +            password = config.get('password')
       +        else:
                    password = prompt_password('Password:', False)
                    if not password:
                        print_msg("Error: Password required")
       t@@ -290,8 +303,6 @@ def run_cmdline(config):
                    except InvalidPassword:
                        print_msg("Error: This password does not decode this wallet.")
                        sys.exit(1)
       -        else:
       -            password = None
            else:
                password = None
        
   DIR diff --git a/lib/commands.py b/lib/commands.py
       t@@ -239,8 +239,11 @@ class Commands:
        
            @command('wp')
            def getprivatekeys(self, address):
       -        """Get the private keys of an address. Address must be in wallet."""
       -        return self.wallet.get_private_key(address, self.password)
       +        """Get the private keys of a wallet address, or list of wallet addresses."""
       +        is_list = type(address) is list
       +        domain = address if is_list else [address]
       +        out = [self.wallet.get_private_key(address, self.password) for address in domain]
       +        return out if is_list else out[0]
        
            @command('w')
            def ismine(self, address):
       t@@ -248,10 +251,9 @@ class Commands:
                return self.wallet.is_mine(address)
        
            @command('wp')
       -    def dumpprivkeys(self, domain=None):
       +    def dumpprivkeys(self):
                """Dump private keys from your wallet"""
       -        if domain is None:
       -            domain = self.wallet.addresses(True)
       +        domain = self.wallet.addresses(True)
                return [self.wallet.get_private_key(address, self.password) for address in domain]
        
            @command('')
       t@@ -353,15 +355,16 @@ class Commands:
        
            @command('n')
            def sweep(self, privkey, destination, tx_fee=None, nocheck=False):
       -        """Sweep private key. Returns a transaction that spends UTXOs from
       +        """Sweep private keys. Returns a transaction that spends UTXOs from
                privkey to a destination address. The transaction is not
                broadcasted."""
       +        privkeys = privkey if type(privkey) is list else [privkey]
                self.nocheck = nocheck
                dest = self._resolver(destination)
                if tx_fee is None:
                    tx_fee = 0.0001
                fee = int(Decimal(tx_fee)*COIN)
       -        return Transaction.sweep([privkey], self.network, dest, fee)
       +        return Transaction.sweep(privkeys, self.network, dest, fee)
        
            @command('wp')
            def signmessage(self, address, message):