lightning: minimal qt invoice gui should work
This commit is contained in:
parent
77164249f3
commit
32940fdea8
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import base64
|
||||
import binascii
|
||||
from PyQt5 import QtCore, QtWidgets
|
||||
from collections import OrderedDict
|
||||
@ -12,6 +13,8 @@ idx = 0
|
||||
|
||||
class MyTableRow(QtWidgets.QTreeWidgetItem):
|
||||
def __init__(self, di):
|
||||
if "settled" not in di:
|
||||
di["settled"] = False
|
||||
strs = [str(di[mapping[key]]) for key in range(len(mapping))]
|
||||
print(strs)
|
||||
super(MyTableRow, self).__init__(strs)
|
||||
@ -23,7 +26,7 @@ class MyTableRow(QtWidgets.QTreeWidgetItem):
|
||||
self.di[idx] = val
|
||||
try:
|
||||
self.setData(revMapp[idx], QtCore.Qt.DisplayRole, '{0}'.format(val))
|
||||
except IndexError:
|
||||
except KeyError:
|
||||
logging.warning("Lightning Invoice field %s unknown", idx)
|
||||
def __str__(self):
|
||||
return str(self.di)
|
||||
@ -34,23 +37,21 @@ def addInvoiceRow(new):
|
||||
datatable.move_to_end(new["r_hash"], last=False)
|
||||
return made
|
||||
|
||||
class SatoshiCountSpinBox(QtWidgets.QSpinBox):
|
||||
def keyPressEvent(self, e):
|
||||
super(SatoshiCountSpinBox, self).keyPressEvent(e)
|
||||
if QtCore.Qt.Key_Return == e.key():
|
||||
clickHandler(self)
|
||||
|
||||
def clickHandler(numInput, treeView, lightningRpc):
|
||||
print(numInput.value())
|
||||
amt = numInput.value()
|
||||
if amt < 1:
|
||||
print("value too small")
|
||||
return
|
||||
print("creating invoice with value {}".format(amt))
|
||||
global idx
|
||||
obj = {
|
||||
"r_hash": binascii.hexlify((int.from_bytes(bytearray.fromhex("9500edb0994b7bc23349193486b25c82097045db641f35fa988c0e849acdec29"), "big")+idx).to_bytes(byteorder="big", length=32)).decode("ascii"),
|
||||
"pay_req": "lntb81920n1pdf258s" + str(idx),
|
||||
"settled": False
|
||||
}
|
||||
treeView.insertTopLevelItem(0, addInvoiceRow(obj))
|
||||
#obj = {
|
||||
# "r_hash": binascii.hexlify((int.from_bytes(bytearray.fromhex("9500edb0994b7bc23349193486b25c82097045db641f35fa988c0e849acdec29"), "big")+idx).to_bytes(byteorder="big", length=32)).decode("ascii"),
|
||||
# "pay_req": "lntb81920n1pdf258s" + str(idx),
|
||||
# "settled": False
|
||||
#}
|
||||
#treeView.insertTopLevelItem(0, addInvoiceRow(obj))
|
||||
idx += 1
|
||||
lightningCall(lightningRpc, "getinfo")()
|
||||
lightningCall(lightningRpc, "addinvoice")("--amt=" + str(amt))
|
||||
|
||||
class LightningInvoiceList(QtWidgets.QWidget):
|
||||
def create_menu(self, position):
|
||||
@ -62,14 +63,35 @@ class LightningInvoiceList(QtWidgets.QWidget):
|
||||
cb.setText(pay_req)
|
||||
menu.addAction("Copy payment request", copy)
|
||||
menu.exec_(self._tv.viewport().mapToGlobal(position))
|
||||
"""
|
||||
A simple test widget to contain and own the model and table.
|
||||
"""
|
||||
def lightningWorkerHandler(self, sourceClassName, obj):
|
||||
new = {}
|
||||
for k, v in obj.items():
|
||||
try:
|
||||
v = binascii.hexlify(base64.b64decode(v)).decode("ascii")
|
||||
except:
|
||||
pass
|
||||
new[k] = v
|
||||
try:
|
||||
obj = datatable[new["r_hash"]]
|
||||
except KeyError:
|
||||
print("lightning payment invoice r_hash {} unknown!".format(new["r_hash"]))
|
||||
else:
|
||||
for k, v in new.items():
|
||||
try:
|
||||
if obj[k] != v: obj[k] = v
|
||||
except KeyError:
|
||||
obj[k] = v
|
||||
def lightningRpcHandler(self, methodName, obj):
|
||||
if methodName != "addinvoice":
|
||||
print("ignoring reply {} to {}".format(obj, methodName))
|
||||
return
|
||||
self._tv.insertTopLevelItem(0, addInvoiceRow(obj))
|
||||
|
||||
def __init__(self, parent, lightningWorker, lightningRpc):
|
||||
QtWidgets.QWidget.__init__(self, parent)
|
||||
|
||||
lightningWorker.subscribe(lambda *args: print(args))
|
||||
lightningRpc.subscribe(lambda *args: print(args))
|
||||
lightningWorker.subscribe(self.lightningWorkerHandler)
|
||||
lightningRpc.subscribe(self.lightningRpcHandler)
|
||||
|
||||
self._tv=QtWidgets.QTreeWidget(self)
|
||||
self._tv.setHeaderLabels([mapping[i] for i in range(len(mapping))])
|
||||
@ -77,6 +99,12 @@ class LightningInvoiceList(QtWidgets.QWidget):
|
||||
self._tv.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
||||
self._tv.customContextMenuRequested.connect(self.create_menu)
|
||||
|
||||
class SatoshiCountSpinBox(QtWidgets.QSpinBox):
|
||||
def keyPressEvent(self2, e):
|
||||
super(SatoshiCountSpinBox, self2).keyPressEvent(e)
|
||||
if QtCore.Qt.Key_Return == e.key():
|
||||
clickHandler(self2, self._tv, lightningRpc)
|
||||
|
||||
numInput = SatoshiCountSpinBox(self)
|
||||
|
||||
button = QtWidgets.QPushButton('Add invoice', self)
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import functools
|
||||
import sys
|
||||
import struct
|
||||
import traceback
|
||||
@ -644,6 +645,7 @@ class LightningRPC(ForeverCoroutineJob):
|
||||
def __init__(self):
|
||||
super(LightningRPC, self).__init__()
|
||||
self.queue = queue.Queue()
|
||||
self.subscribers = []
|
||||
# overridden
|
||||
async def run(self, is_running):
|
||||
print("RPC STARTED")
|
||||
@ -654,19 +656,32 @@ class LightningRPC(ForeverCoroutineJob):
|
||||
await asyncio.sleep(1)
|
||||
pass
|
||||
else:
|
||||
def call(qitem):
|
||||
def lightningRpcNetworkRequestThreadTarget(qitem):
|
||||
applyMethodName = lambda x: functools.partial(x, qitem.methodName)
|
||||
client = Server("http://" + machine + ":8090")
|
||||
result = getattr(client, qitem.methodName)(base64.b64encode(privateKeyHash[:6]).decode("ascii"), *[str(x) for x in qitem.args])
|
||||
argumentStrings = [str(x) for x in qitem.args]
|
||||
lightningSessionKey = base64.b64encode(privateKeyHash[:6]).decode("ascii")
|
||||
resolvedMethod = getattr(client, qitem.methodName)
|
||||
try:
|
||||
result = resolvedMethod(lightningSessionKey, *argumentStrings)
|
||||
except BaseException as e:
|
||||
traceback.print_exc()
|
||||
for i in self.subscribers: applyMethodName(i)(e)
|
||||
raise
|
||||
toprint = result
|
||||
try:
|
||||
if result["stderr"] == "" and result["returncode"] == 0:
|
||||
toprint = json.loads(result["stdout"])
|
||||
except:
|
||||
pass
|
||||
assert result["stderr"] == "" and result["returncode"] == 0, "LightningRPC detected error: " + result["stderr"]
|
||||
toprint = json.loads(result["stdout"])
|
||||
for i in self.subscribers: applyMethodName(i)(toprint)
|
||||
except BaseException as e:
|
||||
traceback.print_exc()
|
||||
for i in self.subscribers: applyMethodName(i)(e)
|
||||
self.console.newResult.emit(json.dumps(toprint, indent=4))
|
||||
threading.Thread(target=call, args=(qitem, )).start()
|
||||
threading.Thread(target=lightningRpcNetworkRequestThreadTarget, args=(qitem, )).start()
|
||||
def setConsole(self, console):
|
||||
self.console = console
|
||||
def subscribe(self, notifyFunction):
|
||||
self.subscribers.append(notifyFunction)
|
||||
|
||||
def lightningCall(rpc, methodName):
|
||||
def fun(*args):
|
||||
@ -706,6 +721,7 @@ class LightningWorker(ForeverCoroutineJob):
|
||||
|
||||
deser = bitcoin.deserialize_xpub(wallet().keystore.xpub)
|
||||
assert deser[0] == "p2wpkh", deser
|
||||
self.subscribers = []
|
||||
|
||||
async def run(self, is_running):
|
||||
global WALLET, NETWORK
|
||||
@ -736,14 +752,18 @@ class LightningWorker(ForeverCoroutineJob):
|
||||
await asyncio.wait_for(writer.drain(), 5)
|
||||
while is_running():
|
||||
obj = await readJson(reader, is_running)
|
||||
if not obj: continue
|
||||
if "id" not in obj:
|
||||
print("Invoice update?", obj)
|
||||
for i in self.subscribers: i(obj)
|
||||
continue
|
||||
await asyncio.wait_for(readReqAndReply(obj, writer), 10)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
await asyncio.sleep(5)
|
||||
continue
|
||||
def subscribe(self, notifyFunction):
|
||||
self.subscribers.append(functools.partial(notifyFunction, "LightningWorker"))
|
||||
|
||||
async def readJson(reader, is_running):
|
||||
data = b""
|
||||
|
||||
46
lib/ln/google/api/annotations_pb2.py
Normal file
46
lib/ln/google/api/annotations_pb2.py
Normal file
@ -0,0 +1,46 @@
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: google/api/annotations.proto
|
||||
|
||||
import sys
|
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import message as _message
|
||||
from google.protobuf import reflection as _reflection
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf import descriptor_pb2
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
from google.api import http_pb2 as google_dot_api_dot_http__pb2
|
||||
from google.protobuf import descriptor_pb2 as google_dot_protobuf_dot_descriptor__pb2
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor(
|
||||
name='google/api/annotations.proto',
|
||||
package='google.api',
|
||||
syntax='proto3',
|
||||
serialized_pb=_b('\n\x1cgoogle/api/annotations.proto\x12\ngoogle.api\x1a\x15google/api/http.proto\x1a google/protobuf/descriptor.proto:E\n\x04http\x12\x1e.google.protobuf.MethodOptions\x18\xb0\xca\xbc\" \x01(\x0b\x32\x14.google.api.HttpRuleBn\n\x0e\x63om.google.apiB\x10\x41nnotationsProtoP\x01ZAgoogle.golang.org/genproto/googleapis/api/annotations;annotations\xa2\x02\x04GAPIb\x06proto3')
|
||||
,
|
||||
dependencies=[google_dot_api_dot_http__pb2.DESCRIPTOR,google_dot_protobuf_dot_descriptor__pb2.DESCRIPTOR,])
|
||||
|
||||
|
||||
HTTP_FIELD_NUMBER = 72295728
|
||||
http = _descriptor.FieldDescriptor(
|
||||
name='http', full_name='google.api.http', index=0,
|
||||
number=72295728, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=True, extension_scope=None,
|
||||
options=None, file=DESCRIPTOR)
|
||||
|
||||
DESCRIPTOR.extensions_by_name['http'] = http
|
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
||||
|
||||
http.message_type = google_dot_api_dot_http__pb2._HTTPRULE
|
||||
google_dot_protobuf_dot_descriptor__pb2.MethodOptions.RegisterExtension(http)
|
||||
|
||||
DESCRIPTOR.has_options = True
|
||||
DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\016com.google.apiB\020AnnotationsProtoP\001ZAgoogle.golang.org/genproto/googleapis/api/annotations;annotations\242\002\004GAPI'))
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
236
lib/ln/google/api/http_pb2.py
Normal file
236
lib/ln/google/api/http_pb2.py
Normal file
@ -0,0 +1,236 @@
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: google/api/http.proto
|
||||
|
||||
import sys
|
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import message as _message
|
||||
from google.protobuf import reflection as _reflection
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf import descriptor_pb2
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor(
|
||||
name='google/api/http.proto',
|
||||
package='google.api',
|
||||
syntax='proto3',
|
||||
serialized_pb=_b('\n\x15google/api/http.proto\x12\ngoogle.api\"+\n\x04Http\x12#\n\x05rules\x18\x01 \x03(\x0b\x32\x14.google.api.HttpRule\"\xea\x01\n\x08HttpRule\x12\x10\n\x08selector\x18\x01 \x01(\t\x12\r\n\x03get\x18\x02 \x01(\tH\x00\x12\r\n\x03put\x18\x03 \x01(\tH\x00\x12\x0e\n\x04post\x18\x04 \x01(\tH\x00\x12\x10\n\x06\x64\x65lete\x18\x05 \x01(\tH\x00\x12\x0f\n\x05patch\x18\x06 \x01(\tH\x00\x12/\n\x06\x63ustom\x18\x08 \x01(\x0b\x32\x1d.google.api.CustomHttpPatternH\x00\x12\x0c\n\x04\x62ody\x18\x07 \x01(\t\x12\x31\n\x13\x61\x64\x64itional_bindings\x18\x0b \x03(\x0b\x32\x14.google.api.HttpRuleB\t\n\x07pattern\"/\n\x11\x43ustomHttpPattern\x12\x0c\n\x04kind\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x01(\tBj\n\x0e\x63om.google.apiB\tHttpProtoP\x01ZAgoogle.golang.org/genproto/googleapis/api/annotations;annotations\xf8\x01\x01\xa2\x02\x04GAPIb\x06proto3')
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
_HTTP = _descriptor.Descriptor(
|
||||
name='Http',
|
||||
full_name='google.api.Http',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='rules', full_name='google.api.Http.rules', index=0,
|
||||
number=1, type=11, cpp_type=10, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None, file=DESCRIPTOR),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=37,
|
||||
serialized_end=80,
|
||||
)
|
||||
|
||||
|
||||
_HTTPRULE = _descriptor.Descriptor(
|
||||
name='HttpRule',
|
||||
full_name='google.api.HttpRule',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='selector', full_name='google.api.HttpRule.selector', index=0,
|
||||
number=1, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='get', full_name='google.api.HttpRule.get', index=1,
|
||||
number=2, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='put', full_name='google.api.HttpRule.put', index=2,
|
||||
number=3, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='post', full_name='google.api.HttpRule.post', index=3,
|
||||
number=4, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='delete', full_name='google.api.HttpRule.delete', index=4,
|
||||
number=5, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='patch', full_name='google.api.HttpRule.patch', index=5,
|
||||
number=6, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='custom', full_name='google.api.HttpRule.custom', index=6,
|
||||
number=8, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='body', full_name='google.api.HttpRule.body', index=7,
|
||||
number=7, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='additional_bindings', full_name='google.api.HttpRule.additional_bindings', index=8,
|
||||
number=11, type=11, cpp_type=10, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None, file=DESCRIPTOR),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
_descriptor.OneofDescriptor(
|
||||
name='pattern', full_name='google.api.HttpRule.pattern',
|
||||
index=0, containing_type=None, fields=[]),
|
||||
],
|
||||
serialized_start=83,
|
||||
serialized_end=317,
|
||||
)
|
||||
|
||||
|
||||
_CUSTOMHTTPPATTERN = _descriptor.Descriptor(
|
||||
name='CustomHttpPattern',
|
||||
full_name='google.api.CustomHttpPattern',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='kind', full_name='google.api.CustomHttpPattern.kind', index=0,
|
||||
number=1, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None, file=DESCRIPTOR),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='path', full_name='google.api.CustomHttpPattern.path', index=1,
|
||||
number=2, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None, file=DESCRIPTOR),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=319,
|
||||
serialized_end=366,
|
||||
)
|
||||
|
||||
_HTTP.fields_by_name['rules'].message_type = _HTTPRULE
|
||||
_HTTPRULE.fields_by_name['custom'].message_type = _CUSTOMHTTPPATTERN
|
||||
_HTTPRULE.fields_by_name['additional_bindings'].message_type = _HTTPRULE
|
||||
_HTTPRULE.oneofs_by_name['pattern'].fields.append(
|
||||
_HTTPRULE.fields_by_name['get'])
|
||||
_HTTPRULE.fields_by_name['get'].containing_oneof = _HTTPRULE.oneofs_by_name['pattern']
|
||||
_HTTPRULE.oneofs_by_name['pattern'].fields.append(
|
||||
_HTTPRULE.fields_by_name['put'])
|
||||
_HTTPRULE.fields_by_name['put'].containing_oneof = _HTTPRULE.oneofs_by_name['pattern']
|
||||
_HTTPRULE.oneofs_by_name['pattern'].fields.append(
|
||||
_HTTPRULE.fields_by_name['post'])
|
||||
_HTTPRULE.fields_by_name['post'].containing_oneof = _HTTPRULE.oneofs_by_name['pattern']
|
||||
_HTTPRULE.oneofs_by_name['pattern'].fields.append(
|
||||
_HTTPRULE.fields_by_name['delete'])
|
||||
_HTTPRULE.fields_by_name['delete'].containing_oneof = _HTTPRULE.oneofs_by_name['pattern']
|
||||
_HTTPRULE.oneofs_by_name['pattern'].fields.append(
|
||||
_HTTPRULE.fields_by_name['patch'])
|
||||
_HTTPRULE.fields_by_name['patch'].containing_oneof = _HTTPRULE.oneofs_by_name['pattern']
|
||||
_HTTPRULE.oneofs_by_name['pattern'].fields.append(
|
||||
_HTTPRULE.fields_by_name['custom'])
|
||||
_HTTPRULE.fields_by_name['custom'].containing_oneof = _HTTPRULE.oneofs_by_name['pattern']
|
||||
DESCRIPTOR.message_types_by_name['Http'] = _HTTP
|
||||
DESCRIPTOR.message_types_by_name['HttpRule'] = _HTTPRULE
|
||||
DESCRIPTOR.message_types_by_name['CustomHttpPattern'] = _CUSTOMHTTPPATTERN
|
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
||||
|
||||
Http = _reflection.GeneratedProtocolMessageType('Http', (_message.Message,), dict(
|
||||
DESCRIPTOR = _HTTP,
|
||||
__module__ = 'google.api.http_pb2'
|
||||
# @@protoc_insertion_point(class_scope:google.api.Http)
|
||||
))
|
||||
_sym_db.RegisterMessage(Http)
|
||||
|
||||
HttpRule = _reflection.GeneratedProtocolMessageType('HttpRule', (_message.Message,), dict(
|
||||
DESCRIPTOR = _HTTPRULE,
|
||||
__module__ = 'google.api.http_pb2'
|
||||
# @@protoc_insertion_point(class_scope:google.api.HttpRule)
|
||||
))
|
||||
_sym_db.RegisterMessage(HttpRule)
|
||||
|
||||
CustomHttpPattern = _reflection.GeneratedProtocolMessageType('CustomHttpPattern', (_message.Message,), dict(
|
||||
DESCRIPTOR = _CUSTOMHTTPPATTERN,
|
||||
__module__ = 'google.api.http_pb2'
|
||||
# @@protoc_insertion_point(class_scope:google.api.CustomHttpPattern)
|
||||
))
|
||||
_sym_db.RegisterMessage(CustomHttpPattern)
|
||||
|
||||
|
||||
DESCRIPTOR.has_options = True
|
||||
DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\016com.google.apiB\tHttpProtoP\001ZAgoogle.golang.org/genproto/googleapis/api/annotations;annotations\370\001\001\242\002\004GAPI'))
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
2514
lib/ln/rpc_pb2.py
Normal file
2514
lib/ln/rpc_pb2.py
Normal file
File diff suppressed because one or more lines are too long
301
lib/ln/rpc_pb2_grpc.py
Normal file
301
lib/ln/rpc_pb2_grpc.py
Normal file
@ -0,0 +1,301 @@
|
||||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
||||
import grpc
|
||||
|
||||
import rpc_pb2 as rpc__pb2
|
||||
|
||||
|
||||
class ElectrumBridgeStub(object):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
|
||||
def __init__(self, channel):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
channel: A grpc.Channel.
|
||||
"""
|
||||
self.SetHdSeed = channel.unary_unary(
|
||||
'/electrumbridge.ElectrumBridge/SetHdSeed',
|
||||
request_serializer=rpc__pb2.SetHdSeedRequest.SerializeToString,
|
||||
response_deserializer=rpc__pb2.SetHdSeedResponse.FromString,
|
||||
)
|
||||
self.NewAddress = channel.unary_unary(
|
||||
'/electrumbridge.ElectrumBridge/NewAddress',
|
||||
request_serializer=rpc__pb2.NewAddressRequest.SerializeToString,
|
||||
response_deserializer=rpc__pb2.NewAddressResponse.FromString,
|
||||
)
|
||||
self.ConfirmedBalance = channel.unary_unary(
|
||||
'/electrumbridge.ElectrumBridge/ConfirmedBalance',
|
||||
request_serializer=rpc__pb2.ConfirmedBalanceRequest.SerializeToString,
|
||||
response_deserializer=rpc__pb2.ConfirmedBalanceResponse.FromString,
|
||||
)
|
||||
self.FetchRootKey = channel.unary_unary(
|
||||
'/electrumbridge.ElectrumBridge/FetchRootKey',
|
||||
request_serializer=rpc__pb2.FetchRootKeyRequest.SerializeToString,
|
||||
response_deserializer=rpc__pb2.FetchRootKeyResponse.FromString,
|
||||
)
|
||||
self.ListUnspentWitness = channel.unary_unary(
|
||||
'/electrumbridge.ElectrumBridge/ListUnspentWitness',
|
||||
request_serializer=rpc__pb2.ListUnspentWitnessRequest.SerializeToString,
|
||||
response_deserializer=rpc__pb2.ListUnspentWitnessResponse.FromString,
|
||||
)
|
||||
self.NewRawKey = channel.unary_unary(
|
||||
'/electrumbridge.ElectrumBridge/NewRawKey',
|
||||
request_serializer=rpc__pb2.NewRawKeyRequest.SerializeToString,
|
||||
response_deserializer=rpc__pb2.NewRawKeyResponse.FromString,
|
||||
)
|
||||
self.FetchInputInfo = channel.unary_unary(
|
||||
'/electrumbridge.ElectrumBridge/FetchInputInfo',
|
||||
request_serializer=rpc__pb2.FetchInputInfoRequest.SerializeToString,
|
||||
response_deserializer=rpc__pb2.FetchInputInfoResponse.FromString,
|
||||
)
|
||||
self.ComputeInputScript = channel.unary_unary(
|
||||
'/electrumbridge.ElectrumBridge/ComputeInputScript',
|
||||
request_serializer=rpc__pb2.ComputeInputScriptRequest.SerializeToString,
|
||||
response_deserializer=rpc__pb2.ComputeInputScriptResponse.FromString,
|
||||
)
|
||||
self.SignOutputRaw = channel.unary_unary(
|
||||
'/electrumbridge.ElectrumBridge/SignOutputRaw',
|
||||
request_serializer=rpc__pb2.SignOutputRawRequest.SerializeToString,
|
||||
response_deserializer=rpc__pb2.SignOutputRawResponse.FromString,
|
||||
)
|
||||
self.PublishTransaction = channel.unary_unary(
|
||||
'/electrumbridge.ElectrumBridge/PublishTransaction',
|
||||
request_serializer=rpc__pb2.PublishTransactionRequest.SerializeToString,
|
||||
response_deserializer=rpc__pb2.PublishTransactionResponse.FromString,
|
||||
)
|
||||
self.LockOutpoint = channel.unary_unary(
|
||||
'/electrumbridge.ElectrumBridge/LockOutpoint',
|
||||
request_serializer=rpc__pb2.LockOutpointRequest.SerializeToString,
|
||||
response_deserializer=rpc__pb2.LockOutpointResponse.FromString,
|
||||
)
|
||||
self.UnlockOutpoint = channel.unary_unary(
|
||||
'/electrumbridge.ElectrumBridge/UnlockOutpoint',
|
||||
request_serializer=rpc__pb2.UnlockOutpointRequest.SerializeToString,
|
||||
response_deserializer=rpc__pb2.UnlockOutpointResponse.FromString,
|
||||
)
|
||||
self.ListTransactionDetails = channel.unary_unary(
|
||||
'/electrumbridge.ElectrumBridge/ListTransactionDetails',
|
||||
request_serializer=rpc__pb2.ListTransactionDetailsRequest.SerializeToString,
|
||||
response_deserializer=rpc__pb2.ListTransactionDetailsResponse.FromString,
|
||||
)
|
||||
self.SendOutputs = channel.unary_unary(
|
||||
'/electrumbridge.ElectrumBridge/SendOutputs',
|
||||
request_serializer=rpc__pb2.SendOutputsRequest.SerializeToString,
|
||||
response_deserializer=rpc__pb2.SendOutputsResponse.FromString,
|
||||
)
|
||||
self.IsSynced = channel.unary_unary(
|
||||
'/electrumbridge.ElectrumBridge/IsSynced',
|
||||
request_serializer=rpc__pb2.IsSyncedRequest.SerializeToString,
|
||||
response_deserializer=rpc__pb2.IsSyncedResponse.FromString,
|
||||
)
|
||||
self.SignMessage = channel.unary_unary(
|
||||
'/electrumbridge.ElectrumBridge/SignMessage',
|
||||
request_serializer=rpc__pb2.SignMessageRequest.SerializeToString,
|
||||
response_deserializer=rpc__pb2.SignMessageResponse.FromString,
|
||||
)
|
||||
|
||||
|
||||
class ElectrumBridgeServicer(object):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
|
||||
def SetHdSeed(self, request, context):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def NewAddress(self, request, context):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def ConfirmedBalance(self, request, context):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def FetchRootKey(self, request, context):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def ListUnspentWitness(self, request, context):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def NewRawKey(self, request, context):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def FetchInputInfo(self, request, context):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def ComputeInputScript(self, request, context):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def SignOutputRaw(self, request, context):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def PublishTransaction(self, request, context):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def LockOutpoint(self, request, context):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def UnlockOutpoint(self, request, context):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def ListTransactionDetails(self, request, context):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def SendOutputs(self, request, context):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def IsSynced(self, request, context):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def SignMessage(self, request, context):
|
||||
# missing associated documentation comment in .proto file
|
||||
pass
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
|
||||
def add_ElectrumBridgeServicer_to_server(servicer, server):
|
||||
rpc_method_handlers = {
|
||||
'SetHdSeed': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.SetHdSeed,
|
||||
request_deserializer=rpc__pb2.SetHdSeedRequest.FromString,
|
||||
response_serializer=rpc__pb2.SetHdSeedResponse.SerializeToString,
|
||||
),
|
||||
'NewAddress': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.NewAddress,
|
||||
request_deserializer=rpc__pb2.NewAddressRequest.FromString,
|
||||
response_serializer=rpc__pb2.NewAddressResponse.SerializeToString,
|
||||
),
|
||||
'ConfirmedBalance': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.ConfirmedBalance,
|
||||
request_deserializer=rpc__pb2.ConfirmedBalanceRequest.FromString,
|
||||
response_serializer=rpc__pb2.ConfirmedBalanceResponse.SerializeToString,
|
||||
),
|
||||
'FetchRootKey': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.FetchRootKey,
|
||||
request_deserializer=rpc__pb2.FetchRootKeyRequest.FromString,
|
||||
response_serializer=rpc__pb2.FetchRootKeyResponse.SerializeToString,
|
||||
),
|
||||
'ListUnspentWitness': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.ListUnspentWitness,
|
||||
request_deserializer=rpc__pb2.ListUnspentWitnessRequest.FromString,
|
||||
response_serializer=rpc__pb2.ListUnspentWitnessResponse.SerializeToString,
|
||||
),
|
||||
'NewRawKey': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.NewRawKey,
|
||||
request_deserializer=rpc__pb2.NewRawKeyRequest.FromString,
|
||||
response_serializer=rpc__pb2.NewRawKeyResponse.SerializeToString,
|
||||
),
|
||||
'FetchInputInfo': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.FetchInputInfo,
|
||||
request_deserializer=rpc__pb2.FetchInputInfoRequest.FromString,
|
||||
response_serializer=rpc__pb2.FetchInputInfoResponse.SerializeToString,
|
||||
),
|
||||
'ComputeInputScript': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.ComputeInputScript,
|
||||
request_deserializer=rpc__pb2.ComputeInputScriptRequest.FromString,
|
||||
response_serializer=rpc__pb2.ComputeInputScriptResponse.SerializeToString,
|
||||
),
|
||||
'SignOutputRaw': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.SignOutputRaw,
|
||||
request_deserializer=rpc__pb2.SignOutputRawRequest.FromString,
|
||||
response_serializer=rpc__pb2.SignOutputRawResponse.SerializeToString,
|
||||
),
|
||||
'PublishTransaction': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.PublishTransaction,
|
||||
request_deserializer=rpc__pb2.PublishTransactionRequest.FromString,
|
||||
response_serializer=rpc__pb2.PublishTransactionResponse.SerializeToString,
|
||||
),
|
||||
'LockOutpoint': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.LockOutpoint,
|
||||
request_deserializer=rpc__pb2.LockOutpointRequest.FromString,
|
||||
response_serializer=rpc__pb2.LockOutpointResponse.SerializeToString,
|
||||
),
|
||||
'UnlockOutpoint': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.UnlockOutpoint,
|
||||
request_deserializer=rpc__pb2.UnlockOutpointRequest.FromString,
|
||||
response_serializer=rpc__pb2.UnlockOutpointResponse.SerializeToString,
|
||||
),
|
||||
'ListTransactionDetails': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.ListTransactionDetails,
|
||||
request_deserializer=rpc__pb2.ListTransactionDetailsRequest.FromString,
|
||||
response_serializer=rpc__pb2.ListTransactionDetailsResponse.SerializeToString,
|
||||
),
|
||||
'SendOutputs': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.SendOutputs,
|
||||
request_deserializer=rpc__pb2.SendOutputsRequest.FromString,
|
||||
response_serializer=rpc__pb2.SendOutputsResponse.SerializeToString,
|
||||
),
|
||||
'IsSynced': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.IsSynced,
|
||||
request_deserializer=rpc__pb2.IsSyncedRequest.FromString,
|
||||
response_serializer=rpc__pb2.IsSyncedResponse.SerializeToString,
|
||||
),
|
||||
'SignMessage': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.SignMessage,
|
||||
request_deserializer=rpc__pb2.SignMessageRequest.FromString,
|
||||
response_serializer=rpc__pb2.SignMessageResponse.SerializeToString,
|
||||
),
|
||||
}
|
||||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'electrumbridge.ElectrumBridge', rpc_method_handlers)
|
||||
server.add_generic_rpc_handlers((generic_handler,))
|
||||
@ -1,13 +1,19 @@
|
||||
import asyncio
|
||||
|
||||
async def handler(reader, writer):
|
||||
magic = await reader.read(6)
|
||||
magic = await reader.read(5+6)
|
||||
await asyncio.sleep(5)
|
||||
print("in five sec!")
|
||||
await asyncio.sleep(5)
|
||||
writer.write(b'{\n "r_preimage": "6UNoNhDZ/0awtaDTM7KuCtlYcNkNljscxMLleoJv9+o=",\n "r_hash": "t7IwR6zq8ZAfHaxvTnPmHdyt9j2tVd9g6TDg59C4juM=",\n "value": "8192",\n "settled": true,\n "creation_date": "1519994196",\n "settle_date": "1519994199",\n "payment_request": "lntb81920n1pdfj325pp5k7erq3avatceq8ca43h5uulxrhw2ma3a442a7c8fxrsw059c3m3sdqqcqzysdpwv4dn2xd74lfmea3taxj6pjfxrdl42t8w7ceptgv5ds0td0ypk47llryl6t4a48x54d7mnwremgcmljced4dhwty9g3pfywr307aqpwtkzf4",\n "expiry": "3600",\n "cltv_expiry": "144"\n}\n')
|
||||
writer.write(b'{\n "r_preimage": "6UNoNhDZ/0awtaDTM7KuCtlYcNkNljscxMLleoJv9+o=",\n "r_hash": "lQDtsJlLe8IzSRk0hrJcgglwRdtkHzX6mIwOhJrN7Ck=",\n "value": "8192",\n "settled": true,\n "creation_date": "1519994196",\n "settle_date": "1519994199",\n "payment_request": "lntb81920n1pdfj325pp5k7erq3avatceq8ca43h5uulxrhw2ma3a442a7c8fxrsw059c3m3sdqqcqzysdpwv4dn2xd74lfmea3taxj6pjfxrdl42t8w7ceptgv5ds0td0ypk47llryl6t4a48x54d7mnwremgcmljced4dhwty9g3pfywr307aqpwtkzf4",\n "expiry": "3600",\n "cltv_expiry": "144"\n}\n'.replace(b"\n",b""))
|
||||
await writer.drain()
|
||||
print(magic)
|
||||
|
||||
async def handler2(reader, writer):
|
||||
while True:
|
||||
data = await reader.read(2048)
|
||||
print(data)
|
||||
|
||||
asyncio.ensure_future(asyncio.start_server(handler, "127.0.0.1", 1080))
|
||||
asyncio.ensure_future(asyncio.start_server(handler2, "127.0.0.1", 8090))
|
||||
asyncio.get_event_loop().run_forever()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user