Browse Source

kivy: ask RBF before send

283
ThomasV 9 years ago
parent
commit
48d42bbafa
  1. 9
      gui/kivy/main_window.py
  2. 4
      gui/kivy/uix/dialogs/question.py
  3. 24
      gui/kivy/uix/screens.py

9
gui/kivy/main_window.py

@ -54,8 +54,6 @@ Cache.register('electrum_widgets', timeout=0)
from kivy.uix.screenmanager import Screen
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.uix.label import Label
from kivy.uix.checkbox import CheckBox
from kivy.uix.switch import Switch
from kivy.core.clipboard import Clipboard
Factory.register('TabbedCarousel', module='electrum_gui.kivy.uix.screens')
@ -762,9 +760,10 @@ class ElectrumWindow(App):
d = Question(_('Delete wallet?') + '\n' + basename, self._delete_wallet)
d.open()
def _delete_wallet(self):
basename = os.path.basename(self.wallet.storage.path)
self.protected(_("Enter your PIN code to confirm deletion of %s") % basename, self.__delete_wallet, ())
def _delete_wallet(self, b):
if b:
basename = os.path.basename(self.wallet.storage.path)
self.protected(_("Enter your PIN code to confirm deletion of %s") % basename, self.__delete_wallet, ())
def __delete_wallet(self, pw):
wallet_path = self.get_wallet_path()

4
gui/kivy/uix/dialogs/question.py

@ -20,6 +20,7 @@ Builder.load_string('''
Label:
id: label
text: root.message
text_size: self.width, None
Widget:
size_hint: 1, 0.1
BoxLayout:
@ -30,13 +31,14 @@ Builder.load_string('''
size_hint: 0.5, None
height: '48dp'
on_release:
root.callback(False)
popup.dismiss()
Button:
text: _('Yes')
size_hint: 0.5, None
height: '48dp'
on_release:
root.callback()
root.callback(True)
popup.dismiss()
''')

24
gui/kivy/uix/screens.py

@ -264,6 +264,14 @@ class SendScreen(CScreen):
outputs = [(bitcoin.TYPE_ADDRESS, address, amount)]
message = unicode(self.screen.message)
amount = sum(map(lambda x:x[2], outputs))
if self.app.electrum_config.get('use_rbf'):
from dialogs.question import Question
d = Question(_('Should this transaction be replaceable?'), lambda b: self._do_send(amount, message, outputs, b))
d.open()
else:
self._do_send(amount, message, outputs, False)
def _do_send(self, amount, message, outputs, rbf):
# make unsigned transaction
coins = self.app.wallet.get_spendable_coins()
config = self.app.electrum_config
@ -276,7 +284,7 @@ class SendScreen(CScreen):
traceback.print_exc(file=sys.stdout)
self.app.show_error(str(e))
return
if self.app.electrum_config.get('use_rbf'):
if rbf:
tx.set_sequence(0)
fee = tx.get_fee()
msg = [
@ -458,9 +466,10 @@ class InvoicesScreen(CScreen):
def do_delete(self, obj):
from dialogs.question import Question
def cb():
self.app.invoices.remove(obj.key)
self.app.update_tab('invoices')
def cb(result):
if result:
self.app.invoices.remove(obj.key)
self.app.update_tab('invoices')
d = Question(_('Delete invoice?'), cb)
d.open()
@ -527,9 +536,10 @@ class RequestsScreen(CScreen):
def do_delete(self, obj):
from dialogs.question import Question
def cb():
self.app.wallet.remove_payment_request(obj.address, self.app.electrum_config)
self.update()
def cb(result):
if result:
self.app.wallet.remove_payment_request(obj.address, self.app.electrum_config)
self.update()
d = Question(_('Delete request?'), cb)
d.open()

Loading…
Cancel
Save