Skip to content

Commit

Permalink
Attempt to use empty imported addresses as change
Browse files Browse the repository at this point in the history
Previously when spending coins on imported-key wallets, the change address
would always be an address from one of the inputs. This address reuse is
pretty bad for privacy because it leaks which output is change.

This commit attempts to find unused imported addresses, and if there are any
then use them as change addresses.

The practical use-case I considered was the situation when using the Electrum
android app to do a cash-in-person trade. Some people might want to bring only
one of their UTXOs to the meetup for safety. This commit allows them to import
that one UTXO plus an unused change address, allowing them to create a
transaction without address reuse.
  • Loading branch information
chris-belcher committed Jun 1, 2021
1 parent cad4e77 commit 6054435
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion electrum/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2681,7 +2681,7 @@ def get_receiving_addresses(self, **kwargs):
return self.get_addresses()

def get_change_addresses(self, **kwargs):
return []
return [addr for addr in self.get_addresses() if len(self.db.get_addr_history(addr)) == 0]

def import_addresses(self, addresses: List[str], *,
write_to_disk=True) -> Tuple[List[str], List[Tuple[str, str]]]:
Expand Down

0 comments on commit 6054435

Please sign in to comment.