mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-21 02:19:51 +00:00
archive paid invoices in the history tab
This commit is contained in:
parent
8e90d6a4e5
commit
6185f94de4
5 changed files with 28 additions and 25 deletions
|
@ -729,7 +729,7 @@ class ElectrumWindow(App):
|
||||||
if self.send_screen:
|
if self.send_screen:
|
||||||
self.send_screen.do_clear()
|
self.send_screen.do_clear()
|
||||||
if pr:
|
if pr:
|
||||||
pr.set_paid(tx.txid())
|
self.wallet.invoices.set_paid(pr, tx.txid())
|
||||||
self.wallet.invoices.save()
|
self.wallet.invoices.save()
|
||||||
self.update_tab('invoices')
|
self.update_tab('invoices')
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -79,6 +79,7 @@ class HistoryList(MyTreeWidget):
|
||||||
for h_item in h:
|
for h_item in h:
|
||||||
tx_hash, height, conf, timestamp, value, balance = h_item
|
tx_hash, height, conf, timestamp, value, balance = h_item
|
||||||
status, status_str = self.wallet.get_tx_status(tx_hash, height, conf, timestamp)
|
status, status_str = self.wallet.get_tx_status(tx_hash, height, conf, timestamp)
|
||||||
|
has_invoice = self.wallet.invoices.paid.get(tx_hash)
|
||||||
icon = QIcon(":icons/" + TX_ICONS[status])
|
icon = QIcon(":icons/" + TX_ICONS[status])
|
||||||
v_str = self.parent.format_amount(value, True, whitespaces=True)
|
v_str = self.parent.format_amount(value, True, whitespaces=True)
|
||||||
balance_str = self.parent.format_amount(balance, whitespaces=True)
|
balance_str = self.parent.format_amount(balance, whitespaces=True)
|
||||||
|
@ -91,6 +92,8 @@ class HistoryList(MyTreeWidget):
|
||||||
entry.append(text)
|
entry.append(text)
|
||||||
item = QTreeWidgetItem(entry)
|
item = QTreeWidgetItem(entry)
|
||||||
item.setIcon(0, icon)
|
item.setIcon(0, icon)
|
||||||
|
if has_invoice:
|
||||||
|
item.setIcon(3, QIcon(":icons/seal"))
|
||||||
for i in range(len(entry)):
|
for i in range(len(entry)):
|
||||||
if i>3:
|
if i>3:
|
||||||
item.setTextAlignment(i, Qt.AlignRight)
|
item.setTextAlignment(i, Qt.AlignRight)
|
||||||
|
@ -144,6 +147,8 @@ class HistoryList(MyTreeWidget):
|
||||||
tx = self.wallet.transactions.get(tx_hash)
|
tx = self.wallet.transactions.get(tx_hash)
|
||||||
is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(tx)
|
is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(tx)
|
||||||
is_unconfirmed = height <= 0
|
is_unconfirmed = height <= 0
|
||||||
|
pr_key = self.wallet.invoices.paid.get(tx_hash)
|
||||||
|
|
||||||
menu = QMenu()
|
menu = QMenu()
|
||||||
|
|
||||||
menu.addAction(_("Copy %s")%column_title, lambda: self.parent.app.clipboard().setText(column_data))
|
menu.addAction(_("Copy %s")%column_title, lambda: self.parent.app.clipboard().setText(column_data))
|
||||||
|
@ -159,6 +164,8 @@ class HistoryList(MyTreeWidget):
|
||||||
child_tx = self.wallet.cpfp(tx, 0)
|
child_tx = self.wallet.cpfp(tx, 0)
|
||||||
if child_tx:
|
if child_tx:
|
||||||
menu.addAction(_("Child pays for parent"), lambda: self.parent.cpfp(tx, child_tx))
|
menu.addAction(_("Child pays for parent"), lambda: self.parent.cpfp(tx, child_tx))
|
||||||
|
if pr_key:
|
||||||
|
menu.addAction(QIcon(":icons/seal"), _("View invoice"), lambda: self.parent.show_invoice(pr_key))
|
||||||
if tx_URL:
|
if tx_URL:
|
||||||
menu.addAction(_("View on block explorer"), lambda: webbrowser.open(tx_URL))
|
menu.addAction(_("View on block explorer"), lambda: webbrowser.open(tx_URL))
|
||||||
menu.exec_(self.viewport().mapToGlobal(position))
|
menu.exec_(self.viewport().mapToGlobal(position))
|
||||||
|
|
|
@ -29,7 +29,6 @@ from electrum.i18n import _
|
||||||
from electrum.util import block_explorer_URL, format_satoshis, format_time
|
from electrum.util import block_explorer_URL, format_satoshis, format_time
|
||||||
from electrum.plugins import run_hook
|
from electrum.plugins import run_hook
|
||||||
|
|
||||||
|
|
||||||
class InvoiceList(MyTreeWidget):
|
class InvoiceList(MyTreeWidget):
|
||||||
filter_columns = [0, 1, 2, 3] # Date, Requestor, Description, Amount
|
filter_columns = [0, 1, 2, 3] # Date, Requestor, Description, Amount
|
||||||
|
|
||||||
|
@ -40,7 +39,7 @@ class InvoiceList(MyTreeWidget):
|
||||||
self.setColumnWidth(1, 200)
|
self.setColumnWidth(1, 200)
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
inv_list = self.parent.invoices.sorted_list()
|
inv_list = self.parent.invoices.unpaid_invoices()
|
||||||
self.clear()
|
self.clear()
|
||||||
for pr in inv_list:
|
for pr in inv_list:
|
||||||
key = pr.get_id()
|
key = pr.get_id()
|
||||||
|
|
|
@ -1383,7 +1383,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
return False, _("Payment request has expired")
|
return False, _("Payment request has expired")
|
||||||
status, msg = self.network.broadcast(tx)
|
status, msg = self.network.broadcast(tx)
|
||||||
if pr and status is True:
|
if pr and status is True:
|
||||||
pr.set_paid(tx.txid())
|
self.invoices.set_paid(pr, tx.txid())
|
||||||
self.invoices.save()
|
self.invoices.save()
|
||||||
self.payment_request = None
|
self.payment_request = None
|
||||||
refund_address = self.wallet.get_receiving_addresses()[0]
|
refund_address = self.wallet.get_receiving_addresses()[0]
|
||||||
|
@ -1621,27 +1621,18 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
grid = QGridLayout()
|
grid = QGridLayout()
|
||||||
grid.addWidget(QLabel(_("Requestor") + ':'), 0, 0)
|
grid.addWidget(QLabel(_("Requestor") + ':'), 0, 0)
|
||||||
grid.addWidget(QLabel(pr.get_requestor()), 0, 1)
|
grid.addWidget(QLabel(pr.get_requestor()), 0, 1)
|
||||||
grid.addWidget(QLabel(_("Expires") + ':'), 1, 0)
|
grid.addWidget(QLabel(_("Amount") + ':'), 1, 0)
|
||||||
grid.addWidget(QLabel(format_time(pr.get_expiration_date())), 1, 1)
|
outputs_str = '\n'.join(map(lambda x: self.format_amount(x[2])+ self.base_unit() + ' @ ' + x[1], pr.get_outputs()))
|
||||||
grid.addWidget(QLabel(_("Memo") + ':'), 2, 0)
|
grid.addWidget(QLabel(outputs_str), 1, 1)
|
||||||
grid.addWidget(QLabel(pr.get_memo()), 2, 1)
|
grid.addWidget(QLabel(_("Expires") + ':'), 2, 0)
|
||||||
grid.addWidget(QLabel(_("Signature") + ':'), 3, 0)
|
grid.addWidget(QLabel(format_time(pr.get_expiration_date())), 2, 1)
|
||||||
grid.addWidget(QLabel(pr.get_verify_status()), 3, 1)
|
grid.addWidget(QLabel(_("Memo") + ':'), 3, 0)
|
||||||
grid.addWidget(QLabel(_("Payment URL") + ':'), 4, 0)
|
grid.addWidget(QLabel(pr.get_memo()), 3, 1)
|
||||||
grid.addWidget(QLabel(pr.payment_url), 4, 1)
|
grid.addWidget(QLabel(_("Signature") + ':'), 4, 0)
|
||||||
grid.addWidget(QLabel(_("Outputs") + ':'), 5, 0)
|
grid.addWidget(QLabel(pr.get_verify_status()), 4, 1)
|
||||||
outputs_str = '\n'.join(map(lambda x: x[1] + ' ' + self.format_amount(x[2])+ self.base_unit(), pr.get_outputs()))
|
|
||||||
grid.addWidget(QLabel(outputs_str), 5, 1)
|
|
||||||
if pr.tx:
|
|
||||||
grid.addWidget(QLabel(_("Transaction ID") + ':'), 6, 0)
|
|
||||||
l = QLineEdit(pr.tx)
|
|
||||||
l.setReadOnly(True)
|
|
||||||
grid.addWidget(l, 6, 1)
|
|
||||||
vbox.addLayout(grid)
|
vbox.addLayout(grid)
|
||||||
vbox.addLayout(Buttons(CloseButton(d)))
|
vbox.addLayout(Buttons(CloseButton(d)))
|
||||||
d.exec_()
|
d.exec_()
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def do_pay_invoice(self, key):
|
def do_pay_invoice(self, key):
|
||||||
pr = self.invoices.get(key)
|
pr = self.invoices.get(key)
|
||||||
|
|
|
@ -298,9 +298,6 @@ class PaymentRequest:
|
||||||
print "PaymentACK message received: %s" % paymntack.memo
|
print "PaymentACK message received: %s" % paymntack.memo
|
||||||
return True, paymntack.memo
|
return True, paymntack.memo
|
||||||
|
|
||||||
def set_paid(self, tx_hash):
|
|
||||||
self.tx = tx_hash
|
|
||||||
|
|
||||||
|
|
||||||
def make_unsigned_request(req):
|
def make_unsigned_request(req):
|
||||||
from transaction import Transaction
|
from transaction import Transaction
|
||||||
|
@ -460,9 +457,14 @@ class InvoiceStore(object):
|
||||||
def __init__(self, storage):
|
def __init__(self, storage):
|
||||||
self.storage = storage
|
self.storage = storage
|
||||||
self.invoices = {}
|
self.invoices = {}
|
||||||
|
self.paid = {}
|
||||||
d = self.storage.get('invoices', {})
|
d = self.storage.get('invoices', {})
|
||||||
self.load(d)
|
self.load(d)
|
||||||
|
|
||||||
|
def set_paid(self, pr, txid):
|
||||||
|
pr.tx = txid
|
||||||
|
self.paid[txid] = pr.get_id()
|
||||||
|
|
||||||
def load(self, d):
|
def load(self, d):
|
||||||
for k, v in d.items():
|
for k, v in d.items():
|
||||||
try:
|
try:
|
||||||
|
@ -470,6 +472,8 @@ class InvoiceStore(object):
|
||||||
pr.tx = v.get('txid')
|
pr.tx = v.get('txid')
|
||||||
pr.requestor = v.get('requestor')
|
pr.requestor = v.get('requestor')
|
||||||
self.invoices[k] = pr
|
self.invoices[k] = pr
|
||||||
|
if pr.tx:
|
||||||
|
self.paid[pr.tx] = k
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -517,3 +521,5 @@ class InvoiceStore(object):
|
||||||
# sort
|
# sort
|
||||||
return self.invoices.values()
|
return self.invoices.values()
|
||||||
|
|
||||||
|
def unpaid_invoices(self):
|
||||||
|
return [ self.invoices[k] for k in filter(lambda x: self.get_status(x)!=PR_PAID, self.invoices.keys())]
|
||||||
|
|
Loading…
Add table
Reference in a new issue