Ejemplo n.º 1
0
        public async Task <string> ConnectToLndWithMacaroon(string host, string cert, string macaroon)
        {
            Debug.Log("connecting to lnd");
            HostName = host;
            Cert     = cert;
            var macaroonCallCredentials = new MacaroonCallCredentials(macaroon);
            var sslCreds     = new SslCredentials(cert);
            var channelCreds = ChannelCredentials.Create(sslCreds, macaroonCallCredentials.credentials);

            rpcChannel = new Grpc.Core.Channel(host, channelCreds);
            lndClient  = new Lightning.LightningClient(rpcChannel);
            InvokeRepeating("TryConnecting", 3, 5);

            return("connected");
        }
Ejemplo n.º 2
0
        public LndService(IConfiguration config)
        {
            var directory = Environment.CurrentDirectory;
            var tls       = File.ReadAllText(directory + "/tls.cert");
            var rpc       = config.GetValue <string>("rpc");

            var macaroonCallCredentials = MacaroonCallCredentials.FromFile(File.ReadAllBytes(directory + "/admin.macaroon"));

            var channelCreds = ChannelCredentials.Create(new SslCredentials(tls), macaroonCallCredentials.credentials);

            lndChannel      = new Grpc.Core.Channel(rpc, channelCreds);
            lightningClient = new Lightning.LightningClient(lndChannel);
            invoicesClient  = new Invoices.InvoicesClient(lndChannel);

            var getInfo = lightningClient.GetInfo(new GetInfoRequest());

            provider          = new RNGCryptoServiceProvider();
            OnInvoiceCreated += LndService_OnInvoiceCreated;
            Console.WriteLine(getInfo.ToString());
            //CancelExistingInvoices();

            ListenInvoices();
        }