electrum

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

commit fd0e5739e220f4d2731bfb2b82017248ec5f6732
parent e297bf81a2dfb5b15119c79557ba8b06b5aea283
Author: ThomasV <thomasv@electrum.org>
Date:   Thu, 18 Feb 2016 15:40:13 +0100

kivy: disable amount and description buttons if payment request is signed

Diffstat:
Mgui/kivy/main.kv | 9+++++----
Mgui/kivy/main_window.py | 3---
Mgui/kivy/uix/screens.py | 11+++++++----
Mgui/kivy/uix/ui_screens/send.kv | 5++++-
Mlib/paymentrequest.py | 6+++---
5 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/gui/kivy/main.kv b/gui/kivy/main.kv @@ -179,9 +179,9 @@ <SendReceiveBlueBottom@GridLayout> canvas.before: Color: - rgba: .238, .585, .878, 1 + #rgba: .238, .585, .878, 1 + rgba: 0.192, .498, 0.745, 1 BorderImage: - #border: 9, 9, 9, 9 source: 'atlas://gui/kivy/theming/light/card_bottom' size: self.size pos: self.pos @@ -221,7 +221,7 @@ pos: self.pos <BlueButton@Button>: - background_color: .238, .585, .878, 0 + background_color: 1, .585, .878, 0 halign: 'left' text_size: (self.width-10, None) size_hint: 0.5, None @@ -230,7 +230,8 @@ padding: '5dp', '5db' height: '40dp' text_color: self.foreground_color - foreground_color: 1, 0, 0, 1 + disabled_color: 1, 1, 1, 1 + foreground_color: 1, 1, 1, 1 canvas.before: Color: rgba: (0.9, .498, 0.745, 1) if self.state == 'down' else self.background_color diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py @@ -216,9 +216,6 @@ class ElectrumWindow(App): self._trigger_notify_transactions = \ Clock.create_trigger(self.notify_transactions, 5) - def do_pay(self, obj): - pr = self.invoices.get(obj.key) - self.on_pr(pr) def on_pr(self, pr): if pr.verify(self.contacts): diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py @@ -204,13 +204,16 @@ class SendScreen(CScreen): self.screen.message = '' self.screen.address = '' self.payment_request = None + self.screen.is_pr = False def set_request(self, pr): - self.payment_request = pr self.screen.address = pr.get_requestor() amount = pr.get_amount() self.screen.amount = self.app.format_amount_and_units(amount) if amount else '' self.screen.message = pr.get_memo() + if pr.is_pr(): + self.screen.is_pr = True + self.payment_request = pr def do_save(self): if not self.screen.address: @@ -439,13 +442,13 @@ class InvoicesScreen(CScreen): msg = _('This screen shows the list of payment requests that have been sent to you. You may also use it to store contact addresses.') invoices_list.add_widget(EmptyLabel(text=msg)) - def do_pay(self, obj): - self.app.do_pay(obj) + pr = self.app.invoices.get(obj.key) + self.app.on_pr(pr) def do_view(self, obj): pr = self.app.invoices.get(obj.key) - pr.verify({}) + pr.verify(self.app.contacts) self.app.show_pr_details(pr.get_dict(), obj.status, True) def do_delete(self, obj): diff --git a/gui/kivy/uix/ui_screens/send.kv b/gui/kivy/uix/ui_screens/send.kv @@ -11,6 +11,7 @@ SendScreen: address: '' amount: '' message: '' + is_pr: False BoxLayout padding: '12dp', '12dp', '12dp', '12dp' spacing: '12dp' @@ -31,7 +32,7 @@ SendScreen: BlueButton: id: payto_e text: s.address if s.address else _('Recipient') - on_release: app.address_dialog(s) + disabled: True shorten: True CardSeparator: opacity: message_selection.opacity @@ -49,6 +50,7 @@ SendScreen: id: amount_e default_text: _('Amount') text: s.amount if s.amount else _('Amount') + disabled: root.is_pr on_release: Clock.schedule_once(lambda dt: app.amount_dialog(s, True)) CardSeparator: opacity: message_selection.opacity @@ -66,6 +68,7 @@ SendScreen: BlueButton: id: description text: s.message if s.message else _('Description') + disabled: root.is_pr on_release: Clock.schedule_once(lambda dt: app.description_dialog(s)) BoxLayout: size_hint: 1, None diff --git a/lib/paymentrequest.py b/lib/paymentrequest.py @@ -101,6 +101,9 @@ class PaymentRequest: self.memo = self.details.memo self.payment_url = self.details.payment_url + def is_pr(self): + return self.get_outputs() != [(TYPE_ADDRESS, self.get_requestor(), self.get_amount())] + def verify(self, contacts): if not self.raw: self.error = "Empty request" @@ -455,9 +458,6 @@ class InvoiceStore(object): def add(self, pr): key = pr.get_id() - if key in self.invoices: - print_error('invoice already in list') - return key self.invoices[key] = pr self.save() return key