Ejemplo n.º 1
0
        public LndGrpcService(IConfiguration config)
        {
            /*
             * var certLoc = config.GetValue<string>("cert");
             * var macLoc = config.GetValue<string>("mac");
             * ;
             *
             * var directory = Path.GetFullPath(certLoc);
             * Console.WriteLine(rpc + " stuff " + directory);*/
            var directory = Environment.CurrentDirectory;
            var tls       = File.ReadAllText(directory + "./../lnd-test-cluster/docker/temp/lnd-alice/tls.cert");
            var hexMac    = Util.ToHex(File.ReadAllBytes(directory + "./../lnd-test-cluster/docker/temp/lnd-alice/data/chain/bitcoin/regtest/admin.macaroon"));
            var rpc       = config.GetValue <string>("rpc");

            feePercentage    = config.GetValue <uint>("fee");
            maxSatPerPayment = config.GetValue <uint>("max_sat");
            maxVouchers      = config.GetValue <uint>("max_voucher");
            var macaroonCallCredentials = new MacaroonCallCredentials(hexMac);
            var channelCreds            = ChannelCredentials.Create(new SslCredentials(tls), macaroonCallCredentials.credentials);
            var lndChannel = new Grpc.Core.Channel(rpc, channelCreds);

            client  = new Lightning.LightningClient(lndChannel);
            getInfo = client.GetInfo(new GetInfoRequest());
            Console.WriteLine(getInfo.ToString());
        }
Ejemplo n.º 2
0
        public async Task <string> ConnectToLnd(string host, string cert)
        {
            Debug.Log("connecting to lnd");

            HostName = host;
            Cert     = cert;
            var channelCreds = new SslCredentials(cert);

            rpcChannel = new Grpc.Core.Channel(host, channelCreds);

            lndClient = new Lightning.LightningClient(rpcChannel);
            InvokeRepeating("TryConnecting", 3, 5);
            return("connected");
        }
Ejemplo n.º 3
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.º 4
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();
        }