lightning: connect send button
This commit is contained in:
parent
424a346834
commit
6949d37251
@ -1504,7 +1504,15 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
|||||||
def do_preview(self):
|
def do_preview(self):
|
||||||
self.do_send(preview = True)
|
self.do_send(preview = True)
|
||||||
|
|
||||||
|
def pay_lightning_invoice(self, invoice):
|
||||||
|
f = self.wallet.lnworker.pay(invoice)
|
||||||
|
self.do_clear()
|
||||||
|
|
||||||
def do_send(self, preview = False):
|
def do_send(self, preview = False):
|
||||||
|
if self.payto_e.is_lightning:
|
||||||
|
self.pay_lightning_invoice(self.payto_e.lightning_invoice)
|
||||||
|
return
|
||||||
|
#
|
||||||
if run_hook('abort_send', self):
|
if run_hook('abort_send', self):
|
||||||
return
|
return
|
||||||
r = self.read_send_tab()
|
r = self.read_send_tab()
|
||||||
@ -1713,11 +1721,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
|||||||
else:
|
else:
|
||||||
description = ''
|
description = ''
|
||||||
self.payto_e.setFrozen(True)
|
self.payto_e.setFrozen(True)
|
||||||
self.payto_e.setGreen()
|
|
||||||
self.payto_e.setText(pubkey)
|
self.payto_e.setText(pubkey)
|
||||||
self.message_e.setText(description)
|
self.message_e.setText(description)
|
||||||
self.amount_e.setAmount(lnaddr.amount)
|
self.amount_e.setAmount(lnaddr.amount)
|
||||||
#self.amount_e.textEdited.emit("")
|
#self.amount_e.textEdited.emit("")
|
||||||
|
self.payto_e.is_lightning = True
|
||||||
|
|
||||||
def pay_to_URI(self, URI):
|
def pay_to_URI(self, URI):
|
||||||
if not URI:
|
if not URI:
|
||||||
@ -1755,6 +1763,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
|||||||
self.not_enough_funds = False
|
self.not_enough_funds = False
|
||||||
self.payment_request = None
|
self.payment_request = None
|
||||||
self.payto_e.is_pr = False
|
self.payto_e.is_pr = False
|
||||||
|
self.payto_e.is_lightning = False
|
||||||
for e in [self.payto_e, self.message_e, self.amount_e, self.fiat_send_e,
|
for e in [self.payto_e, self.message_e, self.amount_e, self.fiat_send_e,
|
||||||
self.fee_e, self.feerate_e]:
|
self.fee_e, self.feerate_e]:
|
||||||
e.setText('')
|
e.setText('')
|
||||||
|
|||||||
@ -56,6 +56,7 @@ class PayToEdit(CompletionTextEdit, ScanQRTextEdit):
|
|||||||
self.errors = []
|
self.errors = []
|
||||||
self.is_pr = False
|
self.is_pr = False
|
||||||
self.is_alias = False
|
self.is_alias = False
|
||||||
|
self.is_lightning = False
|
||||||
self.update_size()
|
self.update_size()
|
||||||
self.payto_address = None
|
self.payto_address = None
|
||||||
self.previous_payto = ''
|
self.previous_payto = ''
|
||||||
@ -129,6 +130,7 @@ class PayToEdit(CompletionTextEdit, ScanQRTextEdit):
|
|||||||
return
|
return
|
||||||
if data.startswith("ln"):
|
if data.startswith("ln"):
|
||||||
self.win.parse_lightning_invoice(data)
|
self.win.parse_lightning_invoice(data)
|
||||||
|
self.lightning_invoice = data
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
self.payto_address = self.parse_output(data)
|
self.payto_address = self.parse_output(data)
|
||||||
|
|||||||
@ -692,7 +692,8 @@ class Commands:
|
|||||||
|
|
||||||
@command('wn')
|
@command('wn')
|
||||||
def lnpay(self, invoice):
|
def lnpay(self, invoice):
|
||||||
self.wallet.lnworker.pay(invoice)
|
f = self.wallet.lnworker.pay(invoice)
|
||||||
|
return f.result()
|
||||||
|
|
||||||
@command('wn')
|
@command('wn')
|
||||||
def addinvoice(self, requested_amount, message):
|
def addinvoice(self, requested_amount, message):
|
||||||
|
|||||||
@ -193,7 +193,7 @@ class LNWorker(PrintError):
|
|||||||
|
|
||||||
def pay(self, invoice):
|
def pay(self, invoice):
|
||||||
coro = self._pay_coroutine(invoice)
|
coro = self._pay_coroutine(invoice)
|
||||||
return asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop).result()
|
return asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop)
|
||||||
|
|
||||||
# not aiosafe because we call .result() which will propagate an exception
|
# not aiosafe because we call .result() which will propagate an exception
|
||||||
async def _pay_coroutine(self, invoice):
|
async def _pay_coroutine(self, invoice):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user