def index(self):
        ln = LightningClient(rpc_uri=LND_RPC_URI, peer_uri=LND_PEER_URI)

        lnd_info = ln.get_info()
        if lnd_info is False:
            lnd_info = {}
        else:
            lnd_info = MessageToDict(lnd_info)


        peers = ln.get_peers()
        if not peers:
            peers = {'No peers': ' '}
        else:
            peers = [MessageToDict(p) for p in peers]

        channels = ln.get_channels()
        if not channels:
            channels = {'No channels': ' '}
        else:
            channels = [MessageToDict(c) for c in channels]

        return self.render('admin/lnd/lnd_dashboard.html',
                           lnd_info=lnd_info,
                           peers=peers,
                           channels=channels)
示例#2
0
    def index(self):
        rpc_uri = os.environ.get('LND_RPC_URI', '127.0.0.1:10009')
        peer_uri = os.environ.get('LND_PEER_URI', '127.0.0.1:9735')
        ln = LightningClient(rpc_uri=rpc_uri, peer_uri=peer_uri)

        try:
            lnd_info = ln.get_info()
            lnd_info = MessageToDict(lnd_info)
        except Exception as exc:
            lnd_info = {'Error': ' '.join([str(type(exc)), str(exc)])}

        try:
            peers = ln.get_peers()
            peers = MessageToDict(peers)['peers']
            if not peers:
                peers = {'No peers': ' '}
        except Exception as exc:
            peers = {'Error': ' '.join([str(type(exc)), str(exc)])}

        try:
            channels = ln.get_channels()
            channels = MessageToDict(channels)['channels']
            if not channels:
                channels = {'No channels': ' '}
        except Exception as exc:
            channels = {'Error': ' '.join([str(type(exc)), str(exc)])}

        return self.render('admin/lnd_dashboard.html',
                           lnd_info=lnd_info,
                           peers=peers,
                           channels=channels)
 def setup_channel(source_node: LightningClient,
                   destination_node: LightningClient, local_amount: int,
                   push_amount: int):
     pubkey = destination_node.pubkey
     source_node.open_channel(pubkey=pubkey,
                              local_amount=local_amount,
                              push_amount=push_amount)
 def setup_channel(source_node: LightningClient,
                   destination_node: LightningClient,
                   local_amount: int,
                   push_amount: int):
     pubkey = destination_node.pubkey
     source_node.open_channel(pubkey=pubkey,
                              local_amount=local_amount,
                              push_amount=push_amount)
 def setup_p2p_connection(source_node: LightningClient,
                          destination_node: LightningClient):
     try:
         source_node.connect(destination_node.pubkey,
                             destination_node.listening_uri)
     except Exception as exc:
         if 'already connected to peer' in exc._state.details:
             pass
         else:
             raise
 def setup_p2p_connection(source_node: LightningClient,
                          destination_node: LightningClient):
     try:
         source_node.connect_peer(destination_node.pubkey,
                                  destination_node.listening_uri)
     except Exception as exc:
         if 'already connected to peer' in exc._state.details:
             pass
         else:
             raise
    def __init__(self):
        self.alice = LightningClient('localhost:10001', 'localhost:10011',
                                     'alice')

        self.bob = LightningClient('localhost:10002', 'localhost:10012', 'bob')

        self.charlie = LightningClient('localhost:10003', 'localhost:10013',
                                       'charlie')

        self.nodes = [self.alice, self.bob, self.charlie]
        self.setup_p2p()
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     rpc_uri = os.environ.get('LND_RPC_URI', '127.0.0.1:10009')
     peer_uri = os.environ.get('LND_PEER_URI', '127.0.0.1:9735')
     self.ln = LightningClient(rpc_uri=rpc_uri, peer_uri=peer_uri)
 def send_payment(source_node: LightningClient,
                  destination_node: LightningClient,
                  amount: int):
     invoice = destination_node.create_invoice(amount=amount).payment_request
     source_node.send_payment(encoded_invoice=invoice)
 def send_payment(source_node: LightningClient,
                  destination_node: LightningClient,
                  amount: int):
     invoice = destination_node.create_invoice(amount=amount).payment_request
     source_node.send_payment(encoded_invoice=invoice)