tgetpubkeys command - electrum - Electrum Bitcoin wallet
 (HTM) git clone https://git.parazyd.org/electrum
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
       ---
 (DIR) commit 6f2471b69bbc670e11376a27460ac122c47302f5
 (DIR) parent 2f66cdf908caaf2563fd53a5d10eb7076ead7c77
 (HTM) Author: ThomasV <thomasv@gitorious>
       Date:   Thu,  3 Oct 2013 13:31:59 +0200
       
       getpubkeys command
       
       Diffstat:
         M electrum                            |       4 ++--
         M lib/account.py                      |       8 ++++++++
         M lib/commands.py                     |      33 ++++++++++++++++++-------------
         M lib/wallet.py                       |       4 ----
       
       4 files changed, 29 insertions(+), 20 deletions(-)
       ---
 (DIR) diff --git a/electrum b/electrum
       t@@ -320,12 +320,12 @@ if __name__ == '__main__':
            # check the number of arguments
            if len(args) - 1 < cmd.min_args:
                print_msg("Not enough arguments")
       -        print_msg("Syntax:", syntax)
       +        print_msg("Syntax:", cmd.syntax)
                sys.exit(1)
        
            if cmd.max_args >= 0 and len(args) - 1 > cmd.max_args:
                print_msg("too many arguments", args)
       -        print_msg("Syntax:", syntax)
       +        print_msg("Syntax:", cmd.syntax)
                sys.exit(1)
        
            if cmd.max_args < 0:
 (DIR) diff --git a/lib/account.py b/lib/account.py
       t@@ -42,6 +42,8 @@ class Account(object):
            def get_address(self, for_change, n):
                pass
                
       +    def get_pubkeys(self, sequence):
       +        return [ self.get_pubkey( *sequence )]
        
        
        
       t@@ -182,6 +184,8 @@ class BIP32_Account_2of2(BIP32_Account):
                address = hash_160_to_bc_address(hash_160(self.redeem_script((for_change, n)).decode('hex')), 5)
                return address
        
       +    def get_pubkeys(self, sequence):
       +        return [ self.get_pubkey( *sequence ), self.get_pubkey2( *sequence )]
        
        class BIP32_Account_2of3(BIP32_Account_2of2):
        
       t@@ -212,4 +216,8 @@ class BIP32_Account_2of3(BIP32_Account_2of2):
                pubkey3 = self.get_pubkey3(chain, i)
                return Transaction.multisig_script([pubkey1, pubkey2, pubkey3], 3)
        
       +    def get_pubkeys(self, sequence):
       +        return [ self.get_pubkey( *sequence ), self.get_pubkey2( *sequence ), self.get_pubkey3( *sequence )]
       +
       +
        
 (DIR) diff --git a/lib/commands.py b/lib/commands.py
       t@@ -69,8 +69,9 @@ register_command('freeze',               1, 1, False, True,  True,  'Freeze the 
        register_command('getbalance',           0, 1, True,  True,  False, 'Return the balance of your wallet, or of one account in your wallet', 'getbalance [<account>]')
        register_command('getservers',           0, 0, True,  False, False, 'Return the list of available servers')
        register_command('getaddressbalance',    1, 1, True,  True,  False, 'Return the balance of an address', 'getbalance <address>')
       -register_command('getaddresshistory',    1, 1, True,  False, False, 'Return the transaction history of an address', 'getaddresshistory <address>')
       +register_command('getaddresshistory',    1, 1, True,  True,  False, 'Return the transaction history of a wallet address', 'getaddresshistory <address>')
        register_command('getconfig',            1, 1, False, False, False, 'Return a configuration variable', 'getconfig <name>', config_options)
       +register_command('getpubkeys',           1, 1, False, True,  False, 'Return the public keys for a wallet address', 'getpubkeys <bitcoin address>')
        register_command('getrawtransaction',    1, 2, True,  False, False, 'Retrieve a transaction', 'getrawtransaction <txhash> <height>')
        register_command('getseed',              0, 0, False, True,  True,  'Print the generation seed of your wallet.')
        register_command('help',                 0, 1, False, False, False, 'Prints this help')
       t@@ -118,6 +119,7 @@ class Commands:
                return result
        
            def getaddresshistory(self, addr):
       +        assert self.wallet.is_mine(addr)
                h = self.wallet.get_history(addr)
                if h is None: h = self.network.synchronous_get([ ('blockchain.address.get_history',[addr]) ])[0]
                return h
       t@@ -177,17 +179,20 @@ class Commands:
                    addresses = self.wallet.addresses(True)
                return [self.wallet.get_private_key(address, self.password) for address in addresses]
        
       -    def validateaddress(self,addr):
       +    def validateaddress(self, addr):
                isvalid = is_valid(addr)
                out = { 'isvalid':isvalid }
                if isvalid:
       -            is_mine = self.wallet.is_mine(addr)
                    out['address'] = addr
       -            out['ismine'] = is_mine
       -            if is_mine:
       -                account, sequence = self.wallet.get_address_index(addr)
       -                if account != -1:
       -                    out['pubkey'] = self.wallet.get_public_key(addr)
       +
       +    def getpubkeys(self, addr):
       +        assert is_valid(addr) and self.wallet.is_mine(addr)
       +        out = { 'address':addr }
       +        account, sequence = self.wallet.get_address_index(addr)
       +        if account != -1:
       +            a = self.wallet.accounts[account]
       +            out['pubkeys'] = a.get_pubkeys( sequence )
       +
                return out
        
            def getbalance(self, account= None):
       t@@ -337,14 +342,14 @@ class Commands:
                        out.append( item )
                return out
                                 
       -    def help(self, cmd2=None):
       -        if cmd2 not in known_commands:
       +    def help(self, cmd=None):
       +        if cmd not in known_commands:
                    print_msg("\nList of commands:", ', '.join(sorted(known_commands)))
                else:
       -            _, _, description, syntax, options_syntax = known_commands[cmd2]
       -            print_msg(description)
       -            if syntax: print_msg("Syntax: " + syntax)
       -            if options_syntax: print_msg("options:\n" + options_syntax)
       +            cmd = known_commands[cmd]
       +            print_msg(cmd.description)
       +            if cmd.syntax: print_msg("Syntax: " + cmd.syntax)
       +            if cmd.options: print_msg("options:\n" + cmd.options)
                return None
        
            def getrawtransaction(self, tx_hash, height = 0):
 (DIR) diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -555,10 +555,6 @@ class Wallet:
                return '&'.join(dd)
        
        
       -    def get_public_key(self, address):
       -        account, sequence = self.get_address_index(address)
       -        return self.accounts[account].get_pubkey( *sequence )
       -
        
            def decode_seed(self, password):
                seed = pw_decode(self.seed, password)