fix #4158
This commit is contained in:
@@ -1771,8 +1771,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
|||||||
def remove_address(self, addr):
|
def remove_address(self, addr):
|
||||||
if self.question(_("Do you want to remove")+" %s "%addr +_("from your wallet?")):
|
if self.question(_("Do you want to remove")+" %s "%addr +_("from your wallet?")):
|
||||||
self.wallet.delete_address(addr)
|
self.wallet.delete_address(addr)
|
||||||
self.address_list.update()
|
self.need_update.set() # history, addresses, coins
|
||||||
self.history_list.update()
|
|
||||||
self.clear_receive_tab()
|
self.clear_receive_tab()
|
||||||
|
|
||||||
def get_coins(self):
|
def get_coins(self):
|
||||||
|
|||||||
@@ -465,6 +465,7 @@ def DecodeBase58Check(psz):
|
|||||||
|
|
||||||
# backwards compat
|
# backwards compat
|
||||||
# extended WIF for segwit (used in 3.0.x; but still used internally)
|
# 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 = {
|
SCRIPT_TYPES = {
|
||||||
'p2pkh':0,
|
'p2pkh':0,
|
||||||
'p2wpkh':1,
|
'p2wpkh':1,
|
||||||
|
|||||||
@@ -143,6 +143,10 @@ class Imported_KeyStore(Software_KeyStore):
|
|||||||
# re-serialize the key so the internal storage format is consistent
|
# re-serialize the key so the internal storage format is consistent
|
||||||
serialized_privkey = serialize_privkey(
|
serialized_privkey = serialize_privkey(
|
||||||
privkey, compressed, txin_type, internal_use=True)
|
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)
|
self.keypairs[pubkey] = pw_encode(serialized_privkey, password)
|
||||||
return txin_type, pubkey
|
return txin_type, pubkey
|
||||||
|
|
||||||
|
|||||||
@@ -1929,8 +1929,18 @@ class Imported_Wallet(Simple_Wallet):
|
|||||||
pubkey = self.get_public_key(address)
|
pubkey = self.get_public_key(address)
|
||||||
self.addresses.pop(address)
|
self.addresses.pop(address)
|
||||||
if pubkey:
|
if pubkey:
|
||||||
self.keystore.delete_imported_key(pubkey)
|
# delete key iff no other address uses it (e.g. p2pkh and p2wpkh for same key)
|
||||||
self.save_keystore()
|
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.put('addresses', self.addresses)
|
||||||
|
|
||||||
self.storage.write()
|
self.storage.write()
|
||||||
|
|||||||
Reference in New Issue
Block a user