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()); }
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"); }
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"); }
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(); }