electrum

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

commit 74b0ed5f48c838d86ad655aaa2dc485ced78d59a
parent 0d4d06c58b86a70354f50b58e8a42507d417e28f
Author: ThomasV <thomasv@gitorious>
Date:   Wed, 22 Apr 2015 13:36:07 +0200

move get_status to InvoiceStore

Diffstat:
Mgui/qt/main_window.py | 12+++++++-----
Mlib/paymentrequest.py | 17+++++++++--------
2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -1189,12 +1189,12 @@ class ElectrumWindow(QMainWindow): def payment_request_ok(self): pr = self.payment_request - status = pr.get_status() key = self.invoices.add(pr) + status = self.invoices.get_status(key) self.update_invoices_list() if status == PR_PAID: - self.do_clear() self.show_message("invoice already paid") + self.do_clear() self.payment_request = None return @@ -1306,7 +1306,7 @@ class ElectrumWindow(QMainWindow): l.clear() for pr in inv_list: key = pr.get_id() - status = pr.get_status() + status = self.invoices.get_status(key) domain = pr.get_domain() date_str = format_time(pr.get_expiration_date()) item = QTreeWidgetItem( [ date_str, domain, pr.memo, self.format_amount(pr.get_amount(), whitespaces=True), pr_tooltips.get(status,'')] ) @@ -1485,7 +1485,9 @@ class ElectrumWindow(QMainWindow): grid.addWidget(QLabel(outputs_str), 5, 1) if pr.tx: grid.addWidget(QLabel(_("Transaction ID") + ':'), 6, 0) - grid.addWidget(QLabel(pr.tx), 6, 1) + l = QLineEdit(pr.tx) + l.setReadOnly(True) + grid.addWidget(l, 6, 1) vbox.addLayout(grid) vbox.addLayout(Buttons(CloseButton(d))) d.exec_() @@ -1508,7 +1510,7 @@ class ElectrumWindow(QMainWindow): return key = str(item.data(0, 32).toString()) pr = self.invoices.get(key) - status = pr.get_status() + status = self.invoices.get_status(key) menu = QMenu() menu.addAction(_("Details"), lambda: self.show_invoice(key)) if status == PR_UNPAID: diff --git a/lib/paymentrequest.py b/lib/paymentrequest.py @@ -84,13 +84,6 @@ class PaymentRequest: def __str__(self): return self.raw - def get_status(self): - if self.tx is not None: - return PR_PAID - if self.has_expired(): - return PR_EXPIRED - return PR_UNPAID - def parse(self, r): self.id = bitcoin.sha256(r)[0:16].encode('hex') try: @@ -330,11 +323,19 @@ class InvoiceStore(object): with open(path, 'w') as f: r = f.write(json.dumps(l)) + def get_status(self, key): + pr = self.get(key) + if pr.tx is not None: + return PR_PAID + if pr.has_expired(): + return PR_EXPIRED + return PR_UNPAID + def add(self, pr): key = pr.get_id() if key in self.invoices: print_error('invoice already in list') - return False + return key self.invoices[key] = pr self.save() return key