check aliases versus stored value

This commit is contained in:
thomasv 2012-02-03 16:39:27 +01:00
parent 0b1e56f51a
commit 8de53f7f45
2 changed files with 28 additions and 1 deletions

View File

@ -592,7 +592,10 @@ class BitcoinGUI:
old_r = r
r = r.strip()
if re.match('^(|([\w\-\.]+)@)((\w[\w\-]+\.)+[\w\-]+)$', r):
to_address = self.wallet.get_alias(r)
try:
to_address = self.wallet.get_alias(r)
except:
continue
if to_address:
s = r + ' <' + to_address + '>'
gobject.idle_add( lambda: self.payto_entry.set_text(s) )
@ -780,6 +783,9 @@ class BitcoinGUI:
if signature:
try:
signing_address = self.wallet.get_alias(identity)
except:
self.show_message('Warning: the key of the recipient has changed since last visit.\nContinue at your own risks!')
try:
self.wallet.verify_message(signing_address, signature, cmd )
except:
self.show_message('Warning: the URI contains a bad signature.\nThe identity of the recipient cannot be verified.\nContinue at your own risks!')
@ -821,6 +827,15 @@ class BitcoinGUI:
payto_entry, label_entry, amount_entry, fee_entry = data
label = label_entry.get_text()
r = payto_entry.get_text()
r = r.strip()
if re.match('^(|([\w\-\.]+)@)((\w[\w\-]+\.)+[\w\-]+)$', r):
try:
to_address = self.wallet.get_alias(r)
except:
self.show_message('Warning: the key of the recipient has changed since last visit.')
return
m = re.match('(|([\w\-\.]+)@)((\w[\w\-]+\.)+[\w\-]+) \<([1-9A-HJ-NP-Za-km-z]{26,})\>', r)
if m:
to_address = m.group(5)

View File

@ -237,6 +237,7 @@ class Wallet:
self.status = {} # current status of addresses
self.history = {}
self.labels = {} # labels for addresses and transactions
self.aliases = {} # aliases for addresses
self.addressbook = [] # outgoing addresses, for payments
# not saved
@ -475,6 +476,7 @@ class Wallet:
'labels':self.labels,
'contacts':self.addressbook,
'imported_keys':self.imported_keys,
'aliases':self.aliases,
}
f = open(self.path,"w")
f.write( repr(s) )
@ -505,6 +507,7 @@ class Wallet:
self.labels = d.get('labels')
self.addressbook = d.get('contacts')
self.imported_keys = d.get('imported_keys',{})
self.aliases = d.get('aliases',{})
except:
raise BaseException(upgrade_msg)
@ -725,4 +728,13 @@ class Wallet:
return ''
if not self.is_valid(xx):
return ''
self.labels[xx] = x
s = self.aliases.get(x)
if s:
if s != xx:
raise BaseException("error:alias does not match previous value")
else:
self.aliases[x] = xx
return xx