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.screenmanager import Screen
from kivy.uix.tabbedpanel import TabbedPanel from kivy.uix.tabbedpanel import TabbedPanel
from kivy.uix.label import Label from kivy.uix.label import Label
from kivy.uix.checkbox import CheckBox
from kivy.uix.switch import Switch
from kivy.core.clipboard import Clipboard from kivy.core.clipboard import Clipboard
Factory.register('TabbedCarousel', module='electrum_gui.kivy.uix.screens') 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 = Question(_('Delete wallet?') + '\n' + basename, self._delete_wallet)
d.open() d.open()
def _delete_wallet(self): def _delete_wallet(self, b):
basename = os.path.basename(self.wallet.storage.path) if b:
self.protected(_("Enter your PIN code to confirm deletion of %s") % basename, self.__delete_wallet, ()) 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): def __delete_wallet(self, pw):
wallet_path = self.get_wallet_path() wallet_path = self.get_wallet_path()

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

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

24
gui/kivy/uix/screens.py

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

Loading…
Cancel
Save