electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit a9197236a2a63014555c755e62b7495c1b809446
parent 2453872a09722a48c0f8540a292e195177e95db6
Author: SomberNight <somber.night@protonmail.com>
Date:   Sun, 16 Sep 2018 02:48:13 +0200

change 'new_transaction' notification to include wallet

Diffstat:
Melectrum/gui/kivy/main_window.py | 4+++-
Melectrum/gui/qt/main_window.py | 17+++++++++--------
Melectrum/synchronizer.py | 2+-
3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py @@ -677,7 +677,9 @@ class ElectrumWindow(App): elif event == 'status': self._trigger_update_status() elif event == 'new_transaction': - self._trigger_update_wallet() + wallet, tx = args + if wallet == self.wallet: + self._trigger_update_wallet() elif event == 'verified': self._trigger_update_wallet() diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py @@ -300,9 +300,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.gui_object.network_updated_signal_obj.network_updated_signal \ .emit(event, args) elif event == 'new_transaction': - # FIXME maybe this event should also include which wallet - # the tx is for. now all wallets get this. - self.tx_notification_queue.put(args[0]) + wallet, tx = args + if wallet == self.wallet: + self.tx_notification_queue.put(tx) elif event in ['status', 'banner', 'verified', 'fee', 'fee_histogram']: # Handle in GUI thread self.network_signal.emit(event, args) @@ -589,12 +589,13 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): def notify_transactions(self): # note: during initial history sync for a wallet, many txns will be - # received multiple times. hence the "total amount received" will be - # a lot higher than should be. this is expected though not intended + # received multiple times. hence the "total amount received" can be + # a lot different than should be. this is expected though not intended if self.tx_notification_queue.qsize() == 0: return now = time.time() - if self.tx_notification_last_time + 5 > now: + rate_limit = 20 # seconds + if self.tx_notification_last_time + rate_limit > now: return self.tx_notification_last_time = now self.print_error("Notifying GUI about new transactions") @@ -609,14 +610,14 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): total_amount = 0 for tx in txns: is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(tx) - if v > 0: + if is_relevant: total_amount += v self.notify(_("{} new transactions received: Total amount received in the new transactions {}") .format(len(txns), self.format_amount_and_units(total_amount))) else: for tx in txns: is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(tx) - if v > 0: + if is_relevant: self.notify(_("New transaction received: {}").format(self.format_amount_and_units(v))) def notify(self, message): diff --git a/electrum/synchronizer.py b/electrum/synchronizer.py @@ -134,7 +134,7 @@ class Synchronizer(PrintError): self.print_error("received tx %s height: %d bytes: %d" % (tx_hash, tx_height, len(tx.raw))) # callbacks - self.wallet.network.trigger_callback('new_transaction', tx) + self.wallet.network.trigger_callback('new_transaction', self.wallet, tx) async def subscribe_to_address(self, addr): h = address_to_scripthash(addr)