mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 01:11:35 +00:00
qt: add clear button to receive tab, show invoice right after it is added
This commit is contained in:
parent
234591624e
commit
0913194a53
3 changed files with 10 additions and 10 deletions
|
@ -786,7 +786,9 @@ class Commands:
|
||||||
@command('wn')
|
@command('wn')
|
||||||
def addinvoice(self, requested_amount, message):
|
def addinvoice(self, requested_amount, message):
|
||||||
# using requested_amount because it is documented in param_descriptions
|
# using requested_amount because it is documented in param_descriptions
|
||||||
return self.lnworker.add_invoice(satoshis(requested_amount), message)
|
payment_hash = self.lnworker.add_invoice(satoshis(requested_amount), message)
|
||||||
|
invoice, direction, is_paid = self.lnworker.invoices[bh2u(payment_hash)]
|
||||||
|
return invoice
|
||||||
|
|
||||||
@command('w')
|
@command('w')
|
||||||
def nodeid(self):
|
def nodeid(self):
|
||||||
|
|
|
@ -963,11 +963,14 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||||
self.expires_label.hide()
|
self.expires_label.hide()
|
||||||
grid.addWidget(self.expires_label, 2, 1)
|
grid.addWidget(self.expires_label, 2, 1)
|
||||||
|
|
||||||
|
self.clear_invoice_button = QPushButton(_('Clear'))
|
||||||
|
self.clear_invoice_button.clicked.connect(self.clear_receive_tab)
|
||||||
self.create_invoice_button = QPushButton(_('On-chain'))
|
self.create_invoice_button = QPushButton(_('On-chain'))
|
||||||
self.create_invoice_button.setIcon(read_QIcon("bitcoin.png"))
|
self.create_invoice_button.setIcon(read_QIcon("bitcoin.png"))
|
||||||
self.create_invoice_button.clicked.connect(lambda: self.create_invoice(False))
|
self.create_invoice_button.clicked.connect(lambda: self.create_invoice(False))
|
||||||
self.receive_buttons = buttons = QHBoxLayout()
|
self.receive_buttons = buttons = QHBoxLayout()
|
||||||
buttons.addStretch(1)
|
buttons.addStretch(1)
|
||||||
|
buttons.addWidget(self.clear_invoice_button)
|
||||||
buttons.addWidget(self.create_invoice_button)
|
buttons.addWidget(self.create_invoice_button)
|
||||||
if self.config.get('lightning'):
|
if self.config.get('lightning'):
|
||||||
self.create_lightning_invoice_button = QPushButton(_('Lightning'))
|
self.create_lightning_invoice_button = QPushButton(_('Lightning'))
|
||||||
|
@ -1076,11 +1079,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||||
i = self.expires_combo.currentIndex()
|
i = self.expires_combo.currentIndex()
|
||||||
expiration = list(map(lambda x: x[1], expiration_values))[i]
|
expiration = list(map(lambda x: x[1], expiration_values))[i]
|
||||||
if is_lightning:
|
if is_lightning:
|
||||||
key = self.wallet.lnworker.add_invoice(amount, message)
|
payment_hash = self.wallet.lnworker.add_invoice(amount, message)
|
||||||
|
key = bh2u(payment_hash)
|
||||||
else:
|
else:
|
||||||
key = self.create_bitcoin_request(amount, message, expiration)
|
key = self.create_bitcoin_request(amount, message, expiration)
|
||||||
self.address_list.update()
|
self.address_list.update()
|
||||||
self.clear_receive_tab()
|
|
||||||
self.request_list.update()
|
self.request_list.update()
|
||||||
self.request_list.select_key(key)
|
self.request_list.select_key(key)
|
||||||
|
|
||||||
|
@ -1130,12 +1133,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||||
self.receive_amount_e.setAmount(None)
|
self.receive_amount_e.setAmount(None)
|
||||||
|
|
||||||
def clear_receive_tab(self):
|
def clear_receive_tab(self):
|
||||||
try:
|
self.receive_address_e.setText('')
|
||||||
addr = self.wallet.get_receiving_address() or ''
|
|
||||||
except InternalAddressCorruption as e:
|
|
||||||
self.show_error(str(e))
|
|
||||||
addr = ''
|
|
||||||
self.receive_address_e.setText(addr)
|
|
||||||
self.receive_message_e.setText('')
|
self.receive_message_e.setText('')
|
||||||
self.receive_amount_e.setAmount(None)
|
self.receive_amount_e.setAmount(None)
|
||||||
self.expires_label.hide()
|
self.expires_label.hide()
|
||||||
|
|
|
@ -781,7 +781,7 @@ class LNWallet(LNWorker):
|
||||||
self.save_invoice(payment_hash, invoice, RECEIVED, is_paid=False)
|
self.save_invoice(payment_hash, invoice, RECEIVED, is_paid=False)
|
||||||
self.save_preimage(payment_hash, payment_preimage)
|
self.save_preimage(payment_hash, payment_preimage)
|
||||||
self.wallet.set_label(bh2u(payment_hash), message)
|
self.wallet.set_label(bh2u(payment_hash), message)
|
||||||
return invoice
|
return payment_hash
|
||||||
|
|
||||||
def save_preimage(self, payment_hash: bytes, preimage: bytes):
|
def save_preimage(self, payment_hash: bytes, preimage: bytes):
|
||||||
assert sha256(preimage) == payment_hash
|
assert sha256(preimage) == payment_hash
|
||||||
|
|
Loading…
Add table
Reference in a new issue