1
0

wallet: add get_label_for_address, and make get_label private

fixes https://github.com/spesmilo/electrum/issues/7919

In the past, when creating payment requests, we keyed them by on-chain address,
and set/saved the msg of the request as label for the address.
Many places in the code were calling wallet.get_label(addr) with the expectation that
relevant payment requests are found and their message/description (if any) is considered.

wallet.get_label(key) is now made private, and instead the explicit non-polymorphic
wallet.get_label_for_{address,rhash,txid} alternatives should be used.
This commit is contained in:
SomberNight
2022-08-09 17:13:44 +02:00
parent 9279463fae
commit 7b095158bf
13 changed files with 35 additions and 19 deletions

View File

@@ -310,7 +310,7 @@ class ElectrumGui(BaseElectrumGui, EventListener):
fmt = self.format_column_width(x, [-50, '*', 15])
messages = [ fmt % (
addr,
self.wallet.get_label(addr),
self.wallet.get_label_for_address(addr),
self.config.format_amount(sum(self.wallet.get_addr_balance(addr)), whitespaces=True)
) for addr in self.wallet.get_addresses() ]
self.print_list(2, x, messages, fmt % ("Address", "Description", "Balance"))
@@ -321,7 +321,7 @@ class ElectrumGui(BaseElectrumGui, EventListener):
utxos = self.wallet.get_utxos()
messages = [ fmt % (
utxo.prevout.to_str(),
self.wallet.get_label(utxo.prevout.txid.hex()),
self.wallet.get_label_for_txid(utxo.prevout.txid.hex()),
self.config.format_amount(utxo.value_sats(), whitespaces=True)
) for utxo in utxos]
self.print_list(2, x, sorted(messages), fmt % ("Outpoint", "Description", "Balance"))