commit da4b974dfd1a902e862becf86375227fc41d770f
parent 486ebf93e2eb3b9a1fc514696636bb31f73cb10c
Author: thomasv <thomasv@gitorious>
Date: Tue, 16 Oct 2012 09:24:38 +0200
simplification: hex encode master_public_key directly
Diffstat:
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/lib/gui_lite.py b/lib/gui_lite.py
@@ -749,7 +749,7 @@ class MiniActuator:
return self.wallet.is_valid(address)
def acceptbit(self, currency):
- master_pubkey = self.wallet.master_public_key.encode("hex")
+ master_pubkey = self.wallet.master_public_key
url = "http://acceptbit.com/mpk/%s/%s" % (master_pubkey, currency)
webbrowser.open(url)
diff --git a/lib/wallet.py b/lib/wallet.py
@@ -270,7 +270,7 @@ class Wallet:
self.use_change = config.get('use_change',True)
self.fee = int(config.get('fee',100000))
self.num_zeros = int(config.get('num_zeros',0))
- self.master_public_key = config.get('master_public_key','').decode('hex')
+ self.master_public_key = config.get('master_public_key','')
self.use_encryption = config.get('use_encryption', False)
self.addresses = config.get('addresses', []) # receiving addresses visible for user
self.change_addresses = config.get('change_addresses', []) # addresses used as change
@@ -347,7 +347,7 @@ class Wallet:
curve = SECP256k1
secexp = self.stretch_key(seed)
master_private_key = ecdsa.SigningKey.from_secret_exponent( secexp, curve = SECP256k1 )
- self.master_public_key = master_private_key.get_verifying_key().to_string()
+ self.master_public_key = master_private_key.get_verifying_key().to_string().encode('hex')
def all_addresses(self):
return self.addresses + self.change_addresses + self.imported_keys.keys()
@@ -374,7 +374,7 @@ class Wallet:
return string_to_number( seed )
def get_sequence(self,n,for_change):
- return string_to_number( Hash( "%d:%d:"%(n,for_change) + self.master_public_key ) )
+ return string_to_number( Hash( "%d:%d:"%(n,for_change) + self.master_public_key.decode('hex') ) )
def get_private_key_base58(self, address, password):
pk = self.get_private_key(address, password)
@@ -488,7 +488,7 @@ class Wallet:
""" Publickey(type,n) = Master_public_key + H(n|S|type)*point """
curve = SECP256k1
z = self.get_sequence(n, for_change)
- master_public_key = ecdsa.VerifyingKey.from_string( self.master_public_key, curve = SECP256k1 )
+ master_public_key = ecdsa.VerifyingKey.from_string( self.master_public_key.decode('hex'), curve = SECP256k1 )
pubkey_point = master_public_key.pubkey.point + z*curve.generator
public_key2 = ecdsa.VerifyingKey.from_public_point( pubkey_point, curve = SECP256k1 )
address = public_key_to_bc_address( '04'.decode('hex') + public_key2.to_string() )
@@ -1009,7 +1009,7 @@ class Wallet:
'seed_version': self.seed_version,
'use_encryption': self.use_encryption,
'use_change': self.use_change,
- 'master_public_key': self.master_public_key.encode('hex'),
+ 'master_public_key': self.master_public_key,
'fee': self.fee,
'seed': self.seed,
'addresses': self.addresses,
diff --git a/scripts/merchant.py b/scripts/merchant.py
@@ -33,7 +33,6 @@ db_password = config.get('db','password')
db_name = config.get('db','name')
electrum_server = config.get('electrum','server')
-mpk = config.get('electrum','mpk')
my_password = config.get('main','password')
my_host = config.get('main','host')
@@ -44,7 +43,7 @@ cb_expired = config.get('callback','expired')
cb_password = config.get('callback','password')
wallet = Wallet()
-wallet.master_public_key = mpk.decode('hex')
+wallet.master_public_key = config.get('electrum','mpk')
@@ -114,7 +113,7 @@ def process_request(i, amount, confirmations, expires_in, password):
return addr
def get_mpk():
- return wallet.master_public_key.encode('hex')
+ return wallet.master_public_key
def server_thread(conn):