Skip to content

Commit

Permalink
lndmanage: communicate with lndmanaged
Browse files Browse the repository at this point in the history
  • Loading branch information
bitromortac committed May 1, 2022
1 parent 4b51a50 commit 5f568bf
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lndmanage/lib/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import lndmanage.grpc_compiled.router_pb2_grpc as lndrouterrpc
import lndmanage.grpc_compiled.walletkit_pb2 as lndwalletkit
import lndmanage.grpc_compiled.walletkit_pb2_grpc as lndwalletkitrpc
import lndmanage.grpc_compiled.manager_pb2 as managermsg
import lndmanage.grpc_compiled.manager_pb2_grpc as managerrpc

from lndmanage.lib.network import Network
from lndmanage.lib.exceptions import PaymentTimeOut, NoRoute, OurNodeFailure
Expand Down Expand Up @@ -53,8 +55,10 @@ class LndNode:
_walletrpc: lndwalletkitrpc.WalletKitStub
_async_rpc: lndrpc.LightningStub
_async_routerrpc: lndrouterrpc.RouterStub
_async_managerrpc: managerrpc.MangagerStub
_async_channel: grpc.aio.Channel
_sync_channel: grpc.Channel
_async_manager_channel: grpc.aio.Channel

# attributes (TODO: clean up)
alias: str
Expand Down Expand Up @@ -152,6 +156,11 @@ async def connect_async_rpcs(self):
self._async_rpc = lndrpc.LightningStub(self._async_channel)
self._async_routerrpc = lndrouterrpc.RouterStub(self._async_channel)

# optionally connect to lndmanged
self._async_manager_channel = grpc.aio.insecure_channel(
'localhost:50051')
self._async_managerrpc = managerrpc.MangagerStub(self._async_manager_channel)

def connect_sync_rpcs(self):
self._sync_channel = grpc.secure_channel(
self.lnd_host, self.get_rpc_credentials(),
Expand Down Expand Up @@ -1039,3 +1048,7 @@ def pubkey_to_channel_map(self):
node_to_channel_map[cv['remote_pubkey']].append(c)

return node_to_channel_map

async def running_services(self):
resp = await self._async_managerrpc.RunningServices(managermsg.RunningServicesRequest())
print(resp)

0 comments on commit 5f568bf

Please sign in to comment.