electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit e34f7dce7f1836b393b5a7f22ac78de71c2674e9
parent 04d78a3bf4d9ca8984ed8ff3a90b7d205953b91b
Author: ThomasV <thomasv@gitorious>
Date:   Mon, 14 May 2012 21:31:37 +0200

do not derive private keys when there is no seed

Diffstat:
Melectrum | 5++---
Mlib/__init__.py | 2+-
Mlib/wallet.py | 6++++++
3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/electrum b/electrum @@ -35,7 +35,7 @@ import electrum from optparse import OptionParser from decimal import Decimal -from electrum import Wallet, SecretToASecret, WalletSynchronizer, format_satoshis +from electrum import Wallet, WalletSynchronizer, format_satoshis known_commands = ['help', 'validateaddress', 'balance', 'contacts', 'create', 'restore', 'payto', 'sendtx', 'password', 'addresses', 'history', 'label', 'mktx','seed','import','signmessage','verifymessage','eval','deseed','reseed'] offline_commands = ['password', 'mktx', 'label', 'contacts', 'help', 'validateaddress', 'signmessage', 'verifymessage', 'eval', 'create', 'addresses', 'import', 'seed','deseed','reseed'] @@ -361,8 +361,7 @@ if __name__ == '__main__': b = "%d %d %s"%(no, ni, str(Decimal(wallet.get_addr_balance(addr)[0])/100000000)) else: b='' if options.show_keys: - pk = wallet.get_private_key(addr, password) - addr = addr + ':' + SecretToASecret(pk) + addr += ':' + str(wallet.get_private_key_base58(addr, password)) print addr, b, _type, label if cmd == 'history': diff --git a/lib/__init__.py b/lib/__init__.py @@ -1,3 +1,3 @@ -from wallet import Wallet, SecretToASecret, format_satoshis +from wallet import Wallet, format_satoshis from interface import WalletSynchronizer from interface import TcpStratumInterface diff --git a/lib/wallet.py b/lib/wallet.py @@ -371,6 +371,11 @@ class Wallet: def get_sequence(self,n,for_change): return string_to_number( Hash( "%d:%d:"%(n,for_change) + self.master_public_key ) ) + def get_private_key_base58(self, address, password): + pk = self.get_private_key(address, password) + if pk is None: return None + return SecretToASecret( pk ) + def get_private_key(self, address, password): """ Privatekey(type,n) = Master_private_key + H(n|S|type) """ order = generator_secp256k1.order() @@ -388,6 +393,7 @@ class Wallet: for_change = True else: raise BaseException("unknown address") + if not self.seed: return None try: seed = self.pw_decode( self.seed, password) except: