public static NRustLightningClient GetTestNRustLightningClient(this CustomWebApplicationFactory factory) { var httpClient = factory.CreateClient(); var client = new NRustLightningClient(httpClient.BaseAddress.ToString(), new NRustLightningNetworkProvider(NetworkType.Regtest).GetByCryptoCode("BTC")); client.HttpClient = httpClient; return(client); }
public static NRustLightningClient GetTestNRustLightningClient(this IHost host) { var httpClient = host.GetTestClient(); var client = new NRustLightningClient(httpClient.BaseAddress.ToString(), new NRustLightningNetworkProvider(NetworkType.Regtest).GetByCryptoCode("BTC")); client.HttpClient = httpClient; return(client); }
public Clients(RPCClient bitcoinRPCClient, LndClient lndClient, CLightningClient cLightningClient, NRustLightningClient nRustLightningHttpClient, NBXplorer.ExplorerClient nbxClient) { BitcoinRPCClient = bitcoinRPCClient ?? throw new ArgumentNullException(nameof(bitcoinRPCClient)); LndClient = lndClient ?? throw new ArgumentNullException(nameof(lndClient)); CLightningClient = cLightningClient ?? throw new ArgumentNullException(nameof(cLightningClient)); NRustLightningHttpClient = nRustLightningHttpClient ?? throw new ArgumentNullException(nameof(nRustLightningHttpClient)); NBXClient = nbxClient ?? throw new ArgumentNullException(nameof(nbxClient)); }
static async Task Main(string[] args) { var command = CommandLine.GetRootCommand(); command.Handler = CommandHandler.Create((ParseResult pr) => { Console.WriteLine($"Calling handler"); Network?network; var n = pr.RootCommandResult.ValueForOption <string>("network"); network = n == "mainnet" ? Network.Main : n == "testnet" ? Network.TestNet : n == "regtest" ? Network.RegTest : null; if (network is null) { if (pr.RootCommandResult.ValueForOption <bool>("testnet")) { network = Network.TestNet; } else if (pr.RootCommandResult.ValueForOption <bool>("regtest")) { network = Network.RegTest; } } if (network is null) { network = Network.Main; } var ip = pr.RootCommandResult.ValueForOption <string>("rpcip"); if (String.IsNullOrEmpty(ip)) { ip = "127.0.0.1"; } var networkProvider = new NRustLightningNetworkProvider(network.NetworkType); var nrustLightningNetwork = networkProvider.GetByCryptoCode(pr.RootCommandResult.ValueForOption <string>("cryptocode") ?? "btc"); var port = pr.RootCommandResult.ValueForOption <int>("rpcport"); if (port == 0) { port = 80; } var baseUrl = $"http://{ip}:{port}"; var client = new NRustLightningClient(baseUrl, nrustLightningNetwork); var subCommand = pr.CommandResult.Symbol.Name; Console.WriteLine($"Subcomamnd is {subCommand}"); if (subCommand == SubCommands.GetInfo) { var nodeInfo = client.GetInfoAsync().Result; Console.WriteLine(nodeInfo.ConnectionString); } else { throw new ArgumentException($"Unknown sub command {subCommand}"); } return; }); var commandLine = new CommandLineBuilder(command).UseDefaults() .Build(); await commandLine.InvokeAsync(args); }