kivy: handle 'verified' event
This commit is contained in:
parent
7f7aa97e2e
commit
5af7139598
|
@ -214,8 +214,6 @@ class ElectrumWindow(App):
|
||||||
Clock.create_trigger(self.update_wallet, .5)
|
Clock.create_trigger(self.update_wallet, .5)
|
||||||
self._trigger_update_status =\
|
self._trigger_update_status =\
|
||||||
Clock.create_trigger(self.update_status, .5)
|
Clock.create_trigger(self.update_status, .5)
|
||||||
self._trigger_notify_transactions = \
|
|
||||||
Clock.create_trigger(self.notify_transactions, 5)
|
|
||||||
# cached dialogs
|
# cached dialogs
|
||||||
self._settings_dialog = None
|
self._settings_dialog = None
|
||||||
self._password_dialog = None
|
self._password_dialog = None
|
||||||
|
@ -512,7 +510,7 @@ class ElectrumWindow(App):
|
||||||
|
|
||||||
# connect callbacks
|
# connect callbacks
|
||||||
if self.network:
|
if self.network:
|
||||||
interests = ['updated', 'status', 'new_transaction']
|
interests = ['updated', 'status', 'new_transaction', 'verified']
|
||||||
self.network.register_callback(self.on_network, interests)
|
self.network.register_callback(self.on_network, interests)
|
||||||
|
|
||||||
#self.wallet = None
|
#self.wallet = None
|
||||||
|
@ -524,7 +522,9 @@ class ElectrumWindow(App):
|
||||||
elif event == 'status':
|
elif event == 'status':
|
||||||
self._trigger_update_status()
|
self._trigger_update_status()
|
||||||
elif event == 'new_transaction':
|
elif event == 'new_transaction':
|
||||||
self._trigger_notify_transactions(*args)
|
self._trigger_update_wallet()
|
||||||
|
elif event == 'verified':
|
||||||
|
self._trigger_update_wallet()
|
||||||
|
|
||||||
@profiler
|
@profiler
|
||||||
def load_wallet(self, wallet):
|
def load_wallet(self, wallet):
|
||||||
|
@ -538,7 +538,6 @@ class ElectrumWindow(App):
|
||||||
if self.receive_screen:
|
if self.receive_screen:
|
||||||
self.receive_screen.clear()
|
self.receive_screen.clear()
|
||||||
self.update_tabs()
|
self.update_tabs()
|
||||||
self.notify_transactions()
|
|
||||||
run_hook('load_wallet', wallet, self)
|
run_hook('load_wallet', wallet, self)
|
||||||
|
|
||||||
def update_status(self, *dt):
|
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()):
|
if self.wallet and (self.wallet.up_to_date or not self.network or not self.network.is_connected()):
|
||||||
self.update_tabs()
|
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):
|
def notify(self, message):
|
||||||
try:
|
try:
|
||||||
global notification, os
|
global notification, os
|
||||||
|
|
|
@ -17,6 +17,7 @@ Builder.load_string('''
|
||||||
is_mine: True
|
is_mine: True
|
||||||
can_sign: False
|
can_sign: False
|
||||||
can_broadcast: False
|
can_broadcast: False
|
||||||
|
can_rbf: False
|
||||||
fee_str: ''
|
fee_str: ''
|
||||||
date_str: ''
|
date_str: ''
|
||||||
amount_str: ''
|
amount_str: ''
|
||||||
|
@ -73,12 +74,13 @@ Builder.load_string('''
|
||||||
Button:
|
Button:
|
||||||
size_hint: 0.5, None
|
size_hint: 0.5, None
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
text: _('Sign') if root.can_sign else _('Broadcast') if root.can_broadcast else ''
|
text: _('Sign') if root.can_sign else _('Broadcast') if root.can_broadcast else _('Bump fee') if root.can_rbf else ''
|
||||||
opacity: 1 if root.can_sign or root.can_broadcast else 0
|
disabled: not(root.can_sign or root.can_broadcast or root.can_rbf)
|
||||||
disabled: not( root.can_sign or root.can_broadcast )
|
opacity: 0 if self.disabled else 1
|
||||||
on_release:
|
on_release:
|
||||||
if root.can_sign: root.do_sign()
|
if root.can_sign: root.do_sign()
|
||||||
if root.can_broadcast: root.do_broadcast()
|
if root.can_broadcast: root.do_broadcast()
|
||||||
|
if root.can_rbf: root.do_rbf()
|
||||||
IconButton:
|
IconButton:
|
||||||
size_hint: 0.5, None
|
size_hint: 0.5, None
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
|
@ -105,7 +107,7 @@ class TxDialog(Factory.Popup):
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
format_amount = self.app.format_amount_and_units
|
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:
|
if timestamp:
|
||||||
self.date_str = datetime.fromtimestamp(timestamp).isoformat(' ')[:-3]
|
self.date_str = datetime.fromtimestamp(timestamp).isoformat(' ')[:-3]
|
||||||
elif exp_n:
|
elif exp_n:
|
||||||
|
@ -125,6 +127,10 @@ class TxDialog(Factory.Popup):
|
||||||
self.can_sign = self.wallet.can_sign(self.tx)
|
self.can_sign = self.wallet.can_sign(self.tx)
|
||||||
self.ids.output_list.update(self.tx.outputs())
|
self.ids.output_list.update(self.tx.outputs())
|
||||||
|
|
||||||
|
def do_rbf(self):
|
||||||
|
# not implemented
|
||||||
|
pass
|
||||||
|
|
||||||
def do_sign(self):
|
def do_sign(self):
|
||||||
self.app.protected(_("Enter your PIN code in order to sign this transaction"), self._do_sign, ())
|
self.app.protected(_("Enter your PIN code in order to sign this transaction"), self._do_sign, ())
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ class TxDialog(QDialog, MessageBoxMixin):
|
||||||
desc = self.desc
|
desc = self.desc
|
||||||
base_unit = self.main_window.base_unit()
|
base_unit = self.main_window.base_unit()
|
||||||
format_amount = self.main_window.format_amount
|
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:
|
if can_broadcast:
|
||||||
self.broadcast_button.show()
|
self.broadcast_button.show()
|
||||||
|
|
|
@ -643,7 +643,9 @@ class Abstract_Wallet(PrintError):
|
||||||
else:
|
else:
|
||||||
amount = None
|
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):
|
def get_addr_io(self, address):
|
||||||
|
|
Loading…
Reference in New Issue