Browse Source

qt receive tab: "receive address" is now coloured red if already used

closes #3812
closes #5374
regtest_lnd
SomberNight 6 years ago
parent
commit
41802d8094
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 11
      electrum/gui/qt/main_window.py
  2. 3
      electrum/gui/qt/request_list.py

11
electrum/gui/qt/main_window.py

@ -907,6 +907,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
msg = _('Bitcoin address where the payment should be received. Note that each payment request uses a different Bitcoin address.')
self.receive_address_label = HelpLabel(_('Receiving address'), msg)
self.receive_address_e.textChanged.connect(self.update_receive_qr)
self.receive_address_e.textChanged.connect(self.update_receive_address_styling)
self.receive_address_e.setFocusPolicy(Qt.ClickFocus)
grid.addWidget(self.receive_address_label, 0, 0)
grid.addWidget(self.receive_address_e, 0, 1, 1, -1)
@ -1152,6 +1153,16 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
if self.qr_window and self.qr_window.isVisible():
self.qr_window.qrw.setData(uri)
def update_receive_address_styling(self):
addr = str(self.receive_address_e.text())
if self.wallet.is_used(addr):
self.receive_address_e.setStyleSheet(ColorScheme.RED.as_stylesheet(True))
self.receive_address_e.setToolTip(_("This address has already been used. "
"For better privacy, do not reuse it for new payments."))
else:
self.receive_address_e.setStyleSheet("")
self.receive_address_e.setToolTip("")
def set_feerounding_text(self, num_satoshis_added):
self.feerounding_text = (_('Additional {} satoshis are going to be added.')
.format(num_satoshis_added))

3
electrum/gui/qt/request_list.py

@ -105,9 +105,10 @@ class RequestList(MyTreeView):
except InternalAddressCorruption as e:
self.parent.show_error(str(e))
addr = ''
if not current_address in domain and addr:
if current_address not in domain and addr:
self.parent.set_receive_address(addr)
self.parent.new_request_button.setEnabled(addr != current_address)
self.parent.update_receive_address_styling()
self.model().clear()
self.update_headers(self.__class__.headers)

Loading…
Cancel
Save