Example #1
0
        public async Task OutBoundConnectAll()
        {
            var clightningPeerInfo = await CLightningClient.ListPeersAsync();

            var lndPeerInfo = await LndClient.SwaggerClient.ListPeersAsync();

            var nrlInfo = await NRustLightningHttpClient.GetInfoAsync();

            if (clightningPeerInfo.Any(x => x.Id.Equals(nrlInfo.ConnectionString.NodeId.ToHex())) &&
                lndPeerInfo.Peers.Any(x => x.Pub_key.Equals(nrlInfo.ConnectionString.NodeId.ToHex())))
            {
                return;
            }

            var lndConnString        = (await LndLNClient.GetInfo()).NodeInfoList.First().ToConnectionString();
            var clightningConnString = (await ClightningLNClient.GetInfo()).NodeInfoList.First().ToConnectionString();
            await NRustLightningHttpClient.ConnectAsync(lndConnString);

            await NRustLightningHttpClient.ConnectAsync(clightningConnString);

            await Support.Utils.Retry(4, TimeSpan.FromSeconds(2), async() =>
            {
                clightningPeerInfo = await CLightningClient.ListPeersAsync();
                lndPeerInfo        = await LndClient.SwaggerClient.ListPeersAsync();
                nrlInfo            = await NRustLightningHttpClient.GetInfoAsync();
                return
                (nrlInfo.NodeIds.Count >= 2 &&
                 clightningPeerInfo.Any(x => x.Id.Equals(nrlInfo.ConnectionString.NodeId.ToHex())) &&
                 lndPeerInfo.Peers.Any(x => x.Pub_key.Equals(nrlInfo.ConnectionString.NodeId.ToHex())));
            }, "Failed to establish outbound connection");
        }
Example #2
0
        public async Task ConnectAll()
        {
            var clightningInfo = await ClightningLNClient.GetInfo();

            await NRustLightningHttpClient.ConnectAsync(clightningInfo.NodeInfoList.FirstOrDefault().ToConnectionString());

            var lndInfo = await LndLNClient.GetInfo();

            await NRustLightningHttpClient.ConnectAsync(lndInfo.NodeInfoList.FirstOrDefault().ToConnectionString());

            await LndLNClient.ConnectTo(clightningInfo.NodeInfoList.FirstOrDefault());
        }