commit 5af71395988bdda1d063559c7b961631218534f9
parent 7f7aa97e2ee56911d8fc518ec2635e026e09f507
Author: ThomasV <thomasv@electrum.org>
Date: Wed, 8 Jun 2016 12:55:42 +0200
kivy: handle 'verified' event
Diffstat:
4 files changed, 18 insertions(+), 46 deletions(-)
diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py
@@ -214,8 +214,6 @@ class ElectrumWindow(App):
Clock.create_trigger(self.update_wallet, .5)
self._trigger_update_status =\
Clock.create_trigger(self.update_status, .5)
- self._trigger_notify_transactions = \
- Clock.create_trigger(self.notify_transactions, 5)
# cached dialogs
self._settings_dialog = None
self._password_dialog = None
@@ -512,7 +510,7 @@ class ElectrumWindow(App):
# connect callbacks
if self.network:
- interests = ['updated', 'status', 'new_transaction']
+ interests = ['updated', 'status', 'new_transaction', 'verified']
self.network.register_callback(self.on_network, interests)
#self.wallet = None
@@ -524,7 +522,9 @@ class ElectrumWindow(App):
elif event == 'status':
self._trigger_update_status()
elif event == 'new_transaction':
- self._trigger_notify_transactions(*args)
+ self._trigger_update_wallet()
+ elif event == 'verified':
+ self._trigger_update_wallet()
@profiler
def load_wallet(self, wallet):
@@ -538,7 +538,6 @@ class ElectrumWindow(App):
if self.receive_screen:
self.receive_screen.clear()
self.update_tabs()
- self.notify_transactions()
run_hook('load_wallet', wallet, self)
def update_status(self, *dt):
@@ -579,41 +578,6 @@ class ElectrumWindow(App):
if self.wallet and (self.wallet.up_to_date or not self.network or not self.network.is_connected()):
self.update_tabs()
- @profiler
- def notify_transactions(self, *dt):
- if not self.network or not self.network.is_connected():
- return
- # temporarily disabled for merge
- return
- iface = self.network
- ptfn = iface.pending_transactions_for_notifications
- if len(ptfn) > 0:
- # Combine the transactions if there are more then three
- tx_amount = len(ptfn)
- if(tx_amount >= 3):
- total_amount = 0
- for tx in ptfn:
- is_relevant, is_mine, v, fee = self.wallet.get_tx_value(tx)
- if(v > 0):
- total_amount += v
- self.notify(_("{txs}s new transactions received. Total amount"
- "received in the new transactions {amount}s"
- "{unit}s").format(txs=tx_amount,
- amount=self.format_amount(total_amount),
- unit=self.base_unit()))
-
- iface.pending_transactions_for_notifications = []
- else:
- for tx in iface.pending_transactions_for_notifications:
- if tx:
- iface.pending_transactions_for_notifications.remove(tx)
- is_relevant, is_mine, v, fee = self.wallet.get_tx_value(tx)
- if(v > 0):
- self.notify(
- _("{txs} new transaction received. {amount} {unit}").
- format(txs=tx_amount, amount=self.format_amount(v),
- unit=self.base_unit))
-
def notify(self, message):
try:
global notification, os
diff --git a/gui/kivy/uix/dialogs/tx_dialog.py b/gui/kivy/uix/dialogs/tx_dialog.py
@@ -17,6 +17,7 @@ Builder.load_string('''
is_mine: True
can_sign: False
can_broadcast: False
+ can_rbf: False
fee_str: ''
date_str: ''
amount_str: ''
@@ -73,12 +74,13 @@ Builder.load_string('''
Button:
size_hint: 0.5, None
height: '48dp'
- text: _('Sign') if root.can_sign else _('Broadcast') if root.can_broadcast else ''
- opacity: 1 if root.can_sign or root.can_broadcast else 0
- disabled: not( root.can_sign or root.can_broadcast )
+ text: _('Sign') if root.can_sign else _('Broadcast') if root.can_broadcast else _('Bump fee') if root.can_rbf else ''
+ disabled: not(root.can_sign or root.can_broadcast or root.can_rbf)
+ opacity: 0 if self.disabled else 1
on_release:
if root.can_sign: root.do_sign()
if root.can_broadcast: root.do_broadcast()
+ if root.can_rbf: root.do_rbf()
IconButton:
size_hint: 0.5, None
height: '48dp'
@@ -105,7 +107,7 @@ class TxDialog(Factory.Popup):
def update(self):
format_amount = self.app.format_amount_and_units
- self.tx_hash, self.status_str, self.description, self.can_broadcast, amount, fee, height, conf, timestamp, exp_n = self.wallet.get_tx_info(self.tx)
+ self.tx_hash, self.status_str, self.description, self.can_broadcast, self.can_rbf, amount, fee, height, conf, timestamp, exp_n = self.wallet.get_tx_info(self.tx)
if timestamp:
self.date_str = datetime.fromtimestamp(timestamp).isoformat(' ')[:-3]
elif exp_n:
@@ -125,6 +127,10 @@ class TxDialog(Factory.Popup):
self.can_sign = self.wallet.can_sign(self.tx)
self.ids.output_list.update(self.tx.outputs())
+ def do_rbf(self):
+ # not implemented
+ pass
+
def do_sign(self):
self.app.protected(_("Enter your PIN code in order to sign this transaction"), self._do_sign, ())
diff --git a/gui/qt/transaction_dialog.py b/gui/qt/transaction_dialog.py
@@ -178,7 +178,7 @@ class TxDialog(QDialog, MessageBoxMixin):
desc = self.desc
base_unit = self.main_window.base_unit()
format_amount = self.main_window.format_amount
- tx_hash, status, label, can_broadcast, amount, fee, height, conf, timestamp, exp_n = self.wallet.get_tx_info(self.tx)
+ tx_hash, status, label, can_broadcast, can_rbf, amount, fee, height, conf, timestamp, exp_n = self.wallet.get_tx_info(self.tx)
if can_broadcast:
self.broadcast_button.show()
diff --git a/lib/wallet.py b/lib/wallet.py
@@ -643,7 +643,9 @@ class Abstract_Wallet(PrintError):
else:
amount = None
- return tx_hash, status, label, can_broadcast, amount, fee, height, conf, timestamp, exp_n
+ can_rbf = is_mine and height <=0 and not tx.is_final()
+
+ return tx_hash, status, label, can_broadcast, can_rbf, amount, fee, height, conf, timestamp, exp_n
def get_addr_io(self, address):