lightning: kivy lightning send invoice ui

This commit is contained in:
Janus 2018-03-05 13:43:48 +01:00
parent 4635d37acf
commit 1694bf3d56
5 changed files with 68 additions and 2 deletions

View File

@ -387,6 +387,9 @@
AddressScreen:
id: address_screen
tab: address_tab
LightningPayerScreen:
id: lightning_payer_screen
tab: lightning_payer_tab
CleanHeader:
id: invoices_tab
text: _('Invoices')
@ -407,6 +410,10 @@
id: address_tab
text: _('Addresses')
slide: 4
CleanHeader:
id: lightning_payer_tab
text: _('Send Lightning Payment')
slide: 5
<ActionOvrButton@ActionButton>

View File

@ -21,6 +21,7 @@ from electrum.util import profiler, parse_URI, format_time, InvalidPassword, Not
from electrum import bitcoin
from electrum.util import timestamp_to_datetime
from electrum.paymentrequest import PR_UNPAID, PR_PAID, PR_UNKNOWN, PR_EXPIRED
import electrum.lightning as lightning
from .context_menu import ContextMenu
@ -589,6 +590,29 @@ class AddressScreen(CScreen):
def ext_search(self, card, search):
return card.memo.find(search) >= 0 or card.amount.find(search) >= 0
class LightningPayerScreen(CScreen):
kvname = 'lightning_payer'
def on_activate(self, *args, **kwargs):
super(LightningPayerScreen, self).on_activate(*args, **kwargs)
class FakeQtSignal:
def emit(self2, data):
self.app.show_info(data)
class MyConsole:
newResult = FakeQtSignal()
self.app.wallet.lightning.setConsole(MyConsole())
def do_paste_sample(self):
self.screen.invoice_data = "lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d73gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ecky03ylcqca784w"
def do_paste(self):
contents = self.app._clipboard.paste()
if not contents:
self.app.show_info(_("Clipboard is empty"))
return
self.screen.invoice_data = contents
def do_clear(self):
self.screen.invoice_data = ""
def do_pay(self):
lightning.lightningCall(self.app.wallet.lightning, "sendpayment")("--pay_req=" + self.screen.invoice_data)

View File

@ -0,0 +1,32 @@
LightningPayerScreen:
id: s
name: 'lightning_payer'
invoice_data: ''
BoxLayout:
orientation: "vertical"
BlueButton:
text: s.invoice_data if s.invoice_data else _('Lightning invoice')
shorten: True
on_release: Clock.schedule_once(lambda dt: app.show_info(_('Copy and paste the lightning invoice using the Paste button, or use the camera to scan a QR code.')))
GridLayout:
cols: 4
size_hint: 1, None
height: '48dp'
IconButton:
id: qr
on_release: Clock.schedule_once(lambda dt: app.scan_qr(on_complete=s.on_lightning_qr))
icon: 'atlas://gui/kivy/theming/light/camera'
Button:
text: _('Paste')
on_release: s.parent.do_paste()
Button:
text: _('Paste sample')
on_release: s.parent.do_paste_sample()
Button:
text: _('Clear')
on_release: s.parent.do_clear()
Button:
size_hint: 1, None
height: '48dp'
text: _('Pay pasted/scanned invoice')
on_release: s.parent.do_pay()

View File

@ -32,7 +32,8 @@ NETWORK = None
CONFIG = None
locked = set()
machine = "148.251.87.112"
#machine = "148.251.87.112"
machine = "127.0.0.1"
def WriteDb(json):
req = rpc_pb2.WriteDbRequest()

View File

@ -12,7 +12,9 @@ async def handler(reader, writer):
async def handler2(reader, writer):
while True:
data = await reader.read(2048)
print(data)
if data != b'':
writer.write(b"HTTP/1.0 200 OK\r\nContent-length: 16\r\n\r\n{\"result\":\"lol\"}")
await writer.drain()
asyncio.ensure_future(asyncio.start_server(handler, "127.0.0.1", 1080))
asyncio.ensure_future(asyncio.start_server(handler2, "127.0.0.1", 8090))