2020
2121if TYPE_CHECKING :
2222 from .main_window import ElectrumWindow
23+ from electrum .wallet import Request
2324
2425
2526class ReceiveTab (QWidget , MessageBoxMixin , Logger ):
@@ -101,6 +102,9 @@ def __init__(self, window: 'ElectrumWindow'):
101102 self .receive_zeroconf_button = QPushButton (_ ('Accept' ))
102103 self .receive_zeroconf_button .clicked .connect (self .on_accept_zeroconf )
103104
105+ self .previous_request = None # type: Optional['Request']
106+ self .confirmed_zeroconf_for_this_request = False # type: bool
107+
104108 def on_receive_rebalance ():
105109 if self .receive_rebalance_button .suggestion :
106110 chan1 , chan2 , delta = self .receive_rebalance_button .suggestion
@@ -221,14 +225,17 @@ def toggle_receive_qr(self):
221225
222226 def update_receive_widgets (self ):
223227 b = self .config .GUI_QT_RECEIVE_TAB_QR_VISIBLE
224- self .receive_widget .update_visibility (b )
228+ self .receive_widget .update_visibility (b , bool ( self . receive_help_text . text ()) )
225229
226230 def update_current_request (self ):
227231 if len (self .request_list .selectionModel ().selectedRows (0 )) > 1 :
228232 key = None
229233 else :
230234 key = self .request_list .get_current_key ()
231235 req = self .wallet .get_request (key ) if key else None
236+ if req != self .previous_request :
237+ self .previous_request = req
238+ self .confirmed_zeroconf_for_this_request = False
232239 if req is None :
233240 self .receive_e .setText ('' )
234241 self .addr = self .URI = self .lnaddr = ''
@@ -243,7 +250,7 @@ def update_current_request(self):
243250 self .ln_help = help_texts .ln_help
244251 can_rebalance = help_texts .can_rebalance ()
245252 can_swap = help_texts .can_swap ()
246- can_zeroconf = help_texts .can_zeroconf ()
253+ can_zeroconf = help_texts .can_zeroconf () if not self . confirmed_zeroconf_for_this_request else False
247254 self .receive_rebalance_button .suggestion = help_texts .ln_rebalance_suggestion
248255 self .receive_swap_button .suggestion = help_texts .ln_swap_suggestion
249256 self .receive_rebalance_button .setVisible (can_rebalance )
@@ -253,25 +260,26 @@ def update_current_request(self):
253260 self .receive_zeroconf_button .setVisible (can_zeroconf )
254261 self .receive_zeroconf_button .setEnabled (can_zeroconf )
255262 text , data , help_text , title = self .get_tab_data ()
263+ if self .confirmed_zeroconf_for_this_request and help_texts .can_zeroconf ():
264+ help_text = ''
265+ # set help before receive_e so we don't flicker from qr to help
266+ self .receive_help_text .setText (help_text )
256267 self .receive_e .setText (text )
257268 self .receive_qr .setData (data )
258- self .receive_help_text .setText (help_text )
259269 for w in [self .receive_e , self .receive_qr ]:
260270 w .setEnabled (bool (text ) and (not help_text or can_zeroconf ))
261271 w .setToolTip (help_text )
262272 # macOS hack (similar to #4777)
263273 self .receive_e .repaint ()
264274 # always show
265- if can_zeroconf :
266- # show the help message if zeroconf so user can first accept it and still sees the invoice
267- # after accepting
268- self .receive_widget .show_help ()
269275 self .receive_widget .setVisible (True )
270276 self .toggle_qr_button .setEnabled (True )
271277 self .update_receive_qr_window ()
272278
273279 def on_accept_zeroconf (self ):
274280 self .receive_zeroconf_button .setVisible (False )
281+ self .confirmed_zeroconf_for_this_request = True
282+ self .receive_help_text .setText ('' )
275283 self .update_receive_widgets ()
276284
277285 def get_tab_data (self ):
@@ -386,8 +394,8 @@ def __init__(self, receive_tab: 'ReceiveTab', textedit: QWidget, qr: QWidget, he
386394
387395 self .setLayout (vbox )
388396
389- def update_visibility (self , is_qr ):
390- if str (self .textedit .toPlainText ()):
397+ def update_visibility (self , is_qr : bool , show_help : bool ):
398+ if str (self .textedit .toPlainText ()) and not show_help :
391399 self .help_widget .setVisible (False )
392400 self .textedit .setVisible (not is_qr )
393401 self .qr .setVisible (is_qr )
0 commit comments