SomberNight 8 years ago
parent
commit
a00439b6f8
  1. 3
      gui/qt/main_window.py
  2. 1
      lib/bitcoin.py
  3. 4
      lib/keystore.py
  4. 14
      lib/wallet.py

3
gui/qt/main_window.py

@ -1771,8 +1771,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
def remove_address(self, addr):
if self.question(_("Do you want to remove")+" %s "%addr +_("from your wallet?")):
self.wallet.delete_address(addr)
self.address_list.update()
self.history_list.update()
self.need_update.set() # history, addresses, coins
self.clear_receive_tab()
def get_coins(self):

1
lib/bitcoin.py

@ -465,6 +465,7 @@ def DecodeBase58Check(psz):
# backwards compat
# extended WIF for segwit (used in 3.0.x; but still used internally)
# the keys in this dict should be a superset of what Imported Wallets can import
SCRIPT_TYPES = {
'p2pkh':0,
'p2wpkh':1,

4
lib/keystore.py

@ -143,6 +143,10 @@ class Imported_KeyStore(Software_KeyStore):
# re-serialize the key so the internal storage format is consistent
serialized_privkey = serialize_privkey(
privkey, compressed, txin_type, internal_use=True)
# NOTE: if the same pubkey is reused for multiple addresses (script types),
# there will only be one pubkey-privkey pair for it in self.keypairs,
# and the privkey will encode a txin_type but that txin_type can not be trusted.
# Removing keys complicates this further.
self.keypairs[pubkey] = pw_encode(serialized_privkey, password)
return txin_type, pubkey

14
lib/wallet.py

@ -1929,8 +1929,18 @@ class Imported_Wallet(Simple_Wallet):
pubkey = self.get_public_key(address)
self.addresses.pop(address)
if pubkey:
self.keystore.delete_imported_key(pubkey)
self.save_keystore()
# delete key iff no other address uses it (e.g. p2pkh and p2wpkh for same key)
for txin_type in bitcoin.SCRIPT_TYPES.keys():
try:
addr2 = bitcoin.pubkey_to_address(txin_type, pubkey)
except NotImplementedError:
pass
else:
if addr2 in self.addresses:
break
else:
self.keystore.delete_imported_key(pubkey)
self.save_keystore()
self.storage.put('addresses', self.addresses)
self.storage.write()

Loading…
Cancel
Save