URI: 
       tadd getaddressbalance command, and use getbalance only for accounts - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit dcd73df929f0d0d238c4a0a90afcf2dbdf19a21a
   DIR parent 921d60468c32119217fd3347c9322a328b06cdcd
  HTML Author: thomasv <thomasv@gitorious>
       Date:   Tue, 16 Apr 2013 16:05:45 +0200
       
       add getaddressbalance command, and use getbalance only for accounts
       
       Diffstat:
         M lib/commands.py                     |      22 ++++++++++++----------
       
       1 file changed, 12 insertions(+), 10 deletions(-)
       ---
   DIR diff --git a/lib/commands.py b/lib/commands.py
       t@@ -49,8 +49,9 @@ register_command('dumpprivkey',          1, 1, True,  True,  'similar to bitcoin
        register_command('dumpprivkeys',         0, 0, True,  True,  'dump all private keys')
        register_command('eval',                 1, 1, False, True,  'Run python eval() on an object', 'eval <expression>\nExample: eval \"wallet.aliases\"')
        register_command('freeze',               1, 1, False, True,  'Freeze the funds at one of your wallet\'s addresses')
       -register_command('getbalance',           0, 1, False, False, 'Display the balance of your wallet or of an address', 'getbalance [<address>]')
       -register_command('getaddresshistory',    1, 1, False, False, 'get history for an address')
       +register_command('getbalance',           0, 1, False, False, 'Return the balance of your wallet, or of one account in your wallet', 'getbalance [<account>]')
       +register_command('getaddressbalance',    0, 1, False, False, 'Return the balance of an address', 'getbalance <address>')
       +register_command('getaddresshistory',    1, 1, False, False, 'Return the transaction history of an address')
        register_command('getconfig',            1, 1, False, True,  'Return a configuration variable', 'getconfig <name>')
        register_command('getseed',              0, 0, True,  True,  'Print the generation seed of your wallet.')
        register_command('help',                 0, 1, False, True,  'Prints this help')
       t@@ -164,17 +165,18 @@ class Commands:
                    
                return out
        
       -        
       -    def getbalance(self, addresses = []):
       -        if addresses == []:
       +    def getbalance(self, account= None):
       +        if account is None:
                    c, u = self.wallet.get_balance()
                else:
       -            c = u = 0
       -            for addr in addresses:
       -                cc, uu = self.wallet.get_addr_balance(addr)
       -                c += cc
       -                u += uu
       +            c, u = self.wallet.get_account_balance(account)
       +
       +        out = { "confirmed": str(Decimal(c)/100000000) }
       +        if u: out["unconfirmed"] = str(Decimal(u)/100000000)
       +        return out
        
       +    def getaddressbalance(self, addr):
       +        c, u = self.wallet.get_addr_balance(addr)
                out = { "confirmed": str(Decimal(c)/100000000) }
                if u: out["unconfirmed"] = str(Decimal(u)/100000000)
                return out